物理DG角色轉換:switchover

OGG-01161發表於2014-04-01
物理DG角色轉換 switchover


1、轉換前準備工作,


a、檢查各初始化引數,檢查和轉換相關的引數是否正確配置


主庫引數
*.standby_file_management='auto'
*.fal_server='liu_sgdb'
*.fal_client='liu_dgdb'
*.LOG_FILE_NAME_CONVERT='/oradata/dgdb/dgdb','/oradata/dgdb/dgdb'
*.DB_FILE_NAME_CONVERT='/oradata/dgdb/dgdb','/oradata/dgdb/dgdb'


備庫引數:
*.standby_file_management='auto'
*.fal_server='liu_dgdb'
*.fal_client='liu_sgdb'
*.LOG_FILE_NAME_CONVERT='/oradata/dgdb/dgdb','/oradata/dgdb/dgdb'
*.DB_FILE_NAME_CONVERT='/oradata/dgdb/dgdb','/oradata/dgdb/dgdb'




注:fal_client引數在11G不需要配置




b、檢查備庫是否開啟歸檔模式


SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/arch
Oldest online log sequence     39
Next log sequence to archive   0
Current log sequence           43
SQL> 
SQL> 


2、檢查主庫是否支援switchover操作


 select switchover_status from v$database;






SQL>  select switchover_status from v$database;


SWITCHOVER_STATUS
--------------------
TO STANDBY


SQL> 






3、主庫啟動switchover




alter database commit to switchover to physical standby;


注:alter database commit to switchover to physical standby with session shutdown; 自動中斷任在聯絡的會話。




SQL> alter database commit to switchover to physical standby;


Database altered.


SQL> 




檢查alert日誌,如下:
oracle@dgdb trace]$ tail -f alert*
Mon Mar 31 12:39:04 2014
alter database commit to switchover to physical standby
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY  [Process Id: 28375] (dgdb)
Mon Mar 31 12:39:05 2014
Thread 1 advanced to log sequence 44 (LGWR switch)
  Current log# 2 seq# 44 mem# 0: /oradata/dgdb/dgdb/redo02.log
Waiting for all non-current ORLs to be archived...
Waiting for the ORL for thread 1 sequence 43 to be archived...
Mon Mar 31 12:39:08 2014
Archived Log entry 69 added for thread 1 sequence 43 ID 0x81b70d1c dest 1:
Mon Mar 31 12:39:15 2014
ORL for thread 1 sequence 43 has been archived...
All non-current ORLs have been archived.
Waiting for all FAL entries to be archived...
All FAL entries have been archived.
Waiting for potential switchover target to become synchronized...
Mon Mar 31 12:39:35 2014
Active, synchronized Physical Standby  switchover target has been identified
Mon Mar 31 12:39:35 2014
Thread 1 advanced to log sequence 45 (LGWR switch)
  Current log# 3 seq# 45 mem# 0: /oradata/dgdb/dgdb/redo03.log
