公司的11g的dataguard主备不同步,检查步骤如下:
Primary:查询主库的最大日志
SQL> select max(sequence#) from v$archived_log;
SQL> select max(sequence#) from v$archived_log where applied=‘YES‘;
standby:查询备库的最大日志
SQL> select max(sequence#) from v$archived_log;
SQL> select max(sequence#) from v$archived_log where applied=‘YES‘;
查询主库日志与备库是否一致
SQL> select sequence# from v$archived_log where recid = (select max(recid) from v$archived_log) and applied = ‘YES‘;
SQL> select sequence# from v$archived_log where recid = (select max(recid) from v$archived_log);
查主备库的日志是否已经一致了
SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
发现2边的日志数不一致。这个不同步的原因就是日志没有传过去,然后去主库那边OS上看,日志还存在,也就是说是传输过程出的问题。
然后查看主库的归档日志的状态:
SQL> select dest_name,status,error from v$archive_dest where rownum<3;
DEST_NAME STATUS ERROR
-------------------- --------- -------------------------------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 ERROR ORA-16191: Primary log shipping client not logged on standby
发现传向备库的状态是error,报错ora-16191 ,官方文档的说明:
ORA-16191: Primary log shipping client not logged on standby
Cause: An attempt to ship redo to standby without logging on to standby or with invalid user credentials.
Action: Check that primary and standby are using password files and that both primary and standby have the same SYS password. Restart primary and/or standby after ensuring that password file is accessible and REMOTE_LOGIN_PASSWORDFILE initialization parameter is set to SHARED or EXCLUSIVE.
最后经检查发现是主备库的sys的密码不一致造成的,把主库的orapw文件copy一份到备库,再修改成备库的名字,就解决了。