在主庫執行
[oracle@mxq ~]$ sqlplus / as sysdba
SQL> select max(SEQUENCE#),applied from v$archived_log group by applied;
MAX(SEQUENCE#) APPLIED
-------------- ---------
87 NOswitchover
89 YES
備庫上面執行
[oracle@mxqdg ~]$ sqlplus / as sysdba
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY TO STANDBY
SQL> select max(SEQUENCE#),applied from v$archived_log group by applied;
MAX(SEQUENCE#) APPLIED
-------------- ---------
89 NO
89 YES
主庫和備庫序列號都是89:YES 說明已經同步完成
在主庫執行
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
Database altered.
SQL> shutdown immediate;
ORA-01092: ORACLE instance terminated. Disconnection forced
SQL> startup mount;
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist
SQL> exit
[oracle@mxqdg ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sat May 16 07:41:05 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 521936896 bytes
Fixed Size 2228072 bytes
Variable Size 159383704 bytes
Database Buffers 352321536 bytes
Redo Buffers 8003584 bytes
Database mounted.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select DATABASE_ROLE,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY MOUNTED
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY NOT ALLOWED
在備庫執行
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
Database altered.
SQL> select DATABASE_ROLE,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY MOUNTED
SQL> alter database open;
Database altered.
SQL> select DATABASE_ROLE,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY TO STANDBY
SQL> select process,pid,status,thread#,sequence# from v$managed_standby;
PROCESS PID STATUS THREAD# SEQUENCE#
--------- ---------- ------------ ---------- ----------
ARCH 3345 CLOSING 1 89
ARCH 3347 CLOSING 1 92
ARCH 3349 CLOSING 1 92
ARCH 3351 CLOSING 1 93
LNS 7786 WRITING 1 94
上面程式已經說明網路是正常
在備庫執行
SQL> select process,pid,status,thread#,sequence# from v$managed_standby;
PROCESS PID STATUS THREAD# SEQUENCE#
--------- ---------- ------------ ---------- ----------
ARCH 6975 CLOSING 1 93
ARCH 6977 CONNECTED 0 0
ARCH 6979 CONNECTED 0 0
ARCH 6981 CLOSING 1 92
MRP0 6984 WAIT_FOR_LOG 1 94
RFS 6999 IDLE 0 0
RFS 6997 IDLE 1 94
RFS 7001 IDLE 0 0
應用程式已經起來兩邊日誌序列號都是94已經正常同步
8 rows selected.
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open read only;
Database altered.
SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.
在主庫執行
SQL> create table mxq(a varchar2(2),b date);
Table created.
SQL> insert into mxq values(1,sysdate);
1 row created.
SQL> commit;
Commit complete.
在備庫執行
SQL> select * from mxq;
A B
-- ------------
1 16-MAY-15
SQL>
--------complete-----------
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29065182/viewspace-1657559/,如需轉載,請註明出處,否則將追究法律責任。