3.机器A操作 duplicate数据库到机器B
验证到机器B可以登录
$ sqlplus sys/oracle@jyzhao_s as sysdba
vi duplicate_dg.sql
duplicate target database
for standby
from active database
DORECOVER
spfile
set db_unique_name='jyzhao_s'
set log_archive_dest_1='location=/u01/app/oracle/product/11.2.0/db_1/dbs/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=jyzhao_s'
set log_archive_dest_2='SERVICE=jyzhao ASYNC LGWR
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jyzhao'
set standby_file_management='AUTO'
set fal_server='jyzhao'
set fal_client='jyzhao_s'
set control_files='+DATA1'
set memory_target='0'
set sga_target='600M';
[oracle@JY-DB ~]$ rman target / auxiliary sys/oracle@jyzhaos cmdfile=duplicate_standby.sql
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Mar 16 23:21:37 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: LINUXIDC (DBID=2463175424)
connected to auxiliary database: LINUXIDC (not mounted)
RMAN> duplicate target database
2> for standby
3> from active database
4> DORECOVER
5> spfile
6> set db_unique_name='jyzhao_s'
7> set log_archive_dest_1='location=/u01/app/oracle/product/11.2.0/db_1/dbs/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
8> DB_UNIQUE_NAME=jyzhao_s'
9> set log_archive_dest_2='SERVICE=MACDBN ASYNC LGWR
10> VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jyzhao'
11> set standby_file_management='AUTO'
12> set fal_server='jyzhao'
13> set fal_client='jyzhao_s'
14> set control_files='+DATA1'
15> set memory_target='0'
16> set sga_target='600M';
17>
Starting Duplicate Db at 16-MAR-15
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=111 device type=DISK
……
Recovery Manager complete.
[oracle@JY-DB ~]$
4. B机器 srvctl add数据库jyzhao_s
注:开始_s有问题,是因为添加指定的参数不足:
srvctl add database -d jyzhao_s -o /u01/app/oracle/product/11.2.0/db_1 -p +DATA1/LINUXIDC_S/spfilejyzhao_s.ora -n jyzhao -i jyzhao_s
srvctl modify database -d jyzhao_s -r PHYSICAL_STANDBY
三、DG切换测试
3.1 手动switchover
1主库切换成standby,启动到mount
select OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS from v$database;
alter database commit to switchover to physical standby;
2.备份切换成primary,启动到open
select OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS from v$database;
alter database commit to switchover to primary;
3.新的备份执行日志应用
alter database recover managed standby database using current logfile disconnect from session;
3.2 Data Guard Broker 快速switchover
SQL> show parameter dg_broker_start
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start boolean FALSE
SQL> alter system set dg_broker_start = true;
System altered.
SQL> show parameter dg_broker_start
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start boolean TRUE
配置dgmgrl