Oracle级联DG部署以及切换测试

**前言:**文档描述搭建一级、二级DG并且模拟多个场景切换测试。DG搭建很简单,级联DG也是生产中比较常见的部署方式,如果一级DG切换为主库,那么就相当于一主两备。

一、 搭建一级备库
环境:11.2.0.4 单机
主库:192.168.100.129 SID:ecms 主机名:nhjcgl-db
一级备库:192.168.100.199 SID:ecms 主机名:dg1
二级备库:192.168.100.200 SID:ecms 主机名:dg2

1.1 主库准备
select FORCE_LOGGING,log_mode from v$database;
alter database force logging;
1.2 开启归档
shu immediate
startup mount
alter database archivelog;
alter database open;

1.3 参数设置
alter system set log_archive_config=‘dg_config=(ecms,ecmsdg1)’;
alter system set log_archive_dest_2=‘service=ecmsdg1 async valid_for=(online_logfile,primary_role) db_unique_name=ecmsdg1’;

1.4 监听配置
#TNS
ECMS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = nhjcgl-db)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ecms)
)
)

ecmsdg1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.199)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ecms)
)
)

##Listener
[oracle@nhjcgl-db admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/11.2.4/db_home1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nhjcgl-db)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_NAME = ecms)
(ORACLE_HOME =/u01/app/oracle/11.2.4/db_home1)
(SID_NAME= ecms)
)
)

ADR_BASE_LISTENER = /u01/app/oracle

1.5 备库准备
复制密码文件、参数文件、监听文件
修改pfile
[oracle@dg1 ~]$ cat pfile001
ecms.__db_cache_size=281018368
ecms.__java_pool_size=20971520
ecms.__large_pool_size=4194304
ecms.__oracle_base=’/u01/app/oracle’#ORACLE_BASE set from environment
ecms.__pga_aggregate_target=289406976
ecms.__sga_target=545259520
ecms.__shared_io_pool_size=0
ecms.__shared_pool_size=222298112
ecms.__streams_pool_size=8388608
*.audit_file_dest=’/u01/app/oracle/admin/ecms/adump’
*.audit_trail=‘db’
*.compatible=‘11.2.0.4.0’
*.control_files=’/u01/app/oracle/oradata/ecms/control01.ctl’
.db_block_size=8192
#
.db_create_file_dest=’/u01/app/oracle/oradata/ecms/’
*.db_domain=’’
*.db_name=‘ecms’
*.db_recovery_file_dest=’/u01/app/oracle/fast_recovery_area’
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest=’/u01/app/oracle’
*.dispatchers=’(PROTOCOL=TCP) (SERVICE=ecmsXDB)’
*.fal_client=‘ECMSDG1’
*.fal_server=‘ECMS’
*.java_jit_enabled=TRUE
*.java_pool_size=0
*.large_pool_size=4194304
*.log_archive_config=‘dg_config=(ecms,ecmsdg1)’
*.log_archive_dest_2=‘service=ecms async valid_for=(online_logfile,primary_role) db_unique_name=ecms’
*.memory_target=831520768
*.open_cursors=3500
*.processes=150
*.remote_login_passwordfile=‘EXCLUSIVE’
*.service_names=‘ecms,tt’
*.standby_file_management=‘AUTO’
*.undo_tablespace=‘UNDOTBS1’
*.db_unique_name=ECMSDG1

1.6 创建目录
/u01/app/oracle/admin/ecms/adump
/u01/app/oracle/oradata/ecms/
/u01/app/oracle/fast_recovery_area
1.7 启动
SQL> startup nomount pfile=’/home/oracle/pfile001’;
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size 2257800 bytes
Variable Size 545262712 bytes
Database Buffers 281018368 bytes
Redo Buffers 2392064 bytes
SQL> create spfile from pfile=’/home/oracle/pfile001’;
SQL> shu immediate;startup nomount;

1.8 备库连接到主库
[oracle@dg1 dbs]$ rman target sys/xxxxx@ecms auxiliary sys/xxxxx@ecmsdg1

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 6 10:15:18 2019

Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: ECMS (DBID=4086521191)
connected to auxiliary database: ECMS (not mounted)

