当前环境:
A: 当前是Primary ,Oracle 11.2.0.3,本次切换后为Physical Standby
B: 当前是Physical Standby,本次切换后为Cascade Standby(因为这个库是11.2.0.4,版本不一致,因此只能做standby,不能open)
C:当前是Cascade Standby,Oracle 11.2.0.3,本次切换后为Primary
============================================================================================================
1,级联环境下,如果到Cascade的路径是enable,则在做switchover时,主库上查询会报:“RESOLVABLE GAP”
解决方法是将主库到cascade的归档路径设置为defer ;
============================================================================================================
21:17:04 SYS@lunarp>SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
RESOLVABLE GAP
Elapsed: 00:00:00.02
21:17:30 SYS@lunarp>show parameter log
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_syslog_level string
commit_logging string
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
enable_ddl_logging boolean FALSE
log_archive_config string DG_CONFIG=(lunarp,lunars,lunar
c)
log_archive_dest string
log_archive_dest_1 string LOCATION=USE_DB_RECOVERY_FILE_
DEST VALID_FOR=(ALL_LOGFILES,A
LL_ROLES) DB_UNIQUE_NAME=lunar
p
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string
log_archive_dest_16 string
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
log_archive_dest_2 string SERVICE=lunars LGWR SYNC AFFIR
M VALID_FOR=(ONLINE_LOGFILES,P
RIMARY_ROLE) DB_UNIQUE_NAME=lu
nars
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
log_archive_dest_28 string
log_archive_dest_29 string
log_archive_dest_3 string SERVICE=lunarc LGWR SYNC AFFIR
M VALID_FOR=(STANDBY_LOGFILES,
STANDBY_ROLE) DB_UNIQUE_NAME=l
unarc
log_archive_dest_30 string
log_archive_dest_31 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string ENABLE
log_archive_dest_state_10 string enable
log_archive_dest_state_11 string enable
log_archive_dest_state_12 string enable
log_archive_dest_state_13 string enable
log_archive_dest_state_14 string enable
log_archive_dest_state_15 string enable
log_archive_dest_state_16 string enable
log_archive_dest_state_17 string enable
log_archive_dest_state_18 string enable
log_archive_dest_state_19 string enable
log_archive_dest_state_2 string ENABLE
log_archive_dest_state_20 string enable
log_archive_dest_state_21 string enable
log_archive_dest_state_22 string enable
log_archive_dest_state_23 string enable
log_archive_dest_state_24 string enable
log_archive_dest_state_25 string enable
log_archive_dest_state_26 string enable
log_archive_dest_state_27 string enable
log_archive_dest_state_28 string enable
log_archive_dest_state_29 string enable
log_archive_dest_state_3 string ENABLE
log_archive_dest_state_30 string enable
log_archive_dest_state_31 string enable
log_archive_dest_state_4 string enable
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable
log_archive_dest_state_9 string enable
log_archive_duplex_dest string
log_archive_format string %t_%s_%r.dbf
log_archive_local_first boolean TRUE
log_archive_max_processes integer 4
log_archive_min_succeed_dest integer 1
log_archive_start boolean FALSE
log_archive_trace integer 0
log_buffer integer 7200768
log_checkpoint_interval integer 0
log_checkpoint_timeout integer 1800
log_checkpoints_to_alert boolean FALSE
log_file_name_convert string +DATA/lunars/, /stage/lunar/
remote_login_passwordfile string EXCLUSIVE
sec_case_sensitive_logon boolean TRUE
sec_max_failed_login_attempts integer 10
21:20:24 SYS@lunarp>alter system set log_archive_dest_state_3=defer;
System altered.
Elapsed: 00:00:00.07
21:20:53 SYS@lunarp>SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS OPEN_MODE
--------- ------------------------------ ---------------- -------------------- -------------------- --------------------
LUNAR lunarp PRIMARY MAXIMUM PERFORMANCE TO STANDBY READ WRITE
Elapsed: 00:00:00.03
21:21:16 SYS@lunarp>
============================================================================================================
2,如果主库到备库的归档路径(A到B的)是defer,那么switchover时,检查主库状态会是“NOT ALLOWED”:
解决方法是: 将A到B的路径设置为enable
============================================================================================================
21:41:50 SYS@lunarp>SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS OPEN_MODE
--------- ------------------------------ ---------------- -------------------- -------------------- --------------------
LUNAR lunarp PRIMARY MAXIMUM PERFORMANCE NOT ALLOWED READ WRITE
Elapsed: 00:00:00.02
21:41:52 SYS@lunarp>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 34
Next log sequence to archive 36
Current log sequence 36
21:42:29 SYS@lunarp>show parameter log
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_syslog_level string
commit_logging string
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
enable_ddl_logging boolean FALSE
log_archive_config string DG_CONFIG=(lunarp,lunars,lunar
c)
log_archive_dest string
log_archive_dest_1 string LOCATION=USE_DB_RECOVERY_FILE_
DEST VALID_FOR=(ALL_LOGFILES,A
LL_ROLES) DB_UNIQUE_NAME=lunar
p
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string
log_archive_dest_16 string
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
log_archive_dest_2 string SERVICE=lunars LGWR ASYNC AFFI
RM VALID_FOR=(ONLINE_LOGFILES,
PRIMARY_ROLE) DB_UNIQUE_NAME=l
unars
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
log_archive_dest_28 string
log_archive_dest_29 string
log_archive_dest_3 string SERVICE=lunarc LGWR ASYNC AFFI
RM VALID_FOR=(STANDBY_LOGFILES
,STANDBY_ROLE) DB_UNIQUE_NAME=
lunarc
log_archive_dest_30 string
log_archive_dest_31 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string ENABLE
log_archive_dest_state_10 string enable
log_archive_dest_state_11 string enable
log_archive_dest_state_12 string enable
log_archive_dest_state_13 string enable
log_archive_dest_state_14 string enable
log_archive_dest_state_15 string enable
log_archive_dest_state_16 string enable
log_archive_dest_state_17 string enable
log_archive_dest_state_18 string enable
log_archive_dest_state_19 string enable
log_archive_dest_state_2 string DEFER
log_archive_dest_state_20 string enable
log_archive_dest_state_21 string enable
log_archive_dest_state_22 string enable
log_archive_dest_state_23 string enable
log_archive_dest_state_24 string enable
log_archive_dest_state_25 string enable
log_archive_dest_state_26 string enable
log_archive_dest_state_27 string enable
log_archive_dest_state_28 string enable
log_archive_dest_state_29 string enable
log_archive_dest_state_3 string DEFER
log_archive_dest_state_30 string enable
log_archive_dest_state_31 string enable
log_archive_dest_state_4 string enable
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable
log_archive_dest_state_9 string enable
log_archive_duplex_dest string
log_archive_format string %t_%s_%r.dbf
log_archive_local_first boolean TRUE
log_archive_max_processes integer 4
log_archive_min_succeed_dest integer 1
log_archive_start boolean FALSE
log_archive_trace integer 0
log_buffer integer 7200768
log_checkpoint_interval integer 0
log_checkpoint_timeout integer 1800
log_checkpoints_to_alert boolean FALSE
log_file_name_convert string +DATA/lunars/, /stage/lunar/
remote_login_passwordfile string EXCLUSIVE
sec_case_sensitive_logon boolean TRUE
sec_max_failed_login_attempts integer 10
21:42:34 SYS@lunarp>
21:42:57 SYS@lunarp>alter system set log_archive_dest_state_2=enable;
System altered.
Elapsed: 00:00:00.10
21:43:08 SYS@lunarp>SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS OPEN_MODE
--------- ------------------------------ ---------------- -------------------- -------------------- --------------------
LUNAR lunarp PRIMARY MAXIMUM PERFORMANCE TO STANDBY READ WRITE
Elapsed: 00:00:00.02
21:43:14 SYS@lunarp>
============================================================================================================
将A库切换为Standby:
============================================================================================================
21:43:14 SYS@lunarp>ALTER SYSTEM SWITCH LOGFILE;
System altered.
Elapsed: 00:00:00.10
21:47:55 SYS@lunarp>select max(sequence#),thread# from v$archived_log group by thread#;
MAX(SEQUENCE#) THREAD#
-------------- ----------
37 1
Elapsed: 00:00:00.07
21:48:07 SYS@lunarp>alter database commit to switchover to physical standby WITH SESSION SHUTDOWN;
Database altered.
Elapsed: 00:00:05.62
21:50:59 SYS@lunarp>shutdown immediate;
ORA-01092: ORACLE instance terminated. Disconnection forced
21:51:43 SYS@lunarp>
21:51:55 SYS@lunarp>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning and Real Application Testing options
[oracle@lunar ~]$ ss
SQL*Plus: Release 11.2.0.3.0 Production on Sat Aug 2 21:52:09 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Welcome Lunar's oracle world!
Connected to an idle instance.
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
Elapsed: 00:00:00.01
21:52:10 SYS@lunarp>startup mount
Welcome Lunar's oracle world!
Love you , baby !
ORACLE instance started.
Total System Global Area 626327552 bytes
Fixed Size 2230952 bytes
Variable Size 184550744 bytes
Database Buffers 432013312 bytes
Redo Buffers 7532544 bytes
Database mounted.
Welcome Lunar's oracle world!
Love you , baby !
21:52:27 SYS@lunarp>SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
RECOVERY NEEDED
Elapsed: 00:00:00.11
21:52:31 SYS@lunarp>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
Elapsed: 00:00:06.08
21:52:55 SYS@lunarp>select DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL from v$database;
DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL
---------------- -------------------- --------------------
PHYSICAL STANDBY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
Elapsed: 00:00:00.03
21:53:07 SYS@lunarp>
============================================================================================================
3,同理,Cascade不能切换为Primary,也需要enable C库到A库的归档路径:
============================================================================================================
21:50:41 SYS@lunarc>SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
NOT ALLOWED
Elapsed: 00:00:00.07
21:54:21 SYS@lunarc>show parameter log
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_syslog_level string
commit_logging string
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
enable_ddl_logging boolean FALSE
log_archive_config string DG_CONFIG=(lunarp,lunars,lunar
c)
log_archive_dest string
log_archive_dest_1 string LOCATION=USE_DB_RECOVERY_FILE_
DEST VALID_FOR=(ALL_LOGFILES,A
LL_ROLES) DB_UNIQUE_NAME=lunar
c
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string
log_archive_dest_16 string
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
log_archive_dest_2 string SERVICE=lunarp LGWR ASYNC AFFI
RM VALID_FOR=(ONLINE_LOGFILES,
PRIMARY_ROLE) DB_UNIQUE_NAME=l
unarp
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
log_archive_dest_28 string
log_archive_dest_29 string
log_archive_dest_3 string SERVICE=lunars LGWR ASYNC AFFI
RM VALID_FOR=(STANDBY_LOGFILES
,STANDBY_ROLE) DB_UNIQUE_NAME=
lunars
log_archive_dest_30 string
log_archive_dest_31 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string ENABLE
log_archive_dest_state_10 string enable
log_archive_dest_state_11 string enable
log_archive_dest_state_12 string enable
log_archive_dest_state_13 string enable
log_archive_dest_state_14 string enable
log_archive_dest_state_15 string enable
log_archive_dest_state_16 string enable
log_archive_dest_state_17 string enable
log_archive_dest_state_18 string enable
log_archive_dest_state_19 string enable
log_archive_dest_state_2 string DEFER
log_archive_dest_state_20 string enable
log_archive_dest_state_21 string enable
log_archive_dest_state_22 string enable
log_archive_dest_state_23 string enable
log_archive_dest_state_24 string enable
log_archive_dest_state_25 string enable
log_archive_dest_state_26 string enable
log_archive_dest_state_27 string enable
log_archive_dest_state_28 string enable
log_archive_dest_state_29 string enable
log_archive_dest_state_3 string DEFER
log_archive_dest_state_30 string enable
log_archive_dest_state_31 string enable
log_archive_dest_state_4 string enable
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable
log_archive_dest_state_9 string enable
log_archive_duplex_dest string
log_archive_format string %t_%s_%r.dbf
log_archive_local_first boolean TRUE
log_archive_max_processes integer 4
log_archive_min_succeed_dest integer 1
log_archive_start boolean FALSE
log_archive_trace integer 0
log_buffer integer 7200768
log_checkpoint_interval integer 0
log_checkpoint_timeout integer 1800
log_checkpoints_to_alert boolean FALSE
log_file_name_convert string /stage/lunar/, /tempdisk/lunar
c/
remote_login_passwordfile string EXCLUSIVE
sec_case_sensitive_logon boolean TRUE
sec_max_failed_login_attempts integer 10
21:58:35 SYS@lunarc>alter system set log_archive_dest_state_2=enable;
System altered.
Elapsed: 00:00:00.01
22:00:00 SYS@lunarc>
============================================================================================================
4,还需要B库到C库的归档路径:
============================================================================================================
22:16:17 SYS@lunarc>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 34
Next log sequence to archive 0
Current log sequence 35
22:16:34 SYS@lunarc>show parameter log
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_syslog_level string
commit_logging string
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
enable_ddl_logging boolean FALSE
log_archive_config string DG_CONFIG=(lunarp,lunars,lunar
c)
log_archive_dest string
log_archive_dest_1 string LOCATION=USE_DB_RECOVERY_FILE_
DEST VALID_FOR=(ALL_LOGFILES,A
LL_ROLES) DB_UNIQUE_NAME=lunar
c
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string
log_archive_dest_16 string
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
log_archive_dest_2 string SERVICE=lunarp LGWR ASYNC AFFI
RM VALID_FOR=(ONLINE_LOGFILES,
PRIMARY_ROLE) DB_UNIQUE_NAME=l
unarp
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
log_archive_dest_28 string
log_archive_dest_29 string
log_archive_dest_3 string SERVICE=lunars LGWR ASYNC AFFI
RM VALID_FOR=(STANDBY_LOGFILES
,STANDBY_ROLE) DB_UNIQUE_NAME=
lunars
log_archive_dest_30 string
log_archive_dest_31 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string ENABLE
log_archive_dest_state_10 string enable
log_archive_dest_state_11 string enable
log_archive_dest_state_12 string enable
log_archive_dest_state_13 string enable
log_archive_dest_state_14 string enable
log_archive_dest_state_15 string enable
log_archive_dest_state_16 string enable
log_archive_dest_state_17 string enable
log_archive_dest_state_18 string enable
log_archive_dest_state_19 string enable
log_archive_dest_state_2 string ENABLE
log_archive_dest_state_20 string enable
log_archive_dest_state_21 string enable
log_archive_dest_state_22 string enable
log_archive_dest_state_23 string enable
log_archive_dest_state_24 string enable
log_archive_dest_state_25 string enable
log_archive_dest_state_26 string enable
log_archive_dest_state_27 string enable
log_archive_dest_state_28 string enable
log_archive_dest_state_29 string enable
log_archive_dest_state_3 string DEFER
log_archive_dest_state_30 string enable
log_archive_dest_state_31 string enable
log_archive_dest_state_4 string enable
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable
log_archive_dest_state_9 string enable
log_archive_duplex_dest string
log_archive_format string %t_%s_%r.dbf
log_archive_local_first boolean TRUE
log_archive_max_processes integer 4
log_archive_min_succeed_dest integer 1
log_archive_start boolean FALSE
log_archive_trace integer 0
log_buffer integer 7200768
log_checkpoint_interval integer 0
log_checkpoint_timeout integer 1800
log_checkpoints_to_alert boolean FALSE
log_file_name_convert string /stage/lunar/, /tempdisk/lunar
c/
remote_login_passwordfile string EXCLUSIVE
sec_case_sensitive_logon boolean TRUE
sec_max_failed_login_attempts integer 10
22:16:39 SYS@lunarc>show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string lunarc
fal_server string lunars, lunarp
22:17:06 SYS@lunarc>SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS OPEN_MODE
--------- ------------------------------ ---------------- -------------------- -------------------- --------------------
LUNAR lunarc PHYSICAL STANDBY MAXIMUM PERFORMANCE TO PRIMARY MOUNTED
Elapsed: 00:00:00.01
22:20:57 SYS@lunarc>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 35
Next log sequence to archive 0
Current log sequence 39
22:21:10 SYS@lunarc>
============================================================================================================
将C切换为primary:
============================================================================================================
检查C库:
22:24:47 SYS@lunarc> SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS OPEN_MODE
--------- ------------------------------ ---------------- -------------------- -------------------- --------------------
LUNAR lunarc PHYSICAL STANDBY MAXIMUM PERFORMANCE TO PRIMARY MOUNTED
Elapsed: 00:00:00.04
22:26:26 SYS@lunarc>22:26:26 SYS@lunarc>select max(sequence#),thread# from v$archived_log group by thread#;
MAX(SEQUENCE#) THREAD#
-------------- ----------
39 1
Elapsed: 00:00:00.02
22:26:30 SYS@lunarc>
============================================================================================================
检查A库(已经切换为Standby了):
============================================================================================================
21:52:55 SYS@lunarp>select DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL from v$database;
DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL
---------------- -------------------- --------------------
PHYSICAL STANDBY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
Elapsed: 00:00:00.03
21:53:07 SYS@lunarp>select max(sequence#),thread# from v$archived_log group by thread#;
MAX(SEQUENCE#) THREAD#
-------------- ----------
39 1
Elapsed: 00:00:00.04
22:15:18 SYS@lunarp>
============================================================================================================
检查B库(即将被切换为Cascade):
============================================================================================================
SQL> select max(sequence#),thread# from v$archived_log group by thread#;
MAX(SEQUENCE#) THREAD#
-------------- ----------
39 1
SQL> SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE
--------- ------------------------------ ---------------- --------------------
SWITCHOVER_STATUS OPEN_MODE
-------------------- --------------------
LUNAR lunars PHYSICAL STANDBY MAXIMUM PERFORMANCE
NOT ALLOWED MOUNTED
SQL> SQL>
============================================================================================================
切换C为primary:
============================================================================================================
22:26:30 SYS@lunarc>alter database recover managed standby database finish;
Database altered.
Elapsed: 00:00:03.19
22:27:58 SYS@lunarc>select max(sequence#),thread# from v$archived_log group by thread#;
MAX(SEQUENCE#) THREAD#
-------------- ----------
39 1
Elapsed: 00:00:00.01
22:28:16 SYS@lunarc>SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS OPEN_MODE
--------- ------------------------------ ---------------- -------------------- -------------------- --------------------
LUNAR lunarc PHYSICAL STANDBY MAXIMUM PERFORMANCE TO PRIMARY MOUNTED
Elapsed: 00:00:00.01
22:28:34 SYS@lunarc>22:28:34 SYS@lunarc>ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
Database altered.
Elapsed: 00:00:02.75
22:28:52 SYS@lunarc>22:28:52 SYS@lunarc>
测试C库的alert:
Sat Aug 02 22:27:55 2014
alter database recover managed standby database finish
Terminal Recovery: Stopping real time apply
Sat Aug 02 22:27:55 2014
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /u01/app/oracle/diag/rdbms/lunarc/lunarc/trace/lunarc_pr00_19297.trc:
ORA-16037: user requested cancel of managed recovery operation
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Sat Aug 02 22:27:55 2014
MRP0: Background Media Recovery process shutdown (lunarc)
Terminal Recovery: Stopped real time apply
Attempt to do a Terminal Recovery (lunarc)
Media Recovery Start: Managed Standby Recovery (lunarc)
started logmerger process
Sat Aug 02 22:27:56 2014
Managed Standby Recovery not using Real Time Apply
Parallel Media Recovery started with 2 slaves
Media Recovery Waiting for thread 1 sequence 40
RECOVER FINISH applied through switchover EOR logs and stopped.
Media Recovery Complete: End-Of-REDO (lunarc)
Attempt to set limbo arscn 0:1362521 irscn 0:1362521
Completed: alter database recover managed standby database finish
Sat Aug 02 22:28:49 2014
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN
ALTER DATABASE SWITCHOVER TO PRIMARY (lunarc)
Maximum wait for role transition is 15 minutes.
krsv_proc_kill: Killing 4 processes (all RFS)
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/lunarc/lunarc/trace/lunarc_ora_18445.trc
SwitchOver after complete recovery through change 1362521
Online log /tempdisk/lunarc/redo01.log: Thread 1 Group 1 was previously cleared
Online log /tempdisk/lunarc/redo02.log: Thread 1 Group 2 was previously cleared
Online log /tempdisk/lunarc/redo03.log: Thread 1 Group 3 was previously cleared
Standby became primary SCN: 1362519
Switchover: Complete - Database mounted as primary
Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN
Sat Aug 02 22:29:12 2014
RFS[10]: Assigned to RFS process 19349
RFS[10]: Database mount ID mismatch [0x92fd5f55:0x92fca1ab] (2466078549:2466029995)
RFS[10]: Client instance is standby database instead of primary
RFS[10]: Not using real application clusters
Sat Aug 02 22:29:41 2014
ARC0: Becoming the 'no SRL' ARCH
然后,重启C库:
22:28:52 SYS@lunarc>22:28:52 SYS@lunarc>shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
22:30:35 SYS@lunarc>startup
Welcome Lunar's oracle world!
Love you , baby !
ORACLE instance started.
Total System Global Area 626327552 bytes
Fixed Size 2230952 bytes
Variable Size 184550744 bytes
Database Buffers 432013312 bytes
Redo Buffers 7532544 bytes
Database mounted.
Welcome Lunar's oracle world!
Love you , baby !
Database opened.
此时,C库的日志:
Sat Aug 02 22:30:37 2014
Starting ORACLE instance (normal)
****************** Large Pages Information *****************
Total Shared Global Region in Large Pages = 0 KB (0%)
Large Pages used by this instance: 0 (0 KB)
Large Pages unused system wide = 0 (0 KB) (alloc incr 4096 KB)
Large Pages configured system wide = 0 (0 KB)
Large Page size = 2048 KB
RECOMMENDATION:
Total Shared Global Region size is 602 MB. For optimal performance,
prior to the next instance restart increase the number
of unused Large Pages by atleast 301 2048 KB Large Pages (602 MB)
system wide to get 100% of the Shared
Global Region allocated with Large pages
***********************************************************
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Picked latch-free SCN scheme 3
Autotune of undo retention is turned on.
IMODE=BR
ILAT =27
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning and Real Application Testing options.
ORACLE_HOME = /u01/app/oracle/product/11.2.0.3/dbhome_1
System name: Linux
Node name: lunar
Release: 2.6.32-300.10.1.el5uek
Version: #1 SMP Wed Feb 22 17:37:40 EST 2012
Machine: x86_64
Using parameter settings in server-side spfile /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/spfilelunarc.ora
System parameters with non-default values:
processes = 150
filesystemio_options = "setall"
sga_target = 600M
control_files = "/tempdisk/lunarc/control01.ctl"
control_files = "/tempdisk/lunarc/control02.ctl"
db_file_name_convert = "/stage/lunar/"
db_file_name_convert = "/tempdisk/lunarc/"
log_file_name_convert = "/stage/lunar/"
log_file_name_convert = "/tempdisk/lunarc/"
db_block_size = 8192
compatible = "11.2.0.3.0"
log_archive_dest_1 = "LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lunarc"
log_archive_dest_2 = "SERVICE=lunarp LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lunarp"
log_archive_dest_state_1 = "ENABLE"
log_archive_dest_state_2 = "ENABLE"
log_archive_dest_state_3 = "ENABLE"
fal_client = "lunarc"
fal_server = "lunars"
fal_server = "lunarp"
log_archive_config = "DG_CONFIG=(lunarp,lunars,lunarc)"
db_recovery_file_dest = "/stage/fast_recovery_area"
db_recovery_file_dest_size= 1190198K
standby_file_management = "auto"
undo_tablespace = "UNDOTBS1"
remote_login_passwordfile= "EXCLUSIVE"
db_domain = ""
service_names = "lunar"
audit_file_dest = "/u01/app/oracle/admin/lunarc/adump"
audit_trail = "NONE"
db_name = "lunar"
db_unique_name = "lunarc"
open_cursors = 300
pga_aggregate_target = 146M
deferred_segment_creation= FALSE
sec_return_server_release_banner= FALSE
diagnostic_dest = "/u01/app/oracle"
Sat Aug 02 22:30:38 2014
PMON started with pid=2, OS id=19357
Sat Aug 02 22:30:38 2014
PSP0 started with pid=3, OS id=19359
Sat Aug 02 22:30:39 2014
VKTM started with pid=4, OS id=19361 at elevated priority
VKTM running at (1)millisec precision with DBRM quantum (100)ms
Sat Aug 02 22:30:40 2014
GEN0 started with pid=5, OS id=19365
Sat Aug 02 22:30:40 2014
DIAG started with pid=6, OS id=19367
Sat Aug 02 22:30:40 2014
DBRM started with pid=7, OS id=19369
Sat Aug 02 22:30:40 2014
DIA0 started with pid=8, OS id=19371
Sat Aug 02 22:30:40 2014
MMAN started with pid=9, OS id=19373
Sat Aug 02 22:30:40 2014
DBW0 started with pid=10, OS id=19375
Sat Aug 02 22:30:40 2014
LGWR started with pid=11, OS id=19377
Sat Aug 02 22:30:40 2014
CKPT started with pid=12, OS id=19379
Sat Aug 02 22:30:40 2014
SMON started with pid=13, OS id=19381
Sat Aug 02 22:30:40 2014
RECO started with pid=14, OS id=19383
Sat Aug 02 22:30:40 2014
MMON started with pid=15, OS id=19385
Sat Aug 02 22:30:40 2014
MMNL started with pid=16, OS id=19387
ORACLE_BASE from environment = /u01/app/oracle
Sat Aug 02 22:30:40 2014
ALTER DATABASE MOUNT
Sat Aug 02 22:30:45 2014
NSS2 started with pid=18, OS id=19394
Successful mount of redo thread 1, with mount id 2466039952
Database mounted in Exclusive Mode
Lost write protection disabled
Completed: ALTER DATABASE MOUNT
Sat Aug 02 22:30:45 2014
ALTER DATABASE OPEN
Assigning activation ID 2466039952 (0x92fcc890)
LGWR: STARTING ARCH PROCESSES
Sat Aug 02 22:30:46 2014
ARC0 started with pid=21, OS id=19401
ARC0: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES
Destination LOG_ARCHIVE_DEST_2 is UNSYNCHRONIZED
Sat Aug 02 22:30:47 2014
ARC1 started with pid=19, OS id=19403
Sat Aug 02 22:30:47 2014
ARC2 started with pid=20, OS id=19405
Thread 1 advanced to log sequence 41 (thread open)
Sat Aug 02 22:30:47 2014
ARC3 started with pid=22, OS id=19407
ARC1: Archival started
ARC2: Archival started
ARC2: Becoming the 'no FAL' ARCH
ARC2: Becoming the 'no SRL' ARCH
ARC1: Becoming the heartbeat ARCH
Thread 1 opened at log sequence 41
Current log# 2 seq# 41 mem# 0: /tempdisk/lunarc/redo02.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
SMON: enabling cache recovery
Archived Log entry 33 added for thread 1 sequence 40 ID 0x92fcc890 dest 1:
ARC3: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
Sat Aug 02 22:30:50 2014
Destination LOG_ARCHIVE_DEST_2 is SYNCHRONIZED
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
Destination LOG_ARCHIVE_DEST_2 no longer supports SYNCHRONIZATION
Thread 1 advanced to log sequence 42 (LGWR switch)
Current log# 3 seq# 42 mem# 0: /tempdisk/lunarc/redo03.log
Archived Log entry 35 added for thread 1 sequence 41 ID 0x92fcc890 dest 1:
[19395] Successfully onlined Undo Tablespace 2.
Undo initialization finished serial:0 start:99886074 end:99887784 diff:1710 (17 seconds)
Dictionary check beginning
Sat Aug 02 22:30:52 2014
Errors in file /u01/app/oracle/diag/rdbms/lunarc/lunarc/trace/lunarc_dbw0_19375.trc:
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '/tempdisk/lunarc/temp01.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/lunarc/lunarc/trace/lunarc_dbw0_19375.trc:
ORA-01186: file 201 failed verification tests
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '/tempdisk/lunarc/temp01.dbf'
File 201 not verified due to error ORA-01157
Dictionary check complete
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
Sat Aug 02 22:30:52 2014
SMON: enabling tx recovery
Re-creating tempfile /tempdisk/lunarc/temp01.dbf ---重建了temp表空间的数据文件
Database Characterset is AL32UTF8
No Resource Manager plan active
Sat Aug 02 22:30:56 2014
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Sat Aug 02 22:30:58 2014
QMNC started with pid=23, OS id=19421
LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete
Completed: ALTER DATABASE OPEN
Sat Aug 02 22:31:05 2014
Starting background process CJQ0
Sat Aug 02 22:31:06 2014
CJQ0 started with pid=25, OS id=19435
Sat Aug 02 22:31:07 2014
db_recovery_file_dest_size of 1162 MB is 33.81% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Sat Aug 02 22:31:47 2014
ARC1: STARTING ARCH PROCESSES
Sat Aug 02 22:31:47 2014
ARC4 started with pid=27, OS id=19445
ARC4: Archival started
ARC1: STARTING ARCH PROCESSES COMPLETE
Shutting down archive processes
ARCH shutting down
ARC4: Archival stopped
切换后的C库(已经切换为primary了):
22:33:15 SYS@lunarc>SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO STANDBY
Elapsed: 00:00:00.18
22:33:23 SYS@lunarc> ALTER SYSTEM SWITCH LOGFILE;
System altered.
Elapsed: 00:00:00.26
22:33:31 SYS@lunarc>select DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL from v$database;
DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL
---------------- -------------------- --------------------
PRIMARY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
Elapsed: 00:00:00.02
22:33:55 SYS@lunarc>select thread#,max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 42
Elapsed: 00:00:00.11
22:34:02 SYS@lunarc>
此时A库的日志(已经切换为Standby)了:
Sat Aug 02 22:07:24 2014
db_recovery_file_dest_size of 1162 MB is 13.66% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Sat Aug 02 22:30:48 2014
Using STANDBY_ARCHIVE_DEST parameter default value as USE_DB_RECOVERY_FILE_DEST
Sat Aug 02 22:30:49 2014
RFS[1]: Assigned to RFS process 19415
RFS[1]: Opened log for thread 1 sequence 40 dbid -1830388907 branch 853060791
Archived Log entry 72 added for thread 1 sequence 40 rlc 853060791 ID 0x92fcc890 dest 2:
Sat Aug 02 22:30:50 2014
Primary database is in MAXIMUM PERFORMANCE mode
RFS[2]: Assigned to RFS process 19417
RFS[2]: No standby redo logfiles created
RFS[2]: Opened log for thread 1 sequence 42 dbid -1830388907 branch 853060791
Sat Aug 02 22:30:51 2014
Media Recovery Log /stage/fast_recovery_area/LUNARP/archivelog/2014_08_02/o1_mf_1_40_9xvorstf_.arc
Media Recovery Waiting for thread 1 sequence 41 (in transit)
Sat Aug 02 22:30:51 2014
RFS[3]: Assigned to RFS process 19419
RFS[3]: Opened log for thread 1 sequence 41 dbid -1830388907 branch 853060791
Archived Log entry 73 added for thread 1 sequence 41 rlc 853060791 ID 0x92fcc890 dest 2:
Media Recovery Log /stage/fast_recovery_area/LUNARP/archivelog/2014_08_02/o1_mf_1_41_9xvorvo0_.arc
Media Recovery Waiting for thread 1 sequence 42 (in transit)
Sat Aug 02 22:33:30 2014
Archived Log entry 74 added for thread 1 sequence 42 rlc 853060791 ID 0x92fcc890 dest 2:
RFS[2]: No standby redo logfiles created
RFS[2]: Opened log for thread 1 sequence 43 dbid -1830388907 branch 853060791
Sat Aug 02 22:33:32 2014
Media Recovery Log /stage/fast_recovery_area/LUNARP/archivelog/2014_08_02/o1_mf_1_42_9xvorv1t_.arc
Media Recovery Waiting for thread 1 sequence 43 (in transit)
调整一下A库的fal参数:
22:15:18 SYS@lunarp>show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string lunarp
fal_server string lunars
22:38:18 SYS@lunarp>alter system set fal_server='lunarc';
System altered.
Elapsed: 00:00:00.08
22:38:44 SYS@lunarp>show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string lunarp
fal_server string lunarc
22:38:58 SYS@lunarp>
============================================================================================================
5,B库,将被切换为Cascade,此时需要先修改归档参数,取消B到A和B到C的归档
============================================================================================================
SQL> SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE
--------- ------------------------------ ---------------- --------------------
SWITCHOVER_STATUS OPEN_MODE
-------------------- --------------------
LUNAR lunars PHYSICAL STANDBY MAXIMUM PERFORMANCE
NOT ALLOWED MOUNTED
SQL> show parameter log
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_syslog_level string
commit_logging string
db_create_online_log_dest_1 string +DATA
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
enable_ddl_logging boolean FALSE
log_archive_config string DG_CONFIG=(lunarp,lunars,lunar
c)
log_archive_dest string
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=USE_DB_RECOVERY_FILE_
DEST VALID_FOR=(ALL_LOGFILES,A
LL_ROLES) DB_UNIQUE_NAME=lunar
s
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string
log_archive_dest_16 string
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
log_archive_dest_2 string SERVICE=lunarp LGWR SYNC AFFIR
M VALID_FOR=(ONLINE_LOGFILES,P
RIMARY_ROLE) DB_UNIQUE_NAME=lu
narp
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
log_archive_dest_28 string
log_archive_dest_29 string
log_archive_dest_3 string SERVICE=lunarc LGWR SYNC AFFIR
M VALID_FOR=(STANDBY_LOGFILES,
STANDBY_ROLE) DB_UNIQUE_NAME=l
unarc
log_archive_dest_30 string
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_31 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string ENABLE
log_archive_dest_state_10 string enable
log_archive_dest_state_11 string enable
log_archive_dest_state_12 string enable
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_13 string enable
log_archive_dest_state_14 string enable
log_archive_dest_state_15 string enable
log_archive_dest_state_16 string enable
log_archive_dest_state_17 string enable
log_archive_dest_state_18 string enable
log_archive_dest_state_19 string enable
log_archive_dest_state_2 string ENABLE
log_archive_dest_state_20 string enable
log_archive_dest_state_21 string enable
log_archive_dest_state_22 string enable
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_23 string enable
log_archive_dest_state_24 string enable
log_archive_dest_state_25 string enable
log_archive_dest_state_26 string enable
log_archive_dest_state_27 string enable
log_archive_dest_state_28 string enable
log_archive_dest_state_29 string enable
log_archive_dest_state_3 string ENABLE
log_archive_dest_state_30 string enable
log_archive_dest_state_31 string enable
log_archive_dest_state_4 string enable
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable
log_archive_dest_state_9 string enable
log_archive_duplex_dest string
log_archive_format string %t_%s_%r.dbf
log_archive_local_first boolean TRUE
log_archive_max_processes integer 4
log_archive_min_succeed_dest integer 1
log_archive_start boolean FALSE
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_trace integer 0
log_buffer integer 7176192
log_checkpoint_interval integer 0
log_checkpoint_timeout integer 1800
log_checkpoints_to_alert boolean FALSE
log_file_name_convert string /stage/lunar/, +DATA/lunars/
remote_login_passwordfile string EXCLUSIVE
sec_case_sensitive_logon boolean TRUE
sec_max_failed_login_attempts integer 10
SQL> alter system set log_archive_dest_3='';
System altered.
SQL> alter system set log_archive_dest_state_3=defer;
System altered.
SQL>
日志没有同步完成,需要检查日志的同步情况:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
NOT ALLOWED
SQL> select max(sequence#),thread# from v$archived_log group by thread#;
MAX(SEQUENCE#) THREAD#
-------------- ----------
39 1
SQL> show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string lunars
fal_server string lunarp
SQL> alter system set fal_server='lunarp','lunarc';
System altered.
SQL> show parameter fal
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fal_client string lunars
fal_server string lunarp, lunarc
SQL>
============================================================================================================
修改A库(已经切换为Standby了)参数:
============================================================================================================
alter system set log_archive_dest_2='';
alter system set log_archive_dest_3='';
alter system set log_archive_dest_2='SERVICE=lunarc LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lunarc';
alter system set log_archive_dest_state_2=enable;
alter system set log_archive_dest_3='SERVICE=lunars LGWR ASYNC AFFIRM VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=lunars';
alter system set log_archive_dest_state_3=enable;
如果还有问题,可以执行下面的(本次没等执行,已经好了):
alter system set log_archive_dest_state_2=defer;
alter system set log_archive_dest_state_3=defer;
alter system set log_archive_dest_state_2=enable;
alter system set log_archive_dest_state_3=enable;
此时原来C库的日志(已经从Cascade Standby切换为primart了):
22:59:48 SYS@lunarc>alter system switch logfile;
System altered.
Elapsed: 00:00:00.19
23:06:22 SYS@lunarc>select thread#,max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 48
Elapsed: 00:00:00.04
23:06:57 SYS@lunarc>select thread#,applied,max(sequence#) from v$archived_log where applied='YES' group by thread#,applied;
THREAD# APPLIED MAX(SEQUENCE#)
---------- --------- --------------
1 YES 48
Elapsed: 00:00:00.05
23:13:00 SYS@lunarc>
日志如下:
Sat Aug 02 22:59:50 2014
Destination LOG_ARCHIVE_DEST_2 is SYNCHRONIZED
Destination LOG_ARCHIVE_DEST_2 no longer supports SYNCHRONIZATION
Thread 1 advanced to log sequence 48 (LGWR switch)
Current log# 3 seq# 48 mem# 0: /tempdisk/lunarc/redo03.log
Sat Aug 02 22:59:51 2014
Archived Log entry 48 added for thread 1 sequence 47 ID 0x92fcc890 dest 1:
Sat Aug 02 23:06:22 2014
Destination LOG_ARCHIVE_DEST_2 is SYNCHRONIZED
Destination LOG_ARCHIVE_DEST_2 no longer supports SYNCHRONIZATION
Thread 1 advanced to log sequence 49 (LGWR switch)
Current log# 1 seq# 49 mem# 0: /tempdisk/lunarc/redo01.log
Sat Aug 02 23:06:23 2014
Archived Log entry 50 added for thread 1 sequence 48 ID 0x92fcc890 dest 1:
此时的A库(已经从Primary切换为Standby了):
23:04:56 SYS@lunarp>select thread#,max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 48
Elapsed: 00:00:00.06
23:07:00 SYS@lunarp>select thread#,applied,max(sequence#) from v$archived_log where applied='YES' group by thread#,applied;
THREAD# APPLIED MAX(SEQUENCE#)
---------- --------- --------------
1 YES 48
Elapsed: 00:00:00.04
23:12:57 SYS@lunarp>
Sat Aug 02 23:06:22 2014
Archived Log entry 88 added for thread 1 sequence 48 rlc 853060791 ID 0x92fcc890 dest 2:
RFS[2]: No standby redo logfiles created
RFS[2]: Opened log for thread 1 sequence 49 dbid -1830388907 branch 853060791
Sat Aug 02 23:06:27 2014
Media Recovery Log /stage/fast_recovery_area/LUNARP/archivelog/2014_08_02/o1_mf_1_48_9xvqh6hl_.arc
Media Recovery Waiting for thread 1 sequence 49 (in transit)
此时的B库(已经切换为Standby 切换为Cascade Standby了)
SQL> select thread#,max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 48
SQL> recover managed standby database cancel;
ORA-16136: Managed Standby Recovery not active
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL>
SQL> select thread#,applied,max(sequence#) from v$archived_log where applied='YES' group by thread#,applied;
THREAD# APPLIED MAX(SEQUENCE#)
---------- --------- --------------
1 YES 48
SQL>
Sun Aug 03 07:06:34 2014
RFS[8]: Opened log for thread 1 sequence 48 dbid -1830388907 branch 853060791
Archived Log entry 75 added for thread 1 sequence 48 rlc 853060791 ID 0x92fcc890 dest 3:
Sun Aug 03 07:11:34 2014
ALTER DATABASE RECOVER managed standby database cancel
ORA-16136 signalled during: ALTER DATABASE RECOVER managed standby database cancel ...
Sun Aug 03 07:11:45 2014
alter database recover managed standby database using current logfile disconnect from session
Attempt to start background Managed Standby Recovery process (lunars)
Sun Aug 03 07:11:45 2014
MRP0 started with pid=34, OS id=20717
MRP0: Background Managed Standby Recovery process started (lunars)
started logmerger process
Sun Aug 03 07:11:50 2014
Managed Standby Recovery starting Real Time Apply
Parallel Media Recovery started with 2 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_02/o1_mf_1_31_9xsv85l5_.arc
Completed: alter database recover managed standby database using current logfile disconnect from session
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_02/o1_mf_1_32_9xsv879v_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_33_9xto475l_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_34_9xto4q5w_.arc
Sun Aug 03 07:12:01 2014
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_35_9xtp69j7_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_36_9xtpvoj1_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_37_9xtq4hwb_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_38_9xtqb2lp_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_39_9xtqb7l9_.arc
Identified End-Of-Redo (switchover) for thread 1 sequence 39 at SCN 0x0.14ca59
Resetting standby activation ID 2464533536 (0x92e5cc20)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Continuing
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_40_9xtvowds_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_41_9xtvowk2_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_42_9xtvow7w_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_43_9xtvowj5_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_44_9xtvownm_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_45_9xtvowop_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_46_9xtvowqg_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_47_9xtvowtt_.arc
Media Recovery Log /stage/fast_recovery_area/LUNARS/archivelog/2014_08_03/o1_mf_1_48_9xtvqtdm_.arc
Media Recovery Waiting for thread 1 sequence 49