问题:
搭建一个dataguard烦死了,好不容易搭建完了。在最大保护模式下switchover后,old standby 不能切换为new primary!alert日志中报16072错误!!!最后实例也中断了。
网上找了各种资料,总算是明白是咋回事了! nnd
主备库启动顺序~~~
max performance(最大性能):主库,备库的启动和关闭顺序没有先后
max availability(最大可用):要先启动备库,再启动主库,如果启动顺序相反,主库仍然能启动,但会在主库的alert.log文件中有报错信息。
max protection(最大保护):先启动备库,再启动主库,如果顺序相反,主库实例会自动中断,数据库无法启动,并会在alert.log文件中报错!
分析原因:
1.在备库还没启动ok,我就开始启动主库了。
2.要注意参数文件中log_archived_dest_2中的service配置,最大可用和最大保护下要配置为SYNC AFFIRM,最大可用性可用配置为ASYNC NOAFFIRM
3.old standby 在switchover为new primary前,没有apply完日志。
tips:
最大性能模式下发生failover,需要检查日志是否同步,不一致要做备份过去!
xxxxxxxxxxxxxxxxxxxxxxxx
当failover发生时,old primary已不可用。这时可用通过flashback database功能将old primary修复为standby database。
可用参考
http://docs.oracle.com/cd/E11882_01/server.112/e17022/scenarios.htm#i1049997xxxxxxxxxxxxxxxxxxxxxxxx
最大保护模式:需要即时将主库的online redo log传到备库的standby redo log中,所以需要建立standby redo log后才能使用该模式
最大可用模式:默认情况下,也是传online redo log到standy redo log,但是也可以配置为传archive log file
xxxxxxxxxxxxxxxxxxxxxxxxx
简单测试日志是否同步命令1
From Primary:
SQL> select thread#,max(sequence#) from v$archived_log group by thread#;
From Standby:
SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
xxxxxxxxxxxxxxxxxxxxxxxx
测试日志传输是否同步命令2
On the primary server, check the latest archived redo log and force a log switch. 主库检查最新的archive log并且强制log切换!
ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS'; SELECT sequence#, first_time, next_time FROM v$archived_log ORDER BY sequence#; ALTER SYSTEM SWITCH LOGFILE;
Check the new archived redo log has arrived at the standby server and been applied. 备库检查新的archive log已经到达并且已应用。
ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS'; SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;
xxxxxxxxxxxxxxxxxxxxxxxx
switchover_status状态解说
NOT ALLOWED - Either this is a standby database and the primary database has
not been switched first, or this is a primary database and there are no standby databases.
//备数据库上显示此状态,表明主库没被先切换;主库上显示此状态,表明当前缺少备数据库。
SESSIONS ACTIVE - Indicates that there are active SQL sessions attached to
the primary or standby database that need to be disconnected before the
switchover operation is permitted.
//在进行switchover操作被允许前,主备数据库需要将会话关闭。
SWITCHOVER PENDING - This is a standby database and the primary database
switchover request has been received but not processed.
//接受到switchover请求,但还没处理
SWITCHOVER LATENT - The switchover was in pending mode, but did not complete
and went back to the primary database.
//switchover待定,但还没完成,回到了主库
TO PRIMARY - This is a standby database, with no active sessions, that is
allowed to switch over to a primary database.
//此为备库,无会话,可以转到主库
TO STANDBY - This is a primary database, with no active sessions, that is
allowed to switch over to a standby database.
//此为主库,无会话,可以转到备库。
RECOVERY NEEDED - This is a standby database that has not received the
switchover request.
//备库还没接受到switchover请求,需要finish?
xxxxxxxxxxxxxxxxxxxxxxxx
先将主库切换为备库
查看switchover status,如果是to standby 直接切;如果是session active ,加 with session shutdown选项;如果是not allowed 表示缺少备库,先建好备库;
备库端:
确认是否可以切换为主库,如果switchover_status为recovery needed或switchover latent,需要apply完所有归档日志才能切换。如果是sessions active则带上with session shutdown选项。apply完所有日志后,即可切换为primary,然后打开数据库。
xxxxxxxxxxxxxxxxxxxxxxxx
参考文章:
http://www.oracle-base.com/articles/11g/data-guard-setup-11gr2.php // oracle 11g dataguard configuration guidehttp://space.itpub.net/519536/viewspace-580366 //配置standby redo log 中文
http://www.cnblogs.com/taosim/articles/2506173.html //主备切换
http://guoyanxi.iteye.com/blog/653374
http://space.itpub.net/519536/viewspace-719056 //snapshot standby应用,一个全新的可读写数据库