RMAN> duplicate target database for standby from active database dorecover nofilenamecheck;

1.9 添加standby log
alter database add standby logfile ‘/u01/app/oracle/oradata/ecms/standby01.log’ size 50m;

二、 搭建二级备库

2.1 级联备库(与创建一级备库方法步骤一致)
级联主库修改dg1
alter system set log_archive_config=‘dg_config=(ecms,ecmsdg1,ecmsdg2)’;
alter system set log_archive_dest_3=‘service=ecmsdg2 async valid_for=(standby_logfile,standby_role) db_unique_name=ecmsdg2’;

2.2 级联备库修改dg2,复制监听文件,密码文件,参数文件
Pfile修改
[oracle@dg2 ~]$ cat pfile002
ecms.__db_cache_size=281018368
ecms.__java_pool_size=20971520
ecms.__large_pool_size=4194304
ecms.__oracle_base=’/u01/app/oracle’#ORACLE_BASE set from environment
ecms.__pga_aggregate_target=289406976
ecms.__sga_target=545259520
ecms.__shared_io_pool_size=0
ecms.__shared_pool_size=222298112
ecms.__streams_pool_size=8388608
*.audit_file_dest=’/u01/app/oracle/admin/ecms/adump’
*.audit_trail=‘db’
*.compatible=‘11.2.0.4.0’
*.control_files=’/u01/app/oracle/oradata/ecms/control01.ctl’
.db_block_size=8192
#
.db_create_file_dest=’/u01/app/oracle/oradata/ecms/’
*.db_domain=’’
*.db_name=‘ecms’
*.db_recovery_file_dest=’/u01/app/oracle/fast_recovery_area’
*.db_recovery_file_dest_size=4385144832
*.db_unique_name=‘ecmsdg2’
*.diagnostic_dest=’/u01/app/oracle’
*.dispatchers=’(PROTOCOL=TCP) (SERVICE=ecmsXDB)’
*.fal_client=‘ECMSDG2’
*.fal_server=‘ECMSDG1’
*.java_jit_enabled=TRUE
*.java_pool_size=0
*.large_pool_size=4194304
*.log_archive_config=‘dg_config=(ecmsdg1,ecmsdg2)’
*.log_archive_dest_2=‘service=ecmsdg1 async valid_for=(online_logfile,primary_role) db_unique_name=ecmsdg1’
*.memory_target=831520768
*.open_cursors=3500
*.processes=150
*.remote_login_passwordfile=‘EXCLUSIVE’
*.service_names=‘ecms,tt’
*.standby_file_management=‘AUTO’
*.undo_tablespace=‘UNDOTBS1’
备注:db_create_file_dest 权重过高,即使主备目录一致,也会按此参数设置,比较坑还要后期处理rename比较麻烦所以注释掉。

2.3 创建目录
/u01/app/oracle/oradata/ecms/
/u01/app/oracle/admin/ecms/adump
/u01/app/oracle/fast_recovery_area

2.4 rman在线创建二级备库
[oracle@dg1 ~]$ rman target sys/xxxxxx@ecmsdg1 auxiliary sys/xxxxxx@ecmsdg2

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 6 11:21:42 2019

Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: ECMS (DBID=4086521191)
connected to auxiliary database: ECMS (not mounted)

RMAN> duplicate target database for standby from active database dorecover nofilenamecheck;

三、 主库与一级备库切换
切换前状态
A:主库B:一级备库 C:二级备库
切换后状态
A:一级备库 B:主库 C:一级备库

3.1 状态检查
SELECT NAME,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE, SWITCHOVER_STATUS, OPEN_MODE FROM V$DATABASE;

SYS@ecms>ALTER SYSTEM SWITCH LOGFILE;
System altered.
Elapsed: 00:00:00.02
SYS@ecms>/

3.2 主备切换
SYS@ecms>alter database commit to switchover to physical standby WITH SESSION SHUTDOWN;
Database altered.
Elapsed: 00:00:07.97

