DataGuard 物理备库,正常为 mount 状态,如果想要进行查询,需要转为 ADG,即 read only 状态!
在开启为 read only 之前,需要给备库添加 n+1
组的 standby redo log!
查询主库的 redolog :
setline222setpagesize1000colmemberfora60selectt2.thread#,t1.group#,t1.member,t2.bytes/1024/1024fromv$logfilet1,v$logt2wheret1.group#=t2.group#orderby1,2; THREAD#GROUP#MEMBERT2.BYTES/1024/1024--------------------------------------------------------------------------------------------------11+DATA/mesdb/onlinelog/group_1.257.103418143120012+DATA/mesdb/onlinelog/group_2.258.103418143120015+DATA/mesdb/onlinelog/group_5.268.103418262320017+DATA/mesdb/onlinelog/group_7.270.103418262320019+DATA/mesdb/onlinelog/group_9.272.1034182623200111+DATA/mesdb/onlinelog/group_11.274.1034182623200113+DATA/mesdb/onlinelog/group_13.276.103418262520023+DATA/mesdb/onlinelog/group_3.265.103418226120024+DATA/mesdb/onlinelog/group_4.266.103418226320026+DATA/mesdb/onlinelog/group_6.269.103418262320028+DATA/mesdb/onlinelog/group_8.271.1034182623200210+DATA/mesdb/onlinelog/group_10.273.1034182623200212+DATA/mesdb/onlinelog/group_12.275.1034182623200214+DATA/mesdb/onlinelog/group_14.277.103418262720014rowsselected. =
需要注意:
- stanby log日志大小至少要和redo log日志一样大小,不能小于
- stanby log数量: standby logfile=(1+logfile组数)=(1+2)=3组,每个thread需要加3组standby logfile.
- thread要与redo log保持一致,如果是rac,需要增加多个thread对应的standby log
关闭备库同步进程:
alterdatabaserecovermanagedstandbydatabasecancel;
备库添加standby redo log:
ALTERDATABASEADDSTANDBYLOGFILEthread1group21 ('/data/MESSTB/onlinelog/standby_group_21') SIZE200M, group22 ('/data/MESSTB/onlinelog/standby_group_22') SIZE200M, group23 ('/data/MESSTB/onlinelog/standby_group_23') SIZE200M, group24 ('/data/MESSTB/onlinelog/standby_group_24') SIZE200M, group25 ('/data/MESSTB/onlinelog/standby_group_25') SIZE200M, group26 ('/data/MESSTB/onlinelog/standby_group_26') SIZE200M, group27 ('/data/MESSTB/onlinelog/standby_group_27') SIZE200M, group28 ('/data/MESSTB/onlinelog/standby_group_28') SIZE200M; ALTERDATABASEADDSTANDBYLOGFILEthread2group31 ('/data/MESSTB/onlinelog/standby_group_31') SIZE200M, group32 ('/data/MESSTB/onlinelog/standby_group_32') SIZE200M, group33 ('/data/MESSTB/onlinelog/standby_group_33') SIZE200M, group34 ('/data/MESSTB/onlinelog/standby_group_34') SIZE200M, group35 ('/data/MESSTB/onlinelog/standby_group_35') SIZE200M, group36 ('/data/MESSTB/onlinelog/standby_group_36') SIZE200M, group37 ('/data/MESSTB/onlinelog/standby_group_37') SIZE200M, group38 ('/data/MESSTB/onlinelog/standby_group_38') SIZE200M;
重启开启备库同步进程:
alterdatabaseopenreadonly; alterdatabaserecovermanagedstandbydatabaseusingcurrentlogfiledisconnectfromsession;
检查日志同步情况:
setline222setpagesize1000colmemberfora60selectt2.thread#,t1.group#,t1.member,t2.STATUS,t2.ARCHIVED,t2.bytes/1024/1024fromv$logfilet1,v$standby_logt2wheret1.group#=t2.group#orderby1,2;
selectprocess,group#,thread#,sequence#fromv$managed_standby;
selectdatabase_role,open_modefromv$database;
至此,ADG 已经转换完成!