Mon Mar 31 12:39:46 2014
ARCH: Standby redo logfile selected for thread 1 sequence 44 for destination LOG_ARCHIVE_DEST_2
Archived Log entry 70 added for thread 1 sequence 44 ID 0x81b70d1c dest 1:
Mon Mar 31 12:39:46 2014
Stopping background process CJQ0
Mon Mar 31 12:39:46 2014
SMON: disabling tx recovery
Stopping background process QMNC
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Stopping background process SMCO
SMON: disabling cache recovery
Mon Mar 31 12:39:49 2014
Shutting down archive processes
Archiving is disabled
Mon Mar 31 12:39:49 2014
ARCH shutting down
ARC2: Archival stopped
Mon Mar 31 12:39:49 2014
ARCH shutting down
ARC1: Archival stopped
Mon Mar 31 12:39:49 2014
ARCH shutting down
ARC0: Archival stopped
Mon Mar 31 12:39:49 2014
krso_proc_start_arch: Aborting starting ARCH processes, archiving disabled
ARC3: Becoming the 'no FAL' ARCH
ARC3: Becoming the 'no SRL' ARCH
ARC3: Archiving disabled
ARCH shutting down
ARC3: Archival stopped
Thread 1 closed at log sequence 45
Successful close of redo thread 1
ARCH: Noswitch archival of thread 1, sequence 45
ARCH: End-Of-Redo Branch archival of thread 1 sequence 45
Mon Mar 31 12:40:00 2014
Archived Log entry 72 added for thread 1 sequence 45 ID 0x81b70d1c dest 1:
ARCH: Archiving is disabled due to current logfile archival
Primary will check for some target standby to have received all redo
Final check for a synchronized target standby. Check will be made once.
Mon Mar 31 12:40:10 2014
LOG_ARCHIVE_DEST_2 is a potential Physical Standby  switchover target
Active, synchronized target has been identified
Target has also applied all redo
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/dgdb_pd/dgdb/trace/dgdb_ora_28375.trc
Clearing standby activation ID 2176257308 (0x81b70d1c)
The primary database controlfile was created using the
'MAXLOGFILES 16' clause.
There is space for up to 13 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 52428800;
Archivelog for thread 1 sequence 45 required for standby recovery
Switchover: Primary controlfile converted to standby controlfile succesfully.
Mon Mar 31 12:40:10 2014
MRP0 started with pid=18, OS id=28516 
MRP0: Background Managed Standby Recovery process started (dgdb)
Serial Media Recovery started
Managed Standby Recovery not using Real Time Apply
Online logfile pre-clearing operation disabled by switchover
Media Recovery Log /u01/app/oracle/arch/1_45_830232990.dbf
Identified End-Of-Redo for thread 1 sequence 45
Resetting standby activation ID 0 (0x0)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Applied until change 1121117
MRP0: Media Recovery Complete: End-Of-REDO (dgdb)
MRP0: Background Media Recovery process shutdown (dgdb)
Mon Mar 31 12:40:16 2014
idle dispatcher 'D000' terminated, pid = (17, 1)
Switchover: Complete - Database shutdown required (dgdb)
Completed: alter database commit to switchover to physical standby




4、主庫啟動到mount狀態


shutdown immediate;
startup mount;






SQL> select status from v$Instance;


STATUS
------------
STARTED


SQL> shutdown immediate;
ORA-01507: database not mounted




ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.


Total System Global Area  409194496 bytes
Fixed Size                  2213856 bytes
Variable Size             297797664 bytes
Database Buffers          104857600 bytes
Redo Buffers                4325376 bytes
Database mounted.
SQL> 




5、原備庫switchover操作




a、檢查備庫是否支援角色轉換


  select switchover_status from v$database;




SQL>  select switchover_status from v$database;


SWITCHOVER_STATUS
--------------------
TO PRIMARY


SQL> 




b、檢查備庫歸檔模式






c、執行轉換操作




alter database commit to switchover to primary;




SQL>  select switchover_status from v$database;


SWITCHOVER_STATUS
--------------------
NOT ALLOWED


SQL>  select switchover_status from v$database;


SWITCHOVER_STATUS
--------------------
TO PRIMARY


SQL> alter database commit to switchover to primary;


Database altered.






d、開啟資料庫




alter database open;






SQL> select status from v$instance;


STATUS
------------
MOUNTED


SQL> alter database open;


Database altered.


SQL> select stauts from v$instance;
select stauts from v$instance
       *
ERROR at line 1:
ORA-00904: "STAUTS": invalid identifier




SQL> select status from v$instance;


STATUS
------------
OPEN


SQL> 




e、檢查alter日誌




[oracle@sgdb trace]$ tail -f alert*
Media Recovery Log /u01/app/oracle/arch/1_45_830232990.dbf
Identified End-Of-Redo for thread 1 sequence 45
Resetting standby activation ID 2176257308 (0x81b70d1c)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Applied until change 1121117
MRP0: Media Recovery Complete: End-Of-REDO (dgdb)
MRP0: Background Media Recovery process shutdown (dgdb)
Mon Mar 31 10:03:13 2014
RFS[9]: Assigned to RFS process 29694
RFS[9]: Identified database type as 'physical standby': Client is Foreground pid 28375
Mon Mar 31 10:14:25 2014
alter database commit to switchover to primary
ALTER DATABASE SWITCHOVER TO PRIMARY (dgdb)
Maximum wait for role transition is 15 minutes.
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Mon Mar 31 10:14:25 2014
SMON: disabling cache recovery
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/sgdb_st/dgdb/trace/dgdb_ora_29449.trc
SwitchOver after complete recovery through change 1121117
Online log /oradata/dgdb/dgdb/redo01.log: Thread 1 Group 1 was previously cleared
Online log /oradata/dgdb/dgdb/redo02.log: Thread 1 Group 2 was previously cleared
Online log /oradata/dgdb/dgdb/redo03.log: Thread 1 Group 3 was previously cleared
Standby became primary SCN: 1121115
Switchover: Complete - Database mounted as primary
Completed: alter database commit to switchover to primary
Mon Mar 31 10:14:26 2014
ARC3: Becoming the 'no SRL' ARCH
Mon Mar 31 10:15:25 2014
idle dispatcher 'D000' terminated, pid = (17, 1)
Mon Mar 31 10:19:14 2014
ARC0: Becoming the 'no SRL' ARCH
Mon Mar 31 10:19:18 2014
ARC1: Becoming the 'no SRL' ARCH
Mon Mar 31 10:24:05 2014
alter database open
Mon Mar 31 10:24:05 2014
Assigning activation ID 2189582394 (0x8282603a)
Thread 1 advanced to log sequence 47 (thread open)
Thread 1 opened at log sequence 47
  Current log# 2 seq# 47 mem# 0: /oradata/dgdb/dgdb/redo02.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Mon Mar 31 10:24:05 2014