3.3 主库日志
Thu Jun 06 12:13:15 2019
alter database commit to switchover to physical standby WITH SESSION SHUTDOWN
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY [Process Id: 6364] (ecms)
Waiting for all non-current ORLs to be 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 Physical Standby switchover target to become synchronized…
Active, synchronized Physical Standby switchover target has been identified
Switchover End-Of-Redo Log thread 1 sequence 395 has been fixed
Switchover: Primary highest seen SCN set to 0x0.0x25636b
ARCH: Noswitch archival of thread 1, sequence 395
ARCH: End-Of-Redo Branch archival of thread 1 sequence 395
ARCH: LGWR is scheduled to archive destination LOG_ARCHIVE_DEST_2 after log switch
ARCH: Standby redo logfile selected for thread 1 sequence 395 for destination LOG_ARCHIVE_DEST_2
Archived Log entry 46 added for thread 1 sequence 395 ID 0xf6371a63 dest 1:
ARCH: Archiving is disabled due to current logfile archival
Primary will check for some target standby to have received alls redo
Final check for a synchronized target standby. Check will be made once.
LOG_ARCHIVE_DEST_2 is a potential Physical Standby switchover target
Active, synchronized target has been identified
Target has also received all redo
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/ecms/ecms/trace/ecms_ora_6364.trc
Clearing standby activation ID 4130806371 (0xf6371a63)
The primary database controlfile was created using the
‘MAXLOGFILES 21’ clause.
There is space for up to 18 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 395 required for standby recovery
Switchover: Primary controlfile converted to standby controlfile succesfully.
Switchover: Complete - Database shutdown required
USER (ospid: 6364): terminating the instance
Instance terminated by USER, pid = 6364
Completed: alter database commit to switchover to physical standby WITH SESSION SHUTDOWN
Shutting down instance (abort)
License high water mark = 6
Thu Jun 06 12:13:20 2019
Instance shutdown complete

3.4 一级备库日志
Thu Jun 06 12:13:18 2019
RFS[19]: Assigned to RFS process 1994
RFS[19]: Selected log 4 for thread 1 sequence 395 dbid -208446105 branch 982149581
Thu Jun 06 12:13:19 2019
Resetting standby activation ID 4130806371 (0xf6371a63)
Thu Jun 06 12:13:19 2019
Archived Log entry 31 added for thread 1 sequence 395 ID 0xf6371a63 dest 1:
Media Recovery Waiting for thread 1 sequence 396
Thu Jun 06 12:13:19 2019
ARC3: Standby redo logfile selected for thread 1 sequence 395 for destination LOG_ARCHIVE_DEST_3
Thu Jun 06 12:13:19 2019
RFS[16]: Possible network disconnect with primary database
Thu Jun 06 12:13:19 2019
RFS[20]: Assigned to RFS process 1992
RFS[20]: Possible network disconnect with primary database
Thu Jun 06 12:13:19 2019
RFS[18]: Possible network disconnect with primary database

3.5 二级备库日志
Thu Jun 06 11:53:02 2019
RFS[8]: Assigned to RFS process 1431
RFS[8]: Selected log 4 for thread 1 sequence 390 dbid -208446105 branch 982149581
Thu Jun 06 11:53:02 2019
Archived Log entry 8 added for thread 1 sequence 390 ID 0xf48ae18e dest 1:
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_390_ghk3jy46_.arc
Media Recovery Waiting for thread 1 sequence 391
Thu Jun 06 11:53:05 2019
RFS[9]: Assigned to RFS process 1433
RFS[9]: Selected log 4 for thread 1 sequence 391 dbid -208446105 branch 982149581
Thu Jun 06 11:53:05 2019
Archived Log entry 9 added for thread 1 sequence 391 ID 0xf48ae18e dest 1:
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_391_ghk3k1ff_.arc
Media Recovery Waiting for thread 1 sequence 392
Thu Jun 06 11:54:46 2019
RFS[10]: Assigned to RFS process 1440
RFS[10]: Selected log 4 for thread 1 sequence 392 dbid -208446105 branch 982149581
Thu Jun 06 11:54:46 2019
Archived Log entry 10 added for thread 1 sequence 392 ID 0xf48ae18e dest 1:
Thu Jun 06 11:54:47 2019
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_392_ghk3n69t_.arc
Identified End-Of-Redo (switchover) for thread 1 sequence 392 at SCN 0x0.2512c7
Resetting standby activation ID 4102742414 (0xf48ae18e)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Continuing
Media Recovery Waiting for thread 1 sequence 393

