SQL> select force_logging,log_mode,cdb from gv$database;
FORCE_LOGGINGLOG_MODE CDB
---------------------------------------
YESARCHIVELOG YES
如果没有开启强制日志:
alter database force logging;
如果没有开启归档日志:
shutdown immediate
startup mount
alter database archivelog;
alter database open;
alter pluggable database all open;
d.主库添加stanby log文件
set line222
col member for a60
select t2.thread#,t1.group#,t1.member,t2.bytes/1024/1024 from v$logfile t1,v$log t2 where t1.group#=t2.group# order by 1,2;
--需要注意:
--1.stanby log日志大小至少要和redo log日志一样大小,不能小于
--2.stanby log数量: standby logfile=(1+logfile组数)=(1+2)=3组,每个thread需要加3组standby logfile.
--3.thread要与redo log保持一致,如果是rac,需要增加多个thread对应的standby log
ALTER DATABASE ADD STANDBY LOGFILE thread 1
group 5 ('+DATA') SIZE 120M,
group 6 ('+DATA') SIZE 120M,
group 7 ('+DATA') SIZE 120M;
ALTER DATABASE ADD STANDBY LOGFILE thread 2
group 8 ('+DATA') SIZE 120M,
group 9 ('+DATA') SIZE 120M,
group 10 ('+DATA') SIZE 120M;
select t2.thread#,t1.group#,t1.member,t2.bytes/1024/1024 from v$logfile t1,v$standby_log t2 where t1.group#=t2.group# order by 1,2;
--主库设置DG参数
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(CDB19C,CDB19C_STBY)' sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=CDB19C' sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=cdb19c_stby ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=CDB19C_STBY' sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=4 sid='*';
ALTER SYSTEM SET FAL_SERVER=CDB19C_STBY sid='*';
ALTER SYSTEM SET FAL_CLIENT=CDB19C sid='*';
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='+DATA','/oradata/CDB19C_STBY' SCOPE=SPFILE sid='*';
ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='+DATA','/oradata/CDB19C_STBY' SCOPE=SPFILE sid='*';
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO sid='*';
注意:RAC修改参数需要加上 sid='*',修改多个实例。
--备库设置DG参数
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(CDB19C_STBY,CDB19C)';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=CDB19C_STBY';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=CDB19C ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=CDB19C';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;
ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=4;
ALTER SYSTEM SET FAL_SERVER=CDB19C;
ALTER SYSTEM SET FAL_CLIENT=CDB19C_STBY;
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/oradata/CDB19C_STBY','+DATA' SCOPE=SPFILE;
ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/oradata/CDB19C_STBY','+DATA' SCOPE=SPFILE;
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
查看OMF参数配置:
show parameter db_create_file_dest
注意:如果同时设置OMG和DB_FILE_NAME_CONVERT参数,则优先OMF参数。
五、开启日志应用
##备库执行
alter database recover managed standby database using current logfile disconnect from session;
##主库执行
alter system set log_archive_dest_state_2=enable sid='*';
六、测试同步
主库创建测试数据:
alter session set container=orcl;
sqlplus lucifer/lucifer@orcl
备库查看是否同步:
至此,ADG已搭建完毕。感谢食用~
参考文章:
官方文档12c:Using DBCA to Create a Data Guard Standby 12C
官方文档19c:Using DBCA to Create a Data Guard Standby 19C
官方文档21c:Using DBCA to Create a Data Guard Standby 21C
MOS文档:Creating a Physical Standby database using DBCA duplicate (Doc ID 2283697.1)
以上就是DBCA搭建Oracle ADG的详细内容,更多关于DBCA搭建Oracle ADG的资料请关注脚本之家其它相关文章!