SMON: enabling cache recovery
Mon Mar 31 10:24:06 2014
Archived Log entry 35 added for thread 1 sequence 46 ID 0x8282603a dest 1:
Mon Mar 31 10:24:06 2014
NSA2 started with pid=21, OS id=29775 
Successfully onlined Undo Tablespace 2.
Dictionary check beginning
Dictionary check complete
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Starting background process SMCO
Mon Mar 31 10:24:06 2014
SMCO started with pid=25, OS id=29777 
Database Characterset is ZHS16GBK
No Resource Manager plan active
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
Thread 1 advanced to log sequence 48 (LGWR switch)
  Current log# 3 seq# 48 mem# 0: /oradata/dgdb/dgdb/redo03.log
Mon Mar 31 10:24:09 2014
Archived Log entry 36 added for thread 1 sequence 47 ID 0x8282603a dest 1:
Starting background process QMNC
Mon Mar 31 10:24:14 2014
QMNC started with pid=27, OS id=29781 
LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete
Completed: alter database open
ARC1: STARTING ARCH PROCESSES
Mon Mar 31 10:24:19 2014
ARC4 started with pid=28, OS id=29783 
Mon Mar 31 10:24:20 2014
ARC4: Archival started
ARC1: STARTING ARCH PROCESSES COMPLETE
Mon Mar 31 10:24:32 2014
ARC0: Standby redo logfile selected for thread 1 sequence 46 for destination LOG_ARCHIVE_DEST_2
Mon Mar 31 10:24:36 2014
LNS: Standby redo logfile selected for thread 1 sequence 47 for destination LOG_ARCHIVE_DEST_2
LNS: Standby redo logfile selected for thread 1 sequence 48 for destination LOG_ARCHIVE_DEST_2
Mon Mar 31 10:25:47 2014
Shutting down archive processes
Mon Mar 31 10:25:47 2014
ARCH shutting down
ARC4: Archival stopped






6、測試新的主庫和備庫同步情況


 新的主庫插入一條記錄


SQL> select status from v$instance;


STATUS
------------
OPEN


SQL> select * from test5;


        ID STUDENT
---------- --------------------
       111 dfadfff
       222 liubinzhouxiuli


SQL> insert into test5 values(333,'zhouxiuliliubin');


1 row created.


SQL> commit;


Commit complete.


SQL> alter system switch logfile;


System altered.


SQL> 
SQL> 




新的備庫同步情況


SQL> select * from test5;


        ID STUDENT
---------- --------------------
       111 dfadfff
       222 liubinzhouxiuli


SQL> select * from test5;


        ID STUDENT
---------- --------------------
       111 dfadfff
       222 liubinzhouxiuli


SQL> alter database recover managed standby database using current logfile disconnect from session;


Database altered.


SQL> select * from test5;


        ID STUDENT
---------- --------------------
       111 dfadfff
       222 liubinzhouxiuli


SQL> /


        ID STUDENT
---------- --------------------
       111 dfadfff
       222 liubinzhouxiuli


SQL> /


        ID STUDENT
---------- --------------------
       111 dfadfff
       222 liubinzhouxiuli


SQL> select * from test5;


        ID STUDENT
---------- --------------------
       111 dfadfff
       222 liubinzhouxiuli
       333 zhouxiuliliubin


SQL> 


資料同步成功!!!!!!!!!!










來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27571661/viewspace-1133808/,如需轉載,請註明出處,否則將追究法律責任。

相關文章