3.6 备库状态检查
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


ECMS ecmsdg1 PHYSICAL STANDBY MAXIMUM PERFORMANCE
TO PRIMARY READ ONLY WITH APPLY

级联备库状态检查(也可以切成主库)
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


ECMS ecmsdg2 PHYSICAL STANDBY MAXIMUM PERFORMANCE
TO PRIMARY READ ONLY WITH APPLY
SQL>

3.7 原主库再切换成主库
切换前状态:
A:主库 B:一级备库C:二级备库
切换后状态:
A:主库 B:一级备库C:二级备库

Thu Jun 06 12:03:43 2019
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
ALTER DATABASE SWITCHOVER TO PRIMARY (ecms)
Maximum wait for role transition is 15 minutes.
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Thu Jun 06 12:03:45 2019
SMON: disabling cache recovery
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/ecms/ecms/trace/ecms_ora_6164.trc
SwitchOver after complete recovery through change 2429639
Online logfile pre-clearing operation disabled by switchover
Thu Jun 06 12:04:51 2019
idle dispatcher ‘D000’ terminated, pid = (17, 1)

Thu Jun 06 12:05:39 2019
Standby became primary SCN: 2429637
AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the parameter file.
Switchover: Complete - Database mounted as primary
Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY

##原主库又切回主库,级联备库状态变成NOT ALLOWED
SQL> /

NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE


SWITCHOVER_STATUS OPEN_MODE


ECMS ecmsdg2 PHYSICAL STANDBY MAXIMUM PERFORMANCE
NOT ALLOWED READ ONLY WITH APPLY

SQL> show parameter config

NAME TYPE VALUE


dg_broker_config_file1 string /u01/app/oracle/11.2.4/db_home
1/dbs/dr1ecmsdg2.dat
dg_broker_config_file2 string /u01/app/oracle/11.2.4/db_home
1/dbs/dr2ecmsdg2.dat
log_archive_config string dg_config=(ecmsdg1,ecmsdg2)
SQL>

备库切换成主库
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
备库日志:
Thu Jun 06 12:16:19 2019
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
ALTER DATABASE SWITCHOVER TO PRIMARY (ecms)
Maximum wait for role transition is 15 minutes.
Switchover: Media recovery is still active
Role Change: Canceling MRP - no more redo to apply
Thu Jun 06 12:16:21 2019
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /u01/app/oracle/diag/rdbms/ecmsdg1/ecms/trace/ecms_mrp0_1661.trc:
ORA-16037: user requested cancel of managed recovery operation
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
MRP0: Background Media Recovery process shutdown (ecms)
Role Change: Canceled MRP
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Thu Jun 06 12:16:22 2019
SMON: disabling cache recovery
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/ecmsdg1/ecms/trace/ecms_ora_1852.trc
SwitchOver after complete recovery through change 2450283
Online logfile pre-clearing operation disabled by switchover
Online log /u01/app/oracle/oradata/ecms/ECMSDG1/onlinelog/o1_mf_1_ghjyzfwk_.log: Thread 1 Group 1 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG1/onlinelog/o1_mf_1_ghjyzfy5_.log: Thread 1 Group 1 was previously cleared
Online log /u01/app/oracle/oradata/ecms/ECMSDG1/onlinelog/o1_mf_2_ghjyzk7o_.log: Thread 1 Group 2 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG1/onlinelog/o1_mf_2_ghjyzk98_.log: Thread 1 Group 2 was previously cleared
Online log /u01/app/oracle/oradata/ecms/ECMSDG1/onlinelog/o1_mf_3_ghjyznhk_.log: Thread 1 Group 3 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG1/onlinelog/o1_mf_3_ghjyznk2_.log: Thread 1 Group 3 was previously cleared
Standby became primary SCN: 2450281
AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the parameter file.
Switchover: Complete - Database mounted as primary
Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY

再转换为备库;
alter database commit to switchover to physical standby WITH SESSION SHUTDOWN;
日志输出
Thu Jun 06 12:32:02 2019
alter database commit to switchover to physical standby WITH SESSION SHUTDOWN
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY [Process Id: 2055] (ecms)
Waiting for all non-current ORLs to be 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 Physical Standby switchover target to become synchronized…
Active, synchronized Physical Standby switchover target has been identified
Switchover End-Of-Redo Log thread 1 sequence 406 has been fixed
Switchover: Primary highest seen SCN set to 0x0.0x25b724
ARCH: Noswitch archival of thread 1, sequence 406
ARCH: End-Of-Redo Branch archival of thread 1 sequence 406
ARCH: LGWR is scheduled to archive destination LOG_ARCHIVE_DEST_2 after log switch
ARCH: Standby redo logfile selected for thread 1 sequence 406 for destination LOG_ARCHIVE_DEST_2
Archived Log entry 53 added for thread 1 sequence 406 ID 0xf636bca0 dest 1:
ARCH: Archiving is disabled due to current logfile archival
Primary will check for some target standby to have received alls redo
Final check for a synchronized target standby. Check will be made once.
LOG_ARCHIVE_DEST_2 is a potential Physical Standby switchover target
Active, synchronized target has been identified
Target has also received all redo
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/ecmsdg1/ecms/trace/ecms_ora_2055.trc
Clearing standby activation ID 4130782368 (0xf636bca0)
The primary database controlfile was created using the
‘MAXLOGFILES 21’ clause.
There is space for up to 18 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 406 required for standby recovery
Switchover: Primary controlfile converted to standby controlfile succesfully.
Switchover: Complete - Database shutdown required
USER (ospid: 2055): terminating the instance
Instance terminated by USER, pid = 2055
Completed: alter database commit to switchover to physical standby WITH SESSION SHUTDOWN
Shutting down instance (abort)

归档存在gap,在级联备库中等待片刻便会同步。
Thu Jun 06 12:33:33 2019
RFS[24]: Assigned to RFS process 1581
RFS[24]: Opened log for thread 1 sequence 406 dbid -208446105 branch 982149581
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_398_ghk5wwfn_.arc
Archived Log entry 24 added for thread 1 sequence 406 rlc 982149581 ID 0xf636bca0 dest 3:
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_399_ghk5wwjh_.arc
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_400_ghk5wwlk_.arc
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_401_ghk5wwnm_.arc
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_402_ghk5wwop_.arc
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_403_ghk5wwp7_.arc
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_404_ghk5wwtv_.arc
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_405_ghk5wwz6_.arc
Media Recovery Log /u01/app/oracle/fast_recovery_area/ECMSDG2/archivelog/2019_06_06/o1_mf_1_406_ghk5wx24_.arc
Identified End-Of-Redo (switchover) for thread 1 sequence 406 at SCN 0x0.25b724
Resetting standby activation ID 4130782368 (0xf636bca0)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Continuing
Media Recovery Waiting for thread 1 sequence 407

四、 一级备库与二级备库切换
切换前状态
A:一级备库 B:主库(指定了2个dest) C:二级备库
切换后状态
A:二级备库 B:一级备库 C:主库
4.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


ECMS ecmsdg2 PHYSICAL STANDBY MAXIMUM PERFORMANCE
TO PRIMARY READ ONLY WITH APPLY

4.2 一级备库切换成主库
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

