概述:rac配置ADG方法无不同,只是在备库上需要将参数文件的群集参数删除改成单机的就行
[grid@11g-rac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.CRSDG.dg
ONLINE ONLINE 11g-rac1
ONLINE ONLINE 11g-rac2
ora.DATADG.dg
ONLINE ONLINE 11g-rac1
ONLINE ONLINE 11g-rac2
ora.LISTENER.lsnr
ONLINE ONLINE 11g-rac1
ONLINE ONLINE 11g-rac2
ora.asm
ONLINE ONLINE 11g-rac1 Started
ONLINE ONLINE 11g-rac2 Started
ora.gsd
OFFLINE OFFLINE 11g-rac1
OFFLINE OFFLINE 11g-rac2
ora.net1.network
ONLINE ONLINE 11g-rac1
ONLINE ONLINE 11g-rac2
ora.ons
ONLINE ONLINE 11g-rac1
ONLINE ONLINE 11g-rac2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.11g-rac1.vip
1 ONLINE ONLINE 11g-rac1
ora.11g-rac2.vip
1 ONLINE ONLINE 11g-rac2
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE 11g-rac1
ora.cube.db
1 ONLINE ONLINE 11g-rac1 Open
2 ONLINE ONLINE 11g-rac2 Open
ora.cvu
1 ONLINE ONLINE 11g-rac2
ora.oc4j
1 ONLINE ONLINE 11g-rac2
ora.scan1.vip
1 ONLINE ONLINE 11g-rac1
为主库添加standby redo日志:
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DATADG/cube/onlinelog/group_2.264.986815557
+DATADG/cube/onlinelog/group_2.265.986815557
+DATADG/cube/onlinelog/group_1.262.986815555
+DATADG/cube/onlinelog/group_1.263.986815555
+DATADG/cube/onlinelog/group_3.268.986815937
+DATADG/cube/onlinelog/group_3.269.986815937
+DATADG/cube/onlinelog/group_4.270.986815939
+DATADG/cube/onlinelog/group_4.271.986815939
8 rows selected.
SQL> select GROUP#,THREAD#,BYTES/1024/1024 M,status from v$log;
GROUP# THREAD# M STATUS
---------- ---------- ---------- ----------------
1 1 50 CURRENT
2 1 50 INACTIVE
3 2 50 CURRENT
4 2 50 INACTIVE
SQL> select GROUP#,THREAD#,BYTES/1024/1024 M,status,MEMBERS from v$log;
GROUP# THREAD# M STATUS MEMBERS
---------- ---------- ---------- ---------------- ----------
1 1 50 CURRENT 2
2 1 50 INACTIVE 2
3 2 50 CURRENT 2
4 2 50 INACTIVE 2
SQL> alter database add standby logfile thread 1 group 5 ('+DATADG/cube/onlinelog/standbyredo5.log') size 50M;
Database altered.
SQL> alter database add standby logfile thread 1 group 6 ('+DATADG/cube/onlinelog/standbyredo6.log') size 50M;
Database altered.
SQL> alter database add standby logfile thread 1 group 7 ('+DATADG/cube/onlinelog/standbyredo7.log') size 50M;
Database altered.
SQL> alter database add standby logfile thread 2 group 8 ('+DATADG/cube/onlinelog/standbyredo8.log') size 50M;
Database altered.
SQL> alter database add standby logfile thread 2 group 9 ('+DATADG/cube/onlinelog/standbyredo9.log') size 50M;
Database altered.
SQL> alter database add standby logfile thread 2 group 10 ('+DATADG/cube/onlinelog/standbyredo10.log') size 50M;
Database altered.
修改主库ADG相关参数:
ALTER SYSTEM SET DB_UNIQUE_NAME=cubep SCOPE=SPFILE sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(cubep,cubeadg)' SCOPE=SPFILE sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+DATADG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=cubep' SCOPE=SPFILE sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=cubeadg ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=cubeadg' SCOPE=SPFILE sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE SCOPE=SPFILE sid='*';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE SCOPE=SPFILE sid='*';
ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE sid='*';
ALTER SYSTEM SET FAL_SERVER=cubeadg SCOPE=SPFILE sid='*';
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/u01/ora/app/oradata/cube/','+DATADG/cube/datafile/' SCOPE=SPFILE sid='*';
ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/u01/ora/app/oradata/cube/','+DATADG/cube/onlinelog/' SCOPE=SPFILE sid='*';
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO SCOPE=SPFILE sid='*';
重启主库
备库初始化参数设置(删除群集相关参数,remote_listener参数是为VIP用的可以删除,另外注意要添加一个*.undo_tablespace参数):
[oracle@11g-adg dbs]$ cat initcube.ora
*.audit_file_dest='/u01/ora/app/oracle/admin/cube/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/ora/app/oradata/cube/control01.ctl','/u01/ora/app/oradata/cube/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='cube'
*.db_recovery_file_dest='/u01/ora/app/fast_recovery_area'
*.db_recovery_file_dest_size=4621074432
*.diagnostic_dest='/u01/ora/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=cubeXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=838860800
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=cubeadg
LOG_ARCHIVE_CONFIG='DG_CONFIG=(cubeadg,cubep)'
LOG_ARCHIVE_DEST_1=
'LOCATION=/u01/ora/app/fast_recovery_area
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=cubeadg'
LOG_ARCHIVE_DEST_2=
'SERVICE=cubep ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=cubep'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=cubep
DB_FILE_NAME_CONVERT=DB_FILE_NAME_CONVERT='+DATADG/cube/datafile/','/u01/ora/app/oradata/cube/','+DATADG/cube/tempfile/','/u01/ora/app/oradata/cube/'
LOG_FILE_NAME_CONVERT='+DATADG/cube/logfile/','/u01/ora/app/oradata/cube/'
STANDBY_FILE_MANAGEMENT=AUTO
建立对应目录
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 541068368 bytes
Database Buffers 289406976 bytes
Redo Buffers 2371584 bytes
SQL> create spfile from pfile;
File created.
SQL> startup nomount force;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 541068368 bytes
Database Buffers 289406976 bytes
Redo Buffers 2371584 bytes
SQL>
拷贝密码文件
[oracle@11g-rac1 dbs]$ scp orapwcube1 [email protected]:/u01/ora/app/product/11.2.0/dbs/orapwcube
配置tns并测试
[oracle@11g-adg admin]$ cat tnsnames.ora
cubep =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.20)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.22)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cubep)
)
)
cubeadg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cubeadg)
(UR=A)
)
)
[oracle@11g-adg admin]$ cat listener.ora
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=cubeadg)
(ORACLE_HOME=/u01/ora/app/product/11.2.0)
(SID_NAME=cube))
(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/u01/ora/app/product/11.2.0)
(PROGRAM=extproc)))
在主机中使用duplicate方式来恢复备库:
[oracle@11g-adg admin]$ rman target sys/windows@cubep auxiliary sys/windows@cubeadg
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Oct 16 09:47:04 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: CUBE (DBID=3170299392)
connected to auxiliary database: CUBE (not mounted)
RMAN> DUPLICATE TARGET DATABASE
2> FOR STANDBY
3> FROM ACTIVE DATABASE;
Starting Duplicate Db at 16-OCT-18
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK
contents of Memory Script:
{
backup as copy reuse
passwordfile auxiliary format '/u01/ora/app/product/11.2.0/dbs/orapwcube' ;
}
executing Memory Script
Starting backup at 16-OCT-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 instance=cube1 device type=DISK
Finished backup at 16-OCT-18
contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '/u01/ora/app/oradata/cube/control01.ctl';
restore clone primary controlfile to '/u01/ora/app/oradata/cube/control02.ctl' from
'/u01/ora/app/oradata/cube/control01.ctl';
}
executing Memory Script
Starting backup at 16-OCT-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.4/db_1/dbs/snapcf_cube1.f tag=TAG20181016T094710 RECID=2 STAMP=989660831
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 16-OCT-18
Starting restore at 16-OCT-18
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 16-OCT-18
contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/ora/app/oradata/cube/temp.266.986815563";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/ora/app/oradata/cube/system.256.986815411";
set newname for datafile 2 to
"/u01/ora/app/oradata/cube/sysaux.257.986815411";
set newname for datafile 3 to
"/u01/ora/app/oradata/cube/undotbs1.258.986815413";
set newname for datafile 4 to
"/u01/ora/app/oradata/cube/users.259.986815413";
set newname for datafile 5 to
"/u01/ora/app/oradata/cube/undotbs2.267.986815775";
backup as copy reuse
datafile 1 auxiliary format
"/u01/ora/app/oradata/cube/system.256.986815411" datafile
2 auxiliary format
"/u01/ora/app/oradata/cube/sysaux.257.986815411" datafile
3 auxiliary format
"/u01/ora/app/oradata/cube/undotbs1.258.986815413" datafile
4 auxiliary format
"/u01/ora/app/oradata/cube/users.259.986815413" datafile
5 auxiliary format
"/u01/ora/app/oradata/cube/undotbs2.267.986815775" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/ora/app/oradata/cube/temp.266.986815563 in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 16-OCT-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATADG/cube/datafile/system.256.986815411
output file name=/u01/ora/app/oradata/cube/system.256.986815411 tag=TAG20181016T094719
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATADG/cube/datafile/sysaux.257.986815411
output file name=/u01/ora/app/oradata/cube/sysaux.257.986815411 tag=TAG20181016T094719
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATADG/cube/datafile/undotbs1.258.986815413
output file name=/u01/ora/app/oradata/cube/undotbs1.258.986815413 tag=TAG20181016T094719
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATADG/cube/datafile/undotbs2.267.986815775
output file name=/u01/ora/app/oradata/cube/undotbs2.267.986815775 tag=TAG20181016T094719
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATADG/cube/datafile/users.259.986815413
output file name=/u01/ora/app/oradata/cube/users.259.986815413 tag=TAG20181016T094719
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 16-OCT-18
sql statement: alter system archive log current
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=989660880 file name=/u01/ora/app/oradata/cube/system.256.986815411
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=989660880 file name=/u01/ora/app/oradata/cube/sysaux.257.986815411
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=989660880 file name=/u01/ora/app/oradata/cube/undotbs1.258.986815413
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=989660880 file name=/u01/ora/app/oradata/cube/users.259.986815413
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=989660880 file name=/u01/ora/app/oradata/cube/undotbs2.267.986815775
Finished Duplicate Db at 16-OCT-18
备库开启日志应用并查看状态:
SQL> alter database recover managed standby database disconnect;
Database altered.
SQL> select open_mode,PROTECTION_LEVEL,DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
OPEN_MODE PROTECTION_LEVEL DATABASE_ROLE SWITCHOVER_STATUS
-------------------- -------------------- ---------------- --------------------
MOUNTED MAXIMUM PERFORMANCE PHYSICAL STANDBY NOT ALLOWED
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open;
Database altered.
SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.
SQL> select open_mode,PROTECTION_LEVEL,DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
OPEN_MODE PROTECTION_LEVEL DATABASE_ROLE SWITCHOVER_STATUS
-------------------- -------------------- ---------------- --------------------
READ ONLY WITH APPLY MAXIMUM PERFORMANCE PHYSICAL STANDBY NOT ALLOWED
RAC ADG搭建完成。