10g datagurad的一次switchover
10g datagurad的一次switchover
查询主库的状态: SQL>select switchover_status from v$database; SWITCHOVER_STATUS -------------------- SESSIONSACTIVE 更换主库的角色: SQL>alter database commit to switchover to physical standby with session shutdown; Database altered.
这时alter_log有以下信息,说明自动建立了standby log:
standbyredo logfiles that match the primary database: ALTERDATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 52428800; ALTERDATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 52428800; ALTERDATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 52428800; ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 52428800;
备库的switchover_status 的状态从not allowed改成了to primary:
SQL>select switchover_status from v$database; SWITCHOVER_STATUS -------------------- NOTALLOWED SQL>select switchover_status from v$database; SWITCHOVER_STATUS -------------------- TOPRIMARY
将备库改成主库:
SQL>ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN; Database altered. SQL>select switchover_status from v$database; SWITCHOVER_STATUS -------------------- TO STANDBY SQL> select DATABASE_ROLE fromv$database; DATABASE_ROLE ---------------- PRIMARY
测试一下,原来的主库已开始接收Log了。
SQL> alter system switchlogfile; System altered.
新主库的alert_log:
RFS[4]: Identified database type as'physical standby' Thu Aug 1 13:03:47 2013 Primary database is in MAXIMUMPERFORMANCE mode RFS[2]: Successfully opened standbylog 5: '/u01/app/oracle/oradata/orcl/redo05.log'
再做一次switchover,恢复到最初的状态:
在主库执行:
SQL> select switchover_statusfrom v$database; SWITCHOVER_STATUS -------------------- SESSIONS ACTIVE SQL> alter database commit to switchover tophysical standby with session shutdown; Database altered.
在备库执行:
SQL> select switchover_statusfrom v$database; SWITCHOVER_STATUS -------------------- NOT ALLOWED SQL> select switchover_status from v$database; SWITCHOVER_STATUS -------------------- TO PRIMARY SQL> ALTER DATABASE COMMIT TOSWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN; Database altered. SQL> select switchover_statusfrom v$database; SWITCHOVER_STATUS -------------------- TO STANDBY
分别重启主重库后:
SQL> startup mount ORACLE instance started. Total System Global Area 281018368 bytes Fixed Size 1218944 bytes Variable Size 100664960 bytes Database Buffers 171966464 bytes Redo Buffers 7168000 bytes Database mounted. SQL> select PROTECTION_MODE,PROTECTION_LEVEL from v$database; PROTECTION_MODE PROTECTION_LEVEL ---------------------------------------- MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY SQL> recover managed standbydatabase disconnect from session; Media recovery complete.
主库切换一次logfile;
SQL> alter system switch logfile; System altered.
备库的日志:
Thu Aug 1 14:19:44 2013 Primary database is in MAXIMUMAVAILABILITY mode Standby controlfile consistent withprimary RFS[2]: Successfully opened standbylog 5: '/u01/app/oracle/oradata/orcl/redo05.log' Thu Aug 1 14:19:48 2013 Media Recovery Log/u01/app/oracle/oradata/orcl/archivelog/1_72_793805797.dbf Media Recovery Waiting for thread 1sequence 73 (in transit)
成功!