目錄
一、準備工作
1.1、在生產與災備上設備所有的hosts表
[root@rac19c1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.33.21 rac19c1
192.168.33.23 rac19c2
192.168.33.22 rac19c1-vip
192.168.33.24 rac19c2-vip
192.168.33.25 rac19c-scan
19.21.68.21 rac19c1-priv
19.21.68.23 rac19c2-priv
192.168.33.26 oracle19c
1.2、生產機設備參數
alter database force logging;
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,std)' scope=both sid='*';
alter system set log_archive_dest_1='LOCATION=+DATADG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl' scope=spfile;
alter system set LOG_ARCHIVE_DEST_2='SERVICE=std LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=std' scope=both sid='*';
alter system set fal_client='orcl' scope=both sid='*';
alter system set FAL_SERVER='std' scope=both sid='*';
alter system set standby_file_management=AUTO scope=both sid='*';
alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl','+DATADG/orcl/datafile','/u01/app/oracle/oradata/orcl','+DATADG/orcl/tempfile' scope=spfile sid='*';
alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl','+DATADG/orcl/onlinelog' scope=spfile sid='*';
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set remote_login_passwordfile='EXCLUSIVE' scope=spfile;
alter system set PARALLEL_EXECUTION_MESSAGE_SIZE=8192 scope=spfile;
重啓數據庫,將之前的參數生效
srvctl stop database -db orcl
srvctl start database -db orcl
1.3、主庫增加standby logfile日誌組
SQL> select bytes/1024/1024 mb from v$log;
MB
----------
50
50
50
50
alter database add standby logfile thread 1 group 11 '+datadg' size 200m;
alter database add standby logfile thread 1 group 12 '+datadg' size 200m;
alter database add standby logfile thread 1 group 13 '+datadg' size 200m;
alter database add standby logfile thread 2 group 14 '+datadg' size 200m;
alter database add standby logfile thread 2 group 15 '+datadg' size 200m;
alter database add standby logfile thread 2 group 15 '+datadg' size 200m;
1.4、主庫上配置tnsnames
如下內容
cat >>/u01/app/oracle/product/19.0.0/db_1/network/admin/tnsnames.ora<<EOF
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac19c-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
std =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle19c)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = std)
)
)
EOF
1.5、備庫上添加tnsnames
cat >>tnsnames.ora<<EOF
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac19c-scan)(PORT = 1521))
(LOAD_BALANCE = yes)
(FAILOVER = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
std =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle19c)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = std)
)
)
EOF
1.6、叢主庫上覆制密碼文件與參數文件
ASMCMD> pwd
+datadg/orcl/password
ASMCMD> cp pwdorcl.256.1038468067 /tmp/orapwstd
copying +datadg/orcl/password/pwdorcl.256.1038468067 -> /tmp/orapwstd
ASMCMD> exit
SQL> create pfile='/tmp/pfile.ora' from spfile;
mv orapwstd orapworcl
mv pfile.ora initorcl.ora
scp orapworcl oracle19c:/u01/app/oracle/product/19.0.0.0/db/dbs/.
scp initorcl.ora oracle19c:/u01/app/oracle/product/19.0.0.0/db/dbs/.
1.7、將參數文件進行修改,如下配置。
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='19.0.0'
*.control_files='/u01/app/oracle/oradata/orcl/current.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/orcl'
*.db_name='orcl'
*.diagnostic_dest='/u01/app/oracle'
*.db_unique_name='std'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.fal_client='std'
*.fal_server='orcl'
*.log_archive_config='DG_CONFIG=(std,orcl)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/u01/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=std'
*.LOG_ARCHIVE_DEST_2='SERVICE=orcl LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl'
*.log_archive_format='%t_%s_%r.arc'
*.log_file_name_convert='+DATADG/orcl/onlinelog','/u01/app/oracle/oradata/orcl'
*.db_file_name_convert='+DATADG/orcl/datafile','/u01/app/oracle/oradata/orcl'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.parallel_execution_message_size=8192
*.pga_aggregate_target=1006m
*.processes=320
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=3018m
*.standby_file_management='AUTO'
1.8、配置災備庫的監聽
[oracle@oracle19c admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.0.0.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/19.0.0.0/db)
(SID_NAME = orcl)
(GLOBAL_DBNAME = std)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle19c)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
LSNRCTL> stat
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle19c)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 27-APR-2020 06:41:42
Uptime 0 days 0 hr. 0 min. 6 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.0.0.0/db/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/oracle19c/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle19c)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "std" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
二、同步備庫
2.1、啓動災備庫至mount狀態
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 3170890656 bytes
Fixed Size 8901536 bytes
Variable Size 771751936 bytes
Database Buffers 2382364672 bytes
Redo Buffers 7872512 bytes
SQL>
2.2、使用rman進行 auxiliary克隆
rman target sys/Oracle123@orcl auxiliary sys/Oracle123@std
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
allocate channel c6 type disk;
allocate AUXILIARY channel c7 type disk;
allocate AUXILIARY channel c8 type disk;
allocate AUXILIARY channel c9 type disk;
allocate AUXILIARY channel c10 type disk;
allocate AUXILIARY channel c11 type disk;
allocate AUXILIARY channel c12 type disk;
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;
release channel c9;
release channel c10;
release channel c11;
release channel c12;
}
日誌
[oracle@rac19c1 ~]$ rman target sys/Oracle123@orcl auxiliary sys/Oracle123@std
Recovery Manager: Release 19.0.0.0.0 - Production on Mon Apr 27 07:09:09 2020
Version 19.2.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1566248944)
connected to auxiliary database: ORCL (not mounted)
RMAN> run
2> {
3> allocate channel c1 type disk;
4> allocate channel c2 type disk;
5> allocate channel c3 type disk;
6> allocate channel c4 type disk;
7> allocate channel c5 type disk;
8> allocate channel c6 type disk;
9> allocate AUXILIARY channel c7 type disk;
10> allocate AUXILIARY channel c8 type disk;
11> allocate AUXILIARY channel c9 type disk;
12> allocate AUXILIARY channel c10 type disk;
13> allocate AUXILIARY channel c11 type disk;
14> allocate AUXILIARY channel c12 type disk;
15> DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK;
16> release channel c1;
17> release channel c2;
18> release channel c3;
19> release channel c4;
20> release channel c5;
21> release channel c6;
22> release channel c7;
23> release channel c8;
24> release channel c9;
25> release channel c10;
26> release channel c11;
27> release channel c12;
28> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=282 instance=orcl1 device type=DISK
allocated channel: c2
channel c2: SID=405 instance=orcl1 device type=DISK
allocated channel: c3
channel c3: SID=31 instance=orcl1 device type=DISK
allocated channel: c4
channel c4: SID=151 instance=orcl1 device type=DISK
allocated channel: c5
channel c5: SID=281 instance=orcl1 device type=DISK
allocated channel: c6
channel c6: SID=404 instance=orcl1 device type=DISK
allocated channel: c7
channel c7: SID=442 device type=DISK
allocated channel: c8
channel c8: SID=6 device type=DISK
allocated channel: c9
channel c9: SID=68 device type=DISK
allocated channel: c10
channel c10: SID=131 device type=DISK
allocated channel: c11
channel c11: SID=196 device type=DISK
allocated channel: c12
channel c12: SID=259 device type=DISK
Starting Duplicate Db at 27-APR-20
current log archived
contents of Memory Script:
{
backup as copy reuse
passwordfile auxiliary format '/u01/app/oracle/product/19.0.0.0/db/dbs/orapworcl' ;
}
executing Memory Script
Starting backup at 27-APR-20
Finished backup at 27-APR-20
contents of Memory Script:
{
restore clone from service 'orcl' standby controlfile;
}
executing Memory Script
Starting restore at 27-APR-20
channel c7: starting datafile backup set restore
channel c7: using network backup set from service orcl
channel c7: restoring control file
channel c7: restore complete, elapsed time: 00:00:02
output file name=/u01/app/oracle/oradata/orcl/current.ctl
Finished restore at 27-APR-20
contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
RMAN-05158: WARNING: auxiliary (tempfile) file name +DATADG/ORCL/TEMPFILE/temp.266.1038468231 conflicts with a file used by the target database
RMAN-05529: warning: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.
contents of Memory Script:
{
set newname for tempfile 1 to
"+DATADG";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/orcl/system.257.1038468083";
set newname for datafile 3 to
"/u01/app/oracle/oradata/orcl/sysaux.258.1038468117";
set newname for datafile 4 to
"/u01/app/oracle/oradata/orcl/undotbs1.259.1038468143";
set newname for datafile 5 to
"/u01/app/oracle/oradata/orcl/undotbs2.271.1038468285";
set newname for datafile 7 to
"/u01/app/oracle/oradata/orcl/users.260.1038468143";
restore
from nonsparse from service
'orcl' clone database
;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to +DATADG in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 27-APR-20
channel c7: starting datafile backup set restore
channel c7: using network backup set from service orcl
channel c7: specifying datafile(s) to restore from backup set
channel c7: restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system.257.1038468083
channel c8: starting datafile backup set restore
channel c8: using network backup set from service orcl
channel c8: specifying datafile(s) to restore from backup set
channel c8: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux.258.1038468117
channel c9: starting datafile backup set restore
channel c9: using network backup set from service orcl
channel c9: specifying datafile(s) to restore from backup set
channel c9: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/undotbs1.259.1038468143
channel c10: starting datafile backup set restore
channel c10: using network backup set from service orcl
channel c10: specifying datafile(s) to restore from backup set
channel c10: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/undotbs2.271.1038468285
channel c11: starting datafile backup set restore
channel c11: using network backup set from service orcl
channel c11: specifying datafile(s) to restore from backup set
channel c11: restoring datafile 00007 to /u01/app/oracle/oradata/orcl/users.260.1038468143
channel c7: restore complete, elapsed time: 00:00:31
channel c9: restore complete, elapsed time: 00:00:30
channel c8: restore complete, elapsed time: 00:00:39
channel c10: restore complete, elapsed time: 00:00:34
channel c11: restore complete, elapsed time: 00:00:31
Finished restore at 27-APR-20
sql statement: alter system archive log current
current log archived
contents of Memory Script:
{
restore clone force from service 'orcl'
archivelog from scn 2141209;
switch clone datafile all;
}
executing Memory Script
Starting restore at 27-APR-20
channel c7: starting archived log restore to default destination
channel c7: using network backup set from service orcl
channel c7: restoring archived log
archived log thread=1 sequence=18
channel c8: starting archived log restore to default destination
channel c8: using network backup set from service orcl
channel c8: restoring archived log
archived log thread=1 sequence=19
channel c7: restore complete, elapsed time: 00:00:01
channel c8: restore complete, elapsed time: 00:00:01
Finished restore at 27-APR-20
datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=1038813030 file name=/u01/app/oracle/oradata/orcl/system.257.1038468083
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1038813030 file name=/u01/app/oracle/oradata/orcl/sysaux.258.1038468117
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1038813030 file name=/u01/app/oracle/oradata/orcl/undotbs1.259.1038468143
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=1038813030 file name=/u01/app/oracle/oradata/orcl/undotbs2.271.1038468285
datafile 7 switched to datafile copy
input datafile copy RECID=5 STAMP=1038813030 file name=/u01/app/oracle/oradata/orcl/users.260.1038468143
contents of Memory Script:
{
set until scn 2141415;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 27-APR-20
starting media recovery
archived log for thread 1 with sequence 18 is already on disk as file /u01/arch1_18_1038468214.arc
archived log for thread 1 with sequence 19 is already on disk as file /u01/arch1_19_1038468214.arc
archived log file name=/u01/arch1_18_1038468214.arc thread=1 sequence=18
archived log file name=/u01/arch1_19_1038468214.arc thread=1 sequence=19
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-APR-20
contents of Memory Script:
{
delete clone force archivelog all;
}
executing Memory Script
deleted archived log
archived log file name=/u01/arch1_18_1038468214.arc RECID=1 STAMP=1038813029
Deleted 1 objects
deleted archived log
archived log file name=/u01/arch1_19_1038468214.arc RECID=2 STAMP=1038813029
Deleted 1 objects
Finished Duplicate Db at 27-APR-20
released channel: c1
released channel: c2
released channel: c3
released channel: c4
released channel: c5
released channel: c6
released channel: c7
released channel: c8
released channel: c9
released channel: c10
released channel: c11
released channel: c12
RMAN>
2.3、備庫上開啓應用
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
SQL> alter database open;
Database altered.
SQL> alter database recover managed standby database disconnect;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL>
SQL> select process,client_process,sequence#, THREAD# ,status from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# ??STATUS
--------- -------- ---------- ----------
DGRD N/A 0 0
DGRD N/A 0 0
ARCH ARCH 13 1
ARCH ARCH 19 1
ARCH ARCH 17 1
ARCH ARCH 0 0
LNS LNS 14 1
DGRD N/A 0 0
LNS LNS 18 1
9 rows selected.
SQL>
SQL> select database_role,protection_mode,protection_level,open_mode from v$database;
DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL OPEN_MODE
---------------- -------------------- -------------------- --------------------
PHYSICAL STANDBY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE READ ONLY WITH APPLY
SQL>
SQL> select dest_name,status,error from v$archive_dest
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
LOG_ARCHIVE_DEST_3 INACTIVE
LOG_ARCHIVE_DEST_4 INACTIVE
LOG_ARCHIVE_DEST_5 INACTIVE
LOG_ARCHIVE_DEST_6 INACTIVE
LOG_ARCHIVE_DEST_7 INACTIVE
LOG_ARCHIVE_DEST_8 INACTIVE
LOG_ARCHIVE_DEST_9 INACTIVE
LOG_ARCHIVE_DEST_10 INACTIVE
LOG_ARCHIVE_DEST_11 INACTIVE
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_12 INACTIVE
LOG_ARCHIVE_DEST_13 INACTIVE
LOG_ARCHIVE_DEST_14 INACTIVE
LOG_ARCHIVE_DEST_15 INACTIVE
LOG_ARCHIVE_DEST_16 INACTIVE
LOG_ARCHIVE_DEST_17 INACTIVE
LOG_ARCHIVE_DEST_18 INACTIVE
LOG_ARCHIVE_DEST_19 INACTIVE
LOG_ARCHIVE_DEST_20 INACTIVE
LOG_ARCHIVE_DEST_21 INACTIVE
LOG_ARCHIVE_DEST_22 INACTIVE
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_23 INACTIVE
LOG_ARCHIVE_DEST_24 INACTIVE
LOG_ARCHIVE_DEST_25 INACTIVE
LOG_ARCHIVE_DEST_26 INACTIVE
LOG_ARCHIVE_DEST_27 INACTIVE
LOG_ARCHIVE_DEST_28 INACTIVE
LOG_ARCHIVE_DEST_29 INACTIVE
LOG_ARCHIVE_DEST_30 INACTIVE
LOG_ARCHIVE_DEST_31 INACTIVE
STANDBY_ARCHIVE_DEST VALID
32 rows selected.
SQL>
2.4、生產庫上檢查
SQL> select process,client_process,sequence#, THREAD# ,status from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# ??STATUS
--------- -------- ---------- ----------
DGRD N/A 0 0
DGRD N/A 0 0
ARCH ARCH 13 1
ARCH ARCH 19 1
ARCH ARCH 17 1
ARCH ARCH 0 0
LNS LNS 14 1
DGRD N/A 0 0
LNS LNS 18 1
9 rows selected.
SQL>
三、測試
3.1、ADG做(switchover)切換測試
SQL> alter database commit to switchover to physical standby;
Database altered.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 3170890656 bytes
Fixed Size 8901536 bytes
Variable Size 838860800 bytes
Database Buffers 2315255808 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY TO PRIMARY
SQL> select process,client_process,sequence#, THREAD# ,status from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# ??STATUS
--------- -------- ---------- ----------
DGRD N/A 0 0
DGRD N/A 0 0
ARCH ARCH 13 1
ARCH ARCH 19 1
ARCH ARCH 17 1
ARCH ARCH 0 0
LNS LNS 14 1
DGRD N/A 0 0
LNS LNS 18 1
9 rows selected.
SQL> select open_mode from v$database;
select open_mode from v$database
*
ERROR at line 1:
ORA-03135: connection lost contact
Process ID: 102062
Session ID: 281 Serial number: 58995
SQL> conn / as sysdba
Connected.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL> select process,client_process,sequence#, THREAD# ,status from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# ??STATUS
--------- -------- ---------- ----------
ARCH ARCH 0 0
DGRD N/A 0 0
DGRD N/A 0 0
ARCH ARCH 0 0
ARCH ARCH 21 1
ARCH ARCH 0 0
MRP0 N/A 22 1
RFS LGWR 22 1
RFS UNKNOWN 0 0
RFS Archival 0 1
10 rows selected.
SQL> run
1* select dest_name,status,error from v$archive_dest
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
LOG_ARCHIVE_DEST_3 INACTIVE
LOG_ARCHIVE_DEST_4 INACTIVE
LOG_ARCHIVE_DEST_5 INACTIVE
LOG_ARCHIVE_DEST_6 INACTIVE
LOG_ARCHIVE_DEST_7 INACTIVE
LOG_ARCHIVE_DEST_8 INACTIVE
LOG_ARCHIVE_DEST_9 INACTIVE
LOG_ARCHIVE_DEST_10 INACTIVE
LOG_ARCHIVE_DEST_11 INACTIVE
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_12 INACTIVE
LOG_ARCHIVE_DEST_13 INACTIVE
LOG_ARCHIVE_DEST_14 INACTIVE
LOG_ARCHIVE_DEST_15 INACTIVE
LOG_ARCHIVE_DEST_16 INACTIVE
LOG_ARCHIVE_DEST_17 INACTIVE
LOG_ARCHIVE_DEST_18 INACTIVE
LOG_ARCHIVE_DEST_19 INACTIVE
LOG_ARCHIVE_DEST_20 INACTIVE
LOG_ARCHIVE_DEST_21 INACTIVE
LOG_ARCHIVE_DEST_22 INACTIVE
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_23 INACTIVE
LOG_ARCHIVE_DEST_24 INACTIVE
LOG_ARCHIVE_DEST_25 INACTIVE
LOG_ARCHIVE_DEST_26 INACTIVE
LOG_ARCHIVE_DEST_27 INACTIVE
LOG_ARCHIVE_DEST_28 INACTIVE
LOG_ARCHIVE_DEST_29 INACTIVE
LOG_ARCHIVE_DEST_30 INACTIVE
LOG_ARCHIVE_DEST_31 INACTIVE
STANDBY_ARCHIVE_DEST VALID
32 rows selected.
SQL>
在備庫上執行啓用
SQL> alter database commit to switchover to primary;
Database altered.
SQL> conn / as sysdba
Connected.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY NOT ALLOWED
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 3170890656 bytes
Fixed Size 8901536 bytes
Variable Size 771751936 bytes
Database Buffers 2382364672 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY TO STANDBY
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> select process,client_process,sequence#, THREAD# ,status from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# ??STATUS
--------- -------- ---------- ----------
ARCH ARCH 21 1
DGRD N/A 0 0
DGRD N/A 0 0
LNS LNS 22 1
DGRD N/A 0 0
ARCH ARCH 0 0
ARCH ARCH 21 1
ARCH ARCH 0 0
8 rows selected.
SQL> select dest_name,status,error from v$archive_dest
2 ;
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
LOG_ARCHIVE_DEST_3 INACTIVE
LOG_ARCHIVE_DEST_4 INACTIVE
LOG_ARCHIVE_DEST_5 INACTIVE
LOG_ARCHIVE_DEST_6 INACTIVE
LOG_ARCHIVE_DEST_7 INACTIVE
LOG_ARCHIVE_DEST_8 INACTIVE
LOG_ARCHIVE_DEST_9 INACTIVE
LOG_ARCHIVE_DEST_10 INACTIVE
LOG_ARCHIVE_DEST_11 INACTIVE
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_12 INACTIVE
LOG_ARCHIVE_DEST_13 INACTIVE
LOG_ARCHIVE_DEST_14 INACTIVE
LOG_ARCHIVE_DEST_15 INACTIVE
LOG_ARCHIVE_DEST_16 INACTIVE
LOG_ARCHIVE_DEST_17 INACTIVE
LOG_ARCHIVE_DEST_18 INACTIVE
LOG_ARCHIVE_DEST_19 INACTIVE
LOG_ARCHIVE_DEST_20 INACTIVE
LOG_ARCHIVE_DEST_21 INACTIVE
LOG_ARCHIVE_DEST_22 INACTIVE
DEST_NAME STATUS ERROR
------------------------------ --------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_23 INACTIVE
LOG_ARCHIVE_DEST_24 INACTIVE
LOG_ARCHIVE_DEST_25 INACTIVE
LOG_ARCHIVE_DEST_26 INACTIVE
LOG_ARCHIVE_DEST_27 INACTIVE
LOG_ARCHIVE_DEST_28 INACTIVE
LOG_ARCHIVE_DEST_29 INACTIVE
LOG_ARCHIVE_DEST_30 INACTIVE
LOG_ARCHIVE_DEST_31 INACTIVE
31 rows selected.
SQL>
3.2、ADG做(fail over)切換測試
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1188511744 bytes
Fixed Size 1364228 bytes
Variable Size 754978556 bytes
Database Buffers 419430400 bytes
Redo Buffers 12738560 bytes
Database mounted.
SQL> alter system flush redo to 'orcl';
System altered.
SQL> select thread#, low_sequence#, high_sequence# from v$archive_gap;
no rows selected
--如果沒有發現明顯的gap現象,說明此次的failover不會有數據損失情況。在standby端,要進行關閉apply和結束應用動作。
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database recover managed standby database finish;
Database altered
SQL> select open_mode, switchover_status from v$database;
OPEN_MODE SWITCHOVER_STATUS
-------------------- --------------------
READ ONLY TO PRIMARY