今天做dataguard切换的时候,由于log_archive_dest_2参数在备库上的配置错误,导致从主库切换到备库后(此时备库是主库),从备库(当前切换后的主库)无法传送到原主库(当前切换后的备库)。
原主库db_unique_name:pr_prov
原备库db_unique_name:dr_prov
有pr_prov切换到dr_prov,切换后,在dr_prov上发现日志不会传到pr_prov上。
dr_prov:
在pr_prov上看,日志只能到48
尝试在dr_prov上执行alter system switch logfile ;
也只是dr_prov上日志序号增大一个,pr_prov上不会有任何变化。此时猜测主库上的日志发送进程估计没了。
查询了一下,发下确定没有了LNS进程,该进程在主库上负责启动网络传送归档日志到备库。继续查看alert日志,发现有日志报错。
PING[ARC2]: Heartbeat failed to connect to standby 'dr_prov'. Error is 16047.
Thu Mar 19 10:38:16 2020
db_recovery_file_dest_size of 4977 MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
FAL[server, ARC3]: Error 16047 creating remote archivelog file 'dr_prov'
FAL[server, ARC3]: FAL archive failed, see trace file.
ARCH: FAL archive failed. Archiver continuing
ORACLE Instance prov - Archival Error. Archiver continuing.
发现上面飘红的'dr_prov'很扎眼,因为现在的主库是dr_prov,他的standby应该是pr_prov。所以配置该参数的就是log_archive_dest_2,一查询该参数果然配置错了
alter system set log_archive_dest_2='SERVICE=pr_prov LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=pr_prov' scope=both;
我之前就是上面图片中红框里面的内容写成了dr_prov。
改过之后,lns进程还是不会自己起来,需要手工log_archive_dest_state_2参数改成defer,然后在改成enable即可。
SQL> show parameter archive
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_2 string enable
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CLOSING
ARCH CLOSING
ARCH CONNECTED
ARCH CLOSING
SQL> alter system set log_archive_dest_state_2=defer ;
System altered.
SQL> alter system set log_archive_dest_state_2=enable ;
System altered.
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CLOSING
ARCH CLOSING
ARCH CLOSING
ARCH CLOSING
LNS WRITING
可以看到lns进程已经起来了。查看主库日志传送情况和备库应用情况。
dr_prov
SQL> select name,SEQUENCE#,APPLIED from v$archived_log order by sequence#;
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
/oradata/provarch/1_34_1034939605.dbf 34 YES
/oradata/provarch/1_35_1034939605.dbf 35 YES
/oradata/provarch/1_36_1034939605.dbf 36 YES
/oradata/provarch/1_37_1034939605.dbf 37 YES
/oradata/provarch/1_38_1034939605.dbf 38 YES
/oradata/provarch/1_39_1034939605.dbf 39 YES
/oradata/provarch/1_40_1034939605.dbf 40 YES
/oradata/provarch/1_41_1034939605.dbf 41 YES
/oradata/provarch/1_42_1034939605.dbf 42 YES
/oradata/provarch/1_43_1034939605.dbf 43 YES
/oradata/provarch/1_44_1034939605.dbf 44 YES
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
/oradata/provarch/1_45_1034939605.dbf 45 YES
/oradata/provarch/1_46_1034939605.dbf 46 YES
/oradata/provarch/1_47_1034939605.dbf 47 YES
/oradata/provarch/1_48_1034939605.dbf 48 YES
/oradata/provarch/1_49_1034939605.dbf 49 NO
pr_prov 49 YES
/oradata/provarch/1_50_1034939605.dbf 50 NO
pr_prov 50 YES
/oradata/provarch/1_51_1034939605.dbf 51 NO
pr_prov 51 YES
/oradata/provarch/1_52_1034939605.dbf 52 NO
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
pr_prov 52 YES
/oradata/provarch/1_53_1034939605.dbf 53 NO
pr_prov 53 NO
25 rows selected.
SQL>
pr_prov:
SQL> select name,SEQUENCE#,APPLIED from v$archived_log order by sequence#;
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
/oradata/fast_recovery_area/PROV/archivelog/2020_0 21 YES
3_13/o1_mf_1_21_h6q4jbkp_.arc
/oradata/fast_recovery_area/PROV/archivelog/2020_0 22 YES
3_14/o1_mf_1_22_h6s098gq_.arc
/oradata/fast_recovery_area/PROV/archivelog/2020_0 23 YES
3_15/o1_mf_1_23_h6vk4yz3_.arc
/oradata/fast_recovery_area/PROV/archivelog/2020_0 24 YES
3_16/o1_mf_1_24_h6y1zmz7_.arc
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
/oradata/provarch/1_25_1034939605.dbf 25 YES
/oradata/provarch/1_26_1034939605.dbf 26 YES
/oradata/provarch/1_27_1034939605.dbf 27 YES
/oradata/provarch/1_28_1034939605.dbf 28 YES
/oradata/provarch/1_29_1034939605.dbf 29 YES
/oradata/provarch/1_30_1034939605.dbf 30 YES
/oradata/fast_recovery_area/PROV/archivelog/2020_0 31 YES
3_16/o1_mf_1_31_h6yh53q7_.arc
/oradata/provarch/1_32_1034939605.dbf 32 YES
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
/oradata/provarch/1_33_1034939605.dbf 33 YES
/oradata/provarch/1_34_1034939605.dbf 34 YES
dr_prov 34 YES
dr_prov 35 YES
/oradata/provarch/1_35_1034939605.dbf 35 YES
/oradata/provarch/1_36_1034939605.dbf 36 YES
dr_prov 36 YES
dr_prov 37 YES
/oradata/provarch/1_37_1034939605.dbf 37 YES
/oradata/provarch/1_38_1034939605.dbf 38 YES
dr_prov 38 YES
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
dr_prov 39 YES
/oradata/provarch/1_39_1034939605.dbf 39 YES
dr_prov 40 YES
/oradata/provarch/1_40_1034939605.dbf 40 YES
dr_prov 41 YES
/oradata/provarch/1_41_1034939605.dbf 41 YES
/oradata/provarch/1_42_1034939605.dbf 42 YES
dr_prov 42 YES
dr_prov 43 YES
/oradata/provarch/1_43_1034939605.dbf 43 YES
dr_prov 44 YES
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
/oradata/provarch/1_44_1034939605.dbf 44 YES
dr_prov 45 YES
/oradata/provarch/1_45_1034939605.dbf 45 YES
dr_prov 46 YES
/oradata/provarch/1_46_1034939605.dbf 46 YES
dr_prov 47 YES
/oradata/provarch/1_47_1034939605.dbf 47 YES
/oradata/provarch/1_48_1034939605.dbf 48 YES
dr_prov 48 NO
/oradata/provarch/1_49_1034939605.dbf 49 YES
/oradata/provarch/1_50_1034939605.dbf 50 YES
NAME SEQUENCE# APPLIED
-------------------------------------------------- ---------- ---------
/oradata/provarch/1_51_1034939605.dbf 51 YES
/oradata/provarch/1_52_1034939605.dbf 52 YES
/oradata/provarch/1_53_1034939605.dbf 53 IN-MEMORY
48 rows selected.
在主库上切换日志
SQL> alter system switch logfile ;
System altered.
SQL>
测试数据:
备库: