Oracle10.2.0.1 DataGuard部署--王清清
一、实验环境
rhel-server-5.5-x86_64-dvd.iso
Oracle 10201_database_linux_x86_64
INSTANCE SID | DB NAME | IP | STORAGE |
orcl | orcl | 192.168.248.19 | File system |
wood | orcll | 192.168.248.151 | file system |
二、开始配置primary和standby
2.1启用强制日志功能
主库备库启用强制日志功能
SQL> select force_logging from v$database;
SQL> ALTER DATABASE FORCE LOGGING;
2.2启用归档模式
主库备库启用归档模式
点击(此处)折叠或打开
- shutdown immediate;
- startup mount;
- alter database archivelog;
- alter database open
2.3 Primary和Standby创建口令文件
主库备库创建口令文件
点击(此处)折叠或打开
- #su – oracle
- orapwd FILE='/u01/app/oracle/product/10.2.0/db_1/dbs/orapworcl' PASSWORD=oracle ENTRIES=5;
- #su - oracle
- orapwd FILE='/u01/app/oracle/product/10.2.0/db_1/dbs/orapwwood' PASSWORD=oracle ENTRIES=5;
2.4配置standby redo logfile
在主库和备库分别添加standby redo logfile
- alter database add standby logfile thread 1 group 4('/u01/app/oracle/oradata/orcl/redo04.log') size 50M;
- alter database add standby logfile thread 1 group 5('/u01/app/oracle/oradata/orcl/redo05.log') size 50M;
- alter database add standby logfile thread 1 group 6('/u01/app/oracle/oradata/orcl/redo06.log') size 50M;
- alter database add standby logfile thread 1 group 7('/u01/app/oracle/oradata/orcl/redo07.log') size 50M
2.5配置network service
2.5.1静态注册主、备库
点击(此处)折叠或打开
- 主库:192.168.248.19
- $more listener.ora
- #########################使用静态注册
- SID_LIST_LISTENER=
- (SID_LIST=
- (SID_DESC=
- (GLOBAL_DBNAME=cxdb)
- (SID_NAME=orcl)
- (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
- )
- )
-
- LISTENER=
- (DESCRIPTION_LIST=
- (DESCRIPTION=
- (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.248.19)(PORT=1521))
- (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
- )
- )
- ###
-
- 备库192.168.248.151
- $more listener.ora
- ###############################使用静态注册
- SID_LIST_LISTENER=
- (SID_LIST=
- (SID_DESC=
- (GLOBAL_DBNAME=xxdb)
- (SID_NAME=wood)
- (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
- )
- )
-
- LISTENER=
- (DESCRIPTION_LIST=
- (DESCRIPTION=
- (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.248.151)(PORT=1521))
- (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
- )
- )
- #######
2.5.2配置tnsnames.ora
点击(此处)折叠或打开
- 主库和备库的tnsnames.ora如下
- $more tnsnames.ora
- # Generated by Oracle configuration tools.
- xxnet =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.248.151)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SID = wood)
- (SERVICE_NAME = xxdb)
- )
- )
-
- cxnet =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.248.19)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SID = orcl)
- (SERVICE_NAME = cxdb)
- )
- )
- ########
2.5.3启动listener、测试网络
启动主、备库监听,测试网络通畅
$lsnrctl start
2.6配置主、备库初始化参数文件
主库:192.168.248.19,添加以下参数
点击(此处)折叠或打开
- DB_UNIQUE_NAME=cxdb
- LOG_ARCHIVE_CONFIG='DG_CONFIG=(cxdb,xxdb)'
- LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/flash_recovery_area/ORCL/arch1/ VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)'
- LOG_ARCHIVE_DEST_2='LOCATION=/u01/app/oracle/flash_recovery_area/ORCL/arch2/ VALID_FOR=(STANDBY_LOGFILE,STANDBY_ROLE)'
- LOG_ARCHIVE_DEST_3='SERVICE=xxnet LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=xxdb'
- LOG_ARCHIVE_DEST_STATE_1=ENABLE
- LOG_ARCHIVE_DEST_STATE_2=ENABLE
- REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
- DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/'
- LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/'
- STANDBY_FILE_MANAGEMENT=AUTO
- FAL_SERVER=xxnet
- FAL_CLIENT=cxnet
- ######################
备库:192.168.248.151,添加以下参数
点击(此处)折叠或打开
- DB_UNIQUE_NAME=cxdb
- LOG_ARCHIVE_CONFIG='DG_CONFIG=(cxdb,xxdb)'
- LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/flash_recovery_area/arch1/ VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)'
- LOG_ARCHIVE_DEST_2='LOCATION=/u01/app/oracle/flash_recovery_area/arch2/ VALID_FOR=(STANDBY_LOGFILE,STANDBY_ROLE)'
- LOG_ARCHIVE_DEST_3='SERVICE=cxnet LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=cxdb'
- LOG_ARCHIVE_DEST_STATE_1=ENABLE
- LOG_ARCHIVE_DEST_STATE_2=ENABLE
- REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
- DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/','/u01/app/oracle/oradata/orcl/'
- LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/','/u01/app/oracle/oradata/orcl/'
- STANDBY_FILE_MANAGEMENT=AUTO
- FAL_SERVER=cxnet
- FAL_CLIENT=xxnet
- #####################
三、一步一步创建physical standby
3.1 备份主库
点击(此处)折叠或打开
- run{
- backup database format '/u01/backup/full_%U' plus archivelog format
- '/u01/backup/arc_%U';
- }
3.2 创建 standby controlfile
点击(此处)折叠或打开
- SQL> STARTUP MOUNT;
- SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/u01/backup/st.ctl';
- SQL> ALTER DATABASE OPEN
3.3 使用 RMAN 进行创建 standby database
3.3.1 将主库的备份集和controlfile拷贝到备库相同目录下
3.3.2 使用rman进行创建standby DB
点击(此处)折叠或打开
- [oracle@localhost~]$ rman target / auxiliary sys/oracle@xxnet
- RMAN> duplicate target database for standby
四、创建完检查physical standby状态
4.1 physical standby创建完检查
4.1.1检查主、备角色
SQL> select database_role, switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY SESSIONS ACTIVE
4.1.2启动备库recovery进程
alter database recover managed standby database disconnect from session;
4.1.3 检查standby DB进程状态
SQL>select PROCESS,STATUS,CLIENT_PROCESS ,THREAD#,SEQUENCE#
from V$MANAGED_STANDBY;
PROCESS STATUS CLIENT_P THREAD# SEQUENCE#
--------- ------------ -------- ---------- ----------
ARCH CLOSING ARCH 1 40
ARCH CLOSING ARCH 1 41
RFS IDLE LGWR 1 42
RFS IDLE UNKNOWN 0 0
MRP0 WAIT_FOR_LOG N/A 1 42
RFS IDLE UNKNOWN 0 0
6 rows selected.
SQL>
4.1.4主库切换日志,备库查看sequence#号
主库切换日志:
SQL> alter system switch logfile;
备库查看进程等待日志序列号:
SQL> select PROCESS,STATUS,CLIENT_PROCESS ,THREAD#,SEQUENCE#
from V$MANAGED_STANDBY;
PROCESS STATUS CLIENT_P THREAD# SEQUENCE#
--------- ------------ -------- ---------- ----------
ARCH CLOSING ARCH 1 42
ARCH CLOSING ARCH 1 41
RFS IDLE UNKNOWN 0 0
MRP0 WAIT_FOR_LOG N/A 1 43
RFS IDLE UNKNOWN 0 0
RFS IDLE LGWR 1 43
6 rows selected.
SQL>
五、主、备角色切换
顺序:
主库-》备库
备库-》主库
5.1 主库切换成备库
alter database commit to switchover to physical standby;
alter database recover managed standby database disconnect from session;
select database_role from v$database;
5.2 备库切换成主库
alter database commit to switchover to physical primary;
alter database open;
5.3 主库切换日志、备库查看日志应用
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29249734/viewspace-1814683/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29249734/viewspace-1814683/