三、主备库switchover
注意:对于升级完成的备库,以下参数不能修改(全部升级完成后再修改)
升级后的版本:
sql> select * from v$version;
banner
----------------------------------------------------------------
oracle database 10g enterprise edition release 10.2.0.4.0 - prod
pl/sql release 10.2.0.4.0 - production
core 10.2.0.4.0 production
tns for linux: version 10.2.0.4.0 - production
nlsrtl version 10.2.0.4.0 - production
如果修改后,在做switchover时会出现以下错误:
switchover 前准备:
查看主备库是否同步:
主库:
14:38:08 sys@ test1>select count(*) from scott.emp1;
count(*)
----------
33
elapsed: 00:00:00.00
14:38:13 sys@ test1>alter system switch logfile;
system altered.
elapsed: 00:00:05.03
14:38:22 sys@ test1>select name,database_role,protection_mode,switchover_status from v$database;
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
test1 primary maximum performance to standby
elapsed: 00:00:00.13
14:40:27 sys@ test1>
备库:
sql> alter database start logical standby apply immediate;
database altered.
sql> show parameter comp
name type value
------------------------------------ ----------- ------------------------------
compatible string 10.2.0
nls_comp string
plsql_compiler_flags string interpreted, non_debug
plsql_v2_compatibility boolean false
sql> select count(*) from scott.emp1;
count(*)
----------
30
sql> /
count(*)
----------
33
sql> select name,database_role,protection_mode,switchover_status from v$database;
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
shdb logical standby maximum performance not allowed
备库切换前准备:
sql> alter database prepare to switchover to primary;
database altered.
sql> select name,database_role,protection_mode,switchover_status from v$database;
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
shdb logical standby maximum performance preparing switchover
sql>
主库切换前准备:
14:40:27 sys@ test1>alter database prepare to switchover to logical standby;
database altered.
elapsed: 00:00:00.04
14:42:06 sys@ test1>select name,database_role,protection_mode,switchover_status from v$database;
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
test1 primary maximum performance preparing switchover
elapsed: 00:00:00.00
在备库做prepare switchover 后,主库状态:
14:42:11 sys@ test1>/
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
test1 primary maximum performance to logical standby
elapsed: 00:00:00.01
14:43:38 sys@ test1>
主库切换:
14:43:38 sys@ test1>alter database commit to switchover to logical standby;
database altered.
elapsed: 00:00:31.50
14:45:01 sys@ test1>
14:45:01 sys@ test1>select name,database_role,protection_mode,switchover_status from v$database;
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
test1 logical standby maximum performance not allowed
切换过程主库告警日志:
alter database commit to switchover to logical standby (test1)
tue apr 15 14:44:30 2014
logstdby: ensuring no active hot backups.
logstdby: disabling job queue processes.
logstdby: enabling database guard to prevent new transactions.
tue apr 15 14:44:30 2014
waiting for transactions in flight at scn 0x0000.0004ebee to complete
lns1 started with pid=16, os id=3161
tue apr 15 14:44:37 2014
thread 1 advanced to log sequence 69
current log# 3 seq# 69 mem# 0: /u01/app/oracle/oradata/test1/redo03a.log
tue apr 15 14:44:37 2014
arch: lgwr is actively archiving destination log_archive_dest_2
arch: standby redo logfile selected for thread 1 sequence 68 for destination log_archive_dest_2
tue apr 15 14:44:37 2014
logstdby: waiting for pending archivals to dest [2].
tue apr 15 14:44:37 2014
lns: standby redo logfile selected for thread 1 sequence 69 for destination log_archive_dest_2
lns1 started with pid=16, os id=3163
tue apr 15 14:44:43 2014
arch: lgwr is actively archiving destination log_archive_dest_2
tue apr 15 14:44:43 2014
thread 1 advanced to log sequence 70
current log# 1 seq# 70 mem# 0: /u01/app/oracle/oradata/test1/redo01a.log
tue apr 15 14:44:43 2014
arch: standby redo logfile selected for thread 1 sequence 69 for destination log_archive_dest_2
logstdby: verifying receipt of eor logfile on log archive destination [2].
tue apr 15 14:44:43 2014
logstdby: verified eor logfile archival to dest [2].
tue apr 15 14:44:44 2014
lns: standby redo logfile selected for thread 1 sequence 70 for destination log_archive_dest_2
tue apr 15 14:44:55 2014
thread 1 cannot allocate new log, sequence 71
checkpoint not complete
current log# 1 seq# 70 mem# 0: /u01/app/oracle/oradata/test1/redo01a.log
lns1 started with pid=16, os id=3166
tue apr 15 14:45:01 2014
shutting down archive processes
tue apr 15 14:45:01 2014
thread 1 advanced to log sequence 71
current log# 2 seq# 71 mem# 0: /u01/app/oracle/oradata/test1/redo02a.log
tue apr 15 14:45:01 2014
logstdby: switchover complete (test1)
tue apr 15 14:45:01 2014
completed: alter database commit to switchover to logical standby
tue apr 15 14:45:02 2014
lns: standby redo logfile selected for thread 1 sequence 71 for destination log_archive_dest_2
tue apr 15 14:45:06 2014
arch shutting down
arc3: archival stopped
备库切换过程告警日志:
rfs[1]: possible network disconnect with primary database
tue apr 15 14:44:37 2014
redo shipping client connected as public
-- connected user is valid
rfs[4]: assigned to rfs process 3189
rfs[4]: identified database type as 'logical standby'
tue apr 15 14:44:37 2014
rfs logminer: client enabled and ready for notification
rfs[4]: successfully opened standby log 5: '/u01/app/oracle/oradata/sh/std_redo05a.log'
tue apr 15 14:44:37 2014
rfs logminer: client enabled and ready for notification
tue apr 15 14:44:37 2014
logminer: archived logfile found, transition to mining logfile: /u01/arch_sh1arch_1_68_797856158.log
tue apr 15 14:44:37 2014
rfs logminer: registered logfile [/u01/arch_sh1arch_1_68_797856158.log] to logminer session id [21]
tue apr 15 14:44:37 2014
redo shipping client connected as public
-- connected user is valid
rfs[5]: assigned to rfs process 3191
rfs[5]: identified database type as 'logical standby'
tue apr 15 14:44:37 2014
rfs logminer: client enabled and ready for notification
rfs[5]: successfully opened standby log 4: '/u01/app/oracle/oradata/sh/std_redo04a.log'
rfs[5]: possible network disconnect with primary database
tue apr 15 14:44:37 2014
logminer: end mining logfile: /u01/arch_sh1arch_1_68_797856158.log
tue apr 15 14:44:37 2014
logminer: log auto delete - deleting: /u01/arch_sh1arch_1_67_797856158.log
deleted file /u01/arch_sh1arch_1_67_797856158.log
tue apr 15 14:44:43 2014
redo shipping client connected as public
-- connected user is valid
rfs[6]: assigned to rfs process 3193
rfs[6]: identified database type as 'logical standby'
tue apr 15 14:44:43 2014
rfs logminer: client enabled and ready for notification
rfs[6]: successfully opened standby log 4: '/u01/app/oracle/oradata/sh/std_redo04a.log'
tue apr 15 14:44:43 2014
rfs logminer: client enabled and ready for notification
tue apr 15 14:44:43 2014
logminer: begin mining logfile for session 21 thread 1 sequence 69, /u01/app/oracle/oradata/sh/std_redo04a.log
tue apr 15 14:44:43 2014
logminer: end mining logfile: /u01/app/oracle/oradata/sh/std_redo04a.log
tue apr 15 14:44:43 2014
rfs logminer: registered logfile [/u01/arch_sh1arch_1_69_797856158.log] to logminer session id [21]
tue apr 15 14:44:43 2014
logstdby: shutdown acknowledged
logstdby analyzer process p003 pid=27 os id=3153 stopped
logstdby apply process p004 pid=28 os id=3155 stopped
logstdby apply process p005 pid=29 os id=3157 stopped
logstdby apply process p006 pid=30 os id=3159 stopped
logstdby apply process p007 pid=31 os id=3161 stopped
logstdby apply process p008 pid=32 os id=3163 stopped
tue apr 15 14:44:44 2014
logminer: log auto delete - deleting: /u01/arch_sh1arch_1_68_797856158.log
deleted file /u01/arch_sh1arch_1_68_797856158.log
tue apr 15 14:44:44 2014
logstdby status: ora-16257: switchover initiated stop apply successfully completed
tue apr 15 14:44:44 2014
redo shipping client connected as public
-- connected user is valid
rfs[7]: assigned to rfs process 3195
rfs[7]: identified database type as 'logical standby'
primary database is in maximum performance mode
tue apr 15 14:44:44 2014
rfs logminer: client enabled and ready for notification
primary database is in maximum performance mode
rfs[7]: successfully opened standby log 4: '/u01/app/oracle/oradata/sh/std_redo04a.log'
rfs[7]: possible network disconnect with primary database
redo shipping client connected as public
-- connected user is valid
rfs[8]: assigned to rfs process 3197
rfs[8]: identified database type as 'logical standby'
primary database is in maximum performance mode
tue apr 15 14:45:02 2014
rfs logminer: client enabled and ready for notification
primary database is in maximum performance mode
rfs[8]: successfully opened standby log 5: '/u01/app/oracle/oradata/sh/std_redo05a.log'
主库切换完成后,备库状态:
sql> select name,database_role,protection_mode,switchover_status from v$database;
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
shdb logical standby maximum performance preparing switchover
sql> /
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
shdb logical standby maximum performance to primary
sql>
备库切换:
sql> alter database commit to switchover to primary;
database altered.
sql> select name,database_role,protection_mode,switchover_status from v$database;
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
shdb primary maximum performance sessions active
sql>
备库切换过程告警日志:
alter database switchover to primary (sh)
tue apr 15 14:48:31 2014
rfs logminer: client enabled and ready for notification
tue apr 15 14:48:31 2014
logminer: warning: registered partial log file /u01/arch_sh1arch_1_70_797856158.log
tue apr 15 14:48:31 2014
rfs logminer: registered logfile [/u01/arch_sh1arch_1_70_797856158.log] to logminer session id [21]
logstdby event: starting scn of new stream from seeded lockdown [0x0000.00071f8b]
logstdby event: successful close of the current log stream:
logstdby event: primary: [1174898526]
logstdby event: first scn: [0x0000.00046d38]
logstdby event: end scn: [0x0000.0004ebf8]
logstdby event: processed scn: [0x0000.0004ebf9]
lns1 started with pid=20, os id=3209
tue apr 15 14:48:34 2014
arch: lgwr is scheduled to archive destination log_archive_dest_2 after log switch
tue apr 15 14:48:34 2014
arc0: starting arch processes
tue apr 15 14:48:34 2014
thread 1 advanced to log sequence 30 (lgwr switch)
current log# 3 seq# 30 mem# 0: /u01/app/oracle/oradata/sh/redo03a.log
tue apr 15 14:48:34 2014
arc3: archival started
arc0: starting arch processes complete
arc3 started with pid=20, os id=3211
tue apr 15 14:49:24 2014
arch: standby redo logfile selected for thread 1 sequence 29 for destination log_archive_dest_2
completed: alter database commit to switchover to primary
tue apr 15 14:49:28 2014
starting background process cjq0
cjq0 started with pid=23, os id=3215
主库日志:
rfs[4]: assigned to rfs process 3177
rfs[4]: identified database type as 'logical standby'
tue apr 15 14:48:34 2014
rfs logminer: client enabled and ready for notification
tue apr 15 14:49:24 2014
rfs[4]: successfully opened standby log 4: '/u01/app/oracle/oradata/test1/std_redo04a.log'
tue apr 15 14:49:25 2014
rfs logminer: client enabled and ready for notification
tue apr 15 14:49:29 2014
rfs logminer: registered logfile [/disk1/arch_test1/arch_1_29_844857742.log] to logminer session id [21]
四、switchover 成功后,升级原主库:
原主库:
14:47:27 sys@ test1>select name,database_role,protection_mode,switchover_status from v$database;
name database_role protection_mode switchover_status
--------- ---------------- -------------------- --------------------
test1 logical standby maximum performance not allowed
elapsed: 00:00:00.00
数据库版本:
14:54:26 sys@ test1>select * from v$version;
banner
----------------------------------------------------------------
oracle database 10g enterprise edition release 10.2.0.1.0 - prod
pl/sql release 10.2.0.1.0 - production
core 10.2.0.1.0 production
tns for linux: version 10.2.0.1.0 - production
nlsrtl version 10.2.0.1.0 - production
原备库数据库版本:
sql> select * from v$version;
banner
----------------------------------------------------------------
oracle database 10g enterprise edition release 10.2.0.4.0 - prod
pl/sql release 10.2.0.4.0 - production
core 10.2.0.4.0 production
tns for linux: version 10.2.0.4.0 - production
nlsrtl version 10.2.0.4.0 - production
@原主库的升级,本案例就不在重复讲述,切换成功后,,滚动升级应该到此已成功!
本文出自 “天涯客的blog” 博客,请务必保留此出处