4.3 二级备库日志
Thu Jun 06 12:37:34 2019
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
ALTER DATABASE SWITCHOVER TO PRIMARY (ecms)
Maximum wait for role transition is 15 minutes.
Switchover: Media recovery is still active
Role Change: Canceling MRP - no more redo to apply
Thu Jun 06 12:37:36 2019
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /u01/app/oracle/diag/rdbms/ecmsdg2/ecms/trace/ecms_mrp0_1553.trc:
ORA-16037: user requested cancel of managed recovery operation
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
MRP0: Background Media Recovery process shutdown (ecms)
Role Change: Canceled MRP
Killing 3 processes with pids 1600,1579,1581 (all RFS) in order to disallow current and future RFS connections. Requested by OS process 1483
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Thu Jun 06 12:37:38 2019
SMON: disabling cache recovery
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/ecmsdg2/ecms/trace/ecms_ora_1483.trc
SwitchOver after complete recovery through change 2471716
Online logfile pre-clearing operation disabled by switchover
Online log /u01/app/oracle/oradata/ecms/ECMSDG2/onlinelog/o1_mf_1_ghk2opl7_.log: Thread 1 Group 1 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG2/onlinelog/o1_mf_1_ghk2opnn_.log: Thread 1 Group 1 was previously cleared
Online log /u01/app/oracle/oradata/ecms/ECMSDG2/onlinelog/o1_mf_2_ghk2osvy_.log: Thread 1 Group 2 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG2/onlinelog/o1_mf_2_ghk2osxj_.log: Thread 1 Group 2 was previously cleared
Online log /u01/app/oracle/oradata/ecms/ECMSDG2/onlinelog/o1_mf_3_ghk2oxgq_.log: Thread 1 Group 3 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG2/onlinelog/o1_mf_3_ghk2oxj8_.log: Thread 1 Group 3 was previously cleared
Standby became primary SCN: 2471714
AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the parameter file.
Switchover: Complete - Database mounted as primary
Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
4.4 状态确认
SQL> /

NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE


SWITCHOVER_STATUS OPEN_MODE


ECMS ecmsdg2 PRIMARY MAXIMUM PERFORMANCE
SESSIONS ACTIVE READ WRITE

五、 主库与二级备库切换
切换前状态:
A:主库 B:一级备库 C:二级备库
切换后状态:
A:二级备库 B:一级备库 C:主库
5.1 切换准备
SYS@ecms>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


ECMS ecms PRIMARY MAXIMUM PERFORMANCE
TO STANDBY READ WRITE

5.2 主库切换成备库
SYS@ecms>alter database commit to switchover to physical standby WITH SESSION SHUTDOWN;
Database altered.
Elapsed: 00:00:05.71
5.3 二级备库状态检查
NAME DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE


SWITCHOVER_STATUS OPEN_MODE


ECMS ecmsdg2 PHYSICAL STANDBY MAXIMUM PERFORMANCE
TO PRIMARY READ ONLY WITH APPLY
5.4 二级备库切换成主库

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

Database altered.
5.5 二级备库切换成主库日志输出
Thu Jun 06 14:19:53 2019
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
ALTER DATABASE SWITCHOVER TO PRIMARY (ecms)
Maximum wait for role transition is 15 minutes.
Switchover: Media recovery is still active
Role Change: Canceling MRP - no more redo to apply
Thu Jun 06 14:19:55 2019
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /u01/app/oracle/diag/rdbms/ecmsdg2/ecms/trace/ecms_mrp0_2204.trc:
ORA-16037: user requested cancel of managed recovery operation
Recovery interrupted!
MRP0: Background Media Recovery process shutdown (ecms)
Role Change: Canceled MRP
Killing 3 processes with pids 2375,2369,2373 (all RFS) in order to disallow current and future RFS connections. Requested by OS process 2196
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Thu Jun 06 14:19:59 2019
SMON: disabling cache recovery
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/ecmsdg2/ecms/trace/ecms_ora_2196.trc
SwitchOver after complete recovery through change 2560371
Online logfile pre-clearing operation disabled by switchover
Online log /u01/app/oracle/oradata/ecms/ECMSDG2/onlinelog/o1_mf_1_ghk2opl7_.log: Thread 1 Group 1 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG2/onlinelog/o1_mf_1_ghk2opnn_.log: Thread 1 Group 1 was previously cleared
Online log /u01/app/oracle/oradata/ecms/ECMSDG2/onlinelog/o1_mf_2_ghk2osvy_.log: Thread 1 Group 2 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG2/onlinelog/o1_mf_2_ghk2osxj_.log: Thread 1 Group 2 was previously cleared
Online log /u01/app/oracle/oradata/ecms/ECMSDG2/onlinelog/o1_mf_3_ghk2oxgq_.log: Thread 1 Group 3 was previously cleared
Online log /u01/app/oracle/fast_recovery_area/ECMSDG2/onlinelog/o1_mf_3_ghk2oxj8_.log: Thread 1 Group 3 was previously cleared
Standby became primary SCN: 2560369
AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the parameter file.
Switchover: Complete - Database mounted as primary
Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
Thu Jun 06 14:20:05 2019
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
ALTER DATABASE SWITCHOVER TO PRIMARY (ecms)
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY (ecms)
ORA-1109 signalled during: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY…
Thu Jun 06 14:20:06 2019
RFS[11]: Assigned to RFS process 2381
RFS[11]: Database mount ID mismatch [0xf63740e4:0xf6372ed7] (4130816228:4130811607)
RFS[11]: Client instance is standby database instead of primary
RFS[11]: Not using real application clusters
Shutting down instance (immediate)
Shutting down instance: further logons disabled
Stopping background process MMNL
Thu Jun 06 14:20:16 2019
Stopping background process MMON
Thu Jun 06 14:20:17 2019
idle dispatcher ‘D000’ terminated, pid = (17, 1)
failed to start dispatcher for network ‘(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))’
License high water mark = 4
All dispatchers and shared servers shutdown
ALTER DATABASE CLOSE NORMAL
ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL…
ALTER DATABASE DISMOUNT
Shutting down archive processes
Archiving is disabled
Thu Jun 06 14:20:17 2019
ARCH shutting down
ARC3: Archival stopped
Thu Jun 06 14:20:17 2019
ARCH shutting down
ARC1: Archival stopped
Thu Jun 06 14:20:17 2019
ARCH shutting down
ARC0: Archival stopped
Thu Jun 06 14:20:17 2019
ARCH shutting down
ARC2: Relinquishing active heartbeat ARCH role
ARC2: Archival stopped
Completed: ALTER DATABASE DISMOUNT
ARCH: Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
Thu Jun 06 14:20:18 2019
Stopping background process VKTM
ARCH: Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
Thu Jun 06 14:20:21 2019
Instance shutdown complete
5.6 状态确认
主库
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


