1.说明:
本次是通过duplicate from active database创建 DG,然后以Active data guard的方式打开。操作的详细过程不再列举,只列主要部分:
主节点:db_unique_name:ocm01
standby节点:db_unique_name:dup01
2.创建DG
前提需要配好网络,并且是静态监听,auxiliary辅助库写个db_name能启动到nomount,能连上就可以了。还有密码文件别忘了。
rman target / auxiliary sys/system@dup01
run {
duplicate target database
for standby
from active database
dorecover
spfile
set "db_unique_name"="dup01"
SET LOG_ARCHIVE_DEST_2="service=ocm01 ASYNC REGISTER
VALID_FOR=(online_logfile,primary_role)"
set fal_server="ocm01"
set control_files='/u01/oradata/dup01/control01.ctl'
set log_file_name_convert='/app/oracle/oradata/ocm01/','/u01/oradata/dup01/'
set db_file_name_convert='/app/oracle/oradata/ocm01/','/u01/oradata/dup01/'
nofilenamecheck;
}
也可用下面的脚本,和primary同样的路径:
run {
duplicate target database
for standby
from active database
dorecover
spfile
set "db_unique_name"="dup01"
SET LOG_ARCHIVE_DEST_2="service=ocm01 ASYNC REGISTER
VALID_FOR=(online_logfile,primary_role)"
set fal_server="ocm01"
nofilenamecheck;
}
可能会有参数不正确的改改,确保日志能够正常传递。
3.以Active data Guard方式打开:
SQL> startupSQL> select open_mode from V$database;
OPEN_MODE
--------------------
READ ONLY
SQL> alter database recover managed standby database disconnect from session;
SQL> select open_mode from V$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
4.修改实时应用:
上面方法是切归档才能实现数据同步。如果想实时应用变化,可以:1》.添加standby redo logfile :
standby redo是添加在备库上的,主库也可以添加,防止switch后,变成备库时使用。也可以在创建DataGuard之前添加在主库,在创建DataGuard时,备库自然也就有了,比较省事。
2》.打开实时应用:SQL> alter database recover managed standby database using current logfile disconnect from session;
此时就可以实时应用。