01: 与做备库一样,配置好 监听文件 密码文件 网络文件 并且动好监听. 注意必要的目录结构.然后从主库,备库1 都能用SYS用户登陆到备库2 表示通道是联通有效的.
02: 从主库生成个最新的INIT.ORA文件,复制到备库2 修改参数文件的参数.
startup nomount pfile='/home/oracle/initdg.ora';
create spfile from pfile='/home/oracle/initdg.ora';
shutdown immeidate;
startup nomount;
主库 设置下面两个参数
pd:
ALTER SYSTEM SET LOG_ARCHIVE_DEST_3='SERVICE=dg2 LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg2' scope=both;
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(pd,dg1,dg2)' scope=both;
在主库上复制备库到备库2上,源数据库必须是主库
pd:
rman target sys/pbs123@orcl_pd auxiliary sys/pbs123@orcl_st3
RMAN> duplicate target database for standby nofilenamecheck from active database;
————————输出省略——————
pd:
alter system set log_archive_dest_state_3=enable scope=both;
开启只读模式完成数据恢复
dg2:
alter database open read only;
alter database recover managed standby database using current logfile disconnect from session;
ALTER SYSTEM SET log_archive_dest_1='LOCATION=/u01/ora_archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=dg2' scope=both;
设置好参数,注意服务器是DG1
alter system set fal_server='dg1';
alter system set fal_client='dg2';
数据同步完了后…
主库pd:
alter system set log_archive_dest_state_3=defer scope=both;
备库1
dg1:
ALTER SYSTEM SET LOG_ARCHIVE_DEST_3='SERVICE=dg2 LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,dg2)' scope=both;
测试下:
主库:
sql> create table zfk_all_objects as select * from dba_objects;
Table created.
Elapsed: 00:00:01.80
备库1:
sql> select count(*) from zfk_all_objects;
COUNT(*)
73680
备库2:
sql> select count(*) from zfk_all_objects;
COUNT(*)
73680
**
注意事项:
1 DG1 设置目的3的时候 应该改成如下
alter system set log_archive_dest_3='SERVICE=dg2LGWR ASYNC AFFIRM valid_for=(standby_logfiles,standby_role) db_unique_name=dg2' scope=BOTH;
2 只有主库发生了日志切换 DG1才把日志传给DG2
**