ECMS ecmsdg2 PRIMARY MAXIMUM PERFORMANCE
TO STANDBY READ WRITE

一级备库

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


ECMS ecmsdg1 PHYSICAL STANDBY MAXIMUM PERFORMANCE
NOT ALLOWED READ ONLY WITH APPLY

二级备库(原主库)

SYS@ecms> 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


ECMS ecms PHYSICAL STANDBY MAXIMUM PERFORMANCE
NOT ALLOWED READ ONLY WITH APPLY
Elapsed: 00:00:00.10
SYS@ecms>

六、 完成切换
6.1 当前状态
A:原主库 B:一级备库 C:二级备库
状态检查
A:状态(未配置dest_3所以一直是TO PRIMARY)
SYS@ecms> 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


ECMS ecms PHYSICAL STANDBY MAXIMUM PERFORMANCE
TO PRIMARY READ ONLY WITH APPLY

B:状态
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


ECMS ecmsdg1 PHYSICAL STANDBY MAXIMUM PERFORMANCE
NOT ALLOWED READ ONLY WITH APPLY

SQL>
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


ECMS ecmsdg2 PHYSICAL STANDBY MAXIMUM PERFORMANCE
NOT ALLOWED READ ONLY WITH APPLY

6.2 同步状态
一级备库(原主库)
SYS@ecms>/
PROCESS STATUS SEQUENCE#


ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CLOSING 430
ARCH OPENING 430
RFS IDLE 0
RFS IDLE 0
RFS IDLE 0
MRP0 WAIT_FOR_LOG 431

一级备库
SQL> /

PROCESS STATUS SEQUENCE#


ARCH CLOSING 429
ARCH CLOSING 429
ARCH CLOSING 426
ARCH CLOSING 430
RFS IDLE 0
RFS IDLE 431
RFS IDLE 0
RFS IDLE 0
RFS IDLE 0
MRP0 APPLYING_LOG 431
RFS IDLE 0

主库(原二级备库)
SQL> select max(sequence#),thread# from v$archived_log group by thread#;

MAX(SEQUENCE#) THREAD#


       430          1

6.3 参数配置
Oracle级联DG部署以及切换测试

上一篇:NodeJs实现下载Excel文件


下一篇:拍照返回的bitmap太小