数据库
首页 > 数据库> > Oracle ADG方式 搭建 DG

Oracle ADG方式 搭建 DG

作者:互联网

1.环境说明

vbox 准备两个虚拟机,Linux 环境 OracleLinux x86.64-dvd,一个虚拟机已经搭建好库,一个虚拟机装好数据库软件,两个虚拟机要能相互ping 通,实例名都是orcl(实例名区分大小写)。

主库数据库版本


SQL> select * from v$version; 

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE	11.2.0.4.0	Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

主库:192.168.56.67

备库:192.168.56.68

2 主库设置为 force logging 模式 

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 1043886080 bytes
Fixed Size		 2259840 bytes
Variable Size		 889193600 bytes
Database Buffers	 146800640 bytes
Redo Buffers		 5632000 bytes
Database mounted.
SQL> alter database force logging;

Database altered.

SQL> select force_logging from v$database; 

FOR
---
YES

--取消force logging命令

SQL> alter database no force logging;

Database altered.

SQL> select force_logging from v$database;

FOR
---
NO

3 修改主库为归档模式

--创建归档目录并赋权限

[root@localhost ~]# mkdir /u01/archive
[root@localhost ~]# chown oracle:oinstall /u01/archive

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 1043886080 bytes
Fixed Size		 2259840 bytes
Variable Size		 889193600 bytes
Database Buffers	 146800640 bytes
Redo Buffers		 5632000 bytes
Database mounted.
SQL> archive log list
Database log mode	 No Archive Mode
Automatic archival	 Disabled
Archive destination	 USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 5
Current log sequence	 7
SQL> alter database archivelog;
Database altered.
SQL> alter system set log_archive_dest_1='location=/u01/archive/' scope=spfile;
System altered.
SQL> archive log list
Database log mode	 Archive Mode
Automatic archival	 Enabled
Archive destination	 USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 5
Next log sequence to archive 7
Current log sequence	 7
4 添加主库的 standby redo log
主库添加 standby redo log:大小和 online redo 相同,比 online redo group 多一组。

 

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/u01/app/oracle/oradata/orcl/redo04.log') size 50M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/u01/app/oracle/oradata/orcl/redo05.log') size 50M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/u01/app/oracle/oradata/orcl/redo06.log') size 50M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/u01/app/oracle/oradata/orcl/redo07.log') size 50M;

Database altered.

SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;

 GROUP# SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
	 1	 7		 50 CURRENT
	 3	 6		 50 INACTIVE
	 2	 5		 50 INACTIVE

SQL> col member for a50 
SQL> select group#,type, member from v$logfile;

 GROUP# TYPE MEMBER
---------- ------- --------------------------------------------------
	 3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log
	 2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log
	 1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log
	 4 STANDBY /u01/app/oracle/oradata/orcl/redo04.log
	 5 STANDBY /u01/app/oracle/oradata/orcl/redo05.log
	 6 STANDBY /u01/app/oracle/oradata/orcl/redo06.log
	 7 STANDBY /u01/app/oracle/oradata/orcl/redo07.log

7 rows selected.

5 在主备库分别创建 Listener 并配置静态注册

使用 netca 命令创建监听,netmgr 命令配置静态注册

--主库192.168.56.67监听

[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
 (SID_LIST =
 (SID_DESC =
 (GLOBAL_DBNAME = orcl)
 (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
 (SID_NAME = orcl)
 )
 )
LISTENER =
 (DESCRIPTION_LIST =
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
 )
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
 )
 )
ADR_BASE_LISTENER = /u01/app/oracle

--备库192.168.56.68监听

[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
 (SID_LIST =
 (SID_DESC =
 (GLOBAL_DBNAME = orcl)
 (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
 (SID_NAME = orcl)
 )
 )

LISTENER =
 (DESCRIPTION_LIST =
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
 )
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
 )
 )

ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER 部分的内容就是静态注册,如果没有该参数,而且 Data Guard 启动顺序又不正确,
那么在 主库可能会报 PING[ARC1]: Heartbeat failed to connect to standby 'orcl_st'. Error is 12512. 错误,导致归档无法完成。

6 在主备库添加 Oracle Net Service

特别说明一下在备库没有安装数据库的时候/u01/app/oracle/product/11.2.0/db_1/network/admin 目录下没有tnsnames.ora 文件

此时需要手工建netmgr 创建

 

--在主备库添加一下内容

[oracle@localhost admin]$ ls
listener1704192PM0644.bak samples tnsnames1704192PM0644.bak
listener.ora shrept.lst tnsnames.ora
 

ORCL_PD = 
 (DESCRIPTION = 
 (ADDRESS_LIST = 
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.67)(PORT = 1521)) 
 ) 
 (CONNECT_DATA = 
 (SERVICE_NAME = orcl) 
 ) 
 ) 

ORCL_ST = 
 (DESCRIPTION = 
 (ADDRESS_LIST = 
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.68)(PORT = 1521)) 
 ) 
 (CONNECT_DATA = 
 (SERVICE_NAME = orcl) 
 ) 
 ) 

 
[oracle@localhost admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
 (CONNECT_DATA =
 (SERVER = DEDICATED)
 (SERVICE_NAME = orcl)
 )
 )
ORCL_PD = 
 (DESCRIPTION = 
 (ADDRESS_LIST = 
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.67)(PORT = 1521)) 
 ) 
 (CONNECT_DATA = 
 (SERVICE_NAME = orcl) 
 ) 
 ) 

ORCL_ST = 
 (DESCRIPTION = 
 (ADDRESS_LIST = 
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.68)(PORT = 1521)) 
 ) 
 (CONNECT_DATA = 
 (SERVICE_NAME = orcl) 
 ) 
 ) 

配置完成后,使用 tnsping 命令效验: 

[oracle@localhost admin]$ tnsping orcl_pd

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 19-APR-2017 15:56:15

Copyright (c) 1997, 2013, Oracle. All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.67)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (0 msec)
[oracle@localhost admin]$ tnsping orcl_st

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 19-APR-2017 15:56:18

Copyright (c) 1997, 2013, Oracle. All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.68)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
TNS-12543: TNS:destination host unreachable

机器的防火墙已开启,但没有开放该1521端口

解决办法:

vi /etc/sysconfig/iptables

添加一行

-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT

重启防火墙

[root@localhost ~]# /etc/init.d/iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[root@localhost ~]# 

在执行tnsping 

[oracle@localhost admin]$ tnsping orcl_pd

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 19-APR-2017 16:01:13

Copyright (c) 1997, 2013, Oracle. All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.67)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (0 msec)
[oracle@localhost admin]$ tnsping orcl_st

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 19-APR-2017 16:01:15

Copyright (c) 1997, 2013, Oracle. All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.68)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (10 msec)


7 在备库创建相关的目录

因为我们的备库没有创建实例,所以是没有相关的目录的,我们需要参考主库的位置来创建。

[oracle@localhost oracle]$ pwd /u01/app/oracle [oracle@localhost oracle]$ ls admin checkpoints fast_recovery_area product cfgtoollogs diag oradata

--FRA目录

[oracle@localhost orcl]$ pwd
/u01/app/oracle/fast_recovery_area/orcl

--DATAFILE 

[oracle@localhost orcl]$ pwd
/u01/app/oracle/oradata/orcl

[oracle@localhost orcl]$ pwd
/u01/app/oracle/admin/orcl

8 在主库创建 pfile 文件并修改 pfile 内容
 

SQL> create pfile from spfile;

File created.
修改pfile

orcl.__db_cache_size=146800640
orcl.__java_pool_size=4194304
orcl.__large_pool_size=587202560
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=25165824
orcl.__sga_target=1023410176
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=272629760
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/fast_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.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=orclXDB)'
*.log_archive_dest_1='location=/u01/archive/'
*.memory_target=1048576000
*.open_cursors=300
*.processes=1500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1655
*.undo_tablespace='UNDOTBS1'
#添加一下内容
*.db_unique_name=orcl_pd 
*.log_archive_config='dg_config=(orcl_pd,orcl_st)' 
*.log_archive_dest_1='location=/u01/archive valid_for=(all_logfiles,all_roles) db_unique_name=orcl_pd' 
*.log_archive_dest_2='service=orcl_st valid_for=(online_logfiles,primary_role) db_unique_name=orcl_st' 
*.log_archive_dest_state_1=enable 
*.log_archive_dest_state_2=enable 
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE 
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc 
*.standby_file_management='auto' 
*.fal_server='orcl_st' 
*.log_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl'
*.db_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl'
--注意这 2 个参数。这个 2 个参数,只在数据库为 standby_role 时才生效,但我们在主库还是配置这 2 个参数, 
就是为了减少以后做 switchover 的时间。 注意 2 个目录的结构。 前面是发送数据的,后面的接收数据的。 

用pfile启动主库,并创建spfile


 
SQL> startup nomount ORA-00845: MEMORY_TARGET not supported on this system SQL> startup nomount pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora' ORACLE instance started. Total System Global Area 1043886080 bytes Fixed Size 2259840 bytes Variable Size 889193600 bytes Database Buffers 146800640 bytes Redo Buffers 5632000 bytes SQL> create spfile from pfile;  SP2-0734: unknown command beginning "create sp..." - rest of line ignored. SQL> create spfile from pfile; File created.

9 将主库的口令文件,参数文件 copy 到备库并修改 

[oracle@localhost dbs]$ scp initorcl.ora 192.168.56.68:/u01/app/oracle/product/11.2.0/db_1/dbs
oracle@192.168.56.68's password: 
initorcl.ora 100% 1672 1.6KB/s 00:00 
[oracle@localhost dbs]$ scp orapworcl 192.168.56.68:/u01/app/oracle/product/11.2.0/db_1/dbs
oracle@192.168.56.68's password: 
orapworcl 100% 1536 1.5KB/s 00:00 

--修改备库pfile

[oracle@localhost dbs]$ cat initorcl.ora 
orcl.__db_cache_size=146800640
orcl.__java_pool_size=4194304
orcl.__large_pool_size=587202560
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=25165824
orcl.__sga_target=1023410176
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=272629760
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/fast_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.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=orclXDB)'
*.log_archive_dest_1='location=/u01/archive/'
*.memory_target=1048576000
*.open_cursors=300
*.processes=1500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1655
*.undo_tablespace='UNDOTBS1'

#添加一下内容
*.db_unique_name=orcl_st 
*.log_archive_config='dg_config=(orcl_pd,orcl_st)' 
*.log_archive_dest_1='location=/u01/archive valid_for=(all_logfiles,all_roles) db_unique_name=orcl_st' 
*.log_archive_dest_2='service=orcl_pd valid_for=(online_logfiles,primary_role) db_unique_name=orcl_pd' 
*.log_archive_dest_state_1=enable 
*.log_archive_dest_state_2=enable 
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE 
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc 
*.standby_file_management='auto' 
*.fal_server='orcl_pd' 
*.log_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl'
*.db_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl'

10 用 spfile 将备库启动到 nomount 状态 

SQL> conn /as sysdba
ERROR:
ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9925
ORA-01075: you are currently logged on

检查原因原来是 /u01/app/oracle/admin/orcl 目录下adump 未建

[oracle@localhost orcl]$ pwd
/u01/app/oracle/admin/orcl
[oracle@localhost orcl]$ mkdir adump 

建好目录adump 在启动就没问题了,原因是因为 参数文件里有 audit_file_dest='/u01/app/oracle/admin/orcl/adump',参数文件里涉及到的目录都要在备库创建。

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1043886080 bytes
Fixed Size		 2259840 bytes
Variable Size		 889193600 bytes
Database Buffers	 146800640 bytes
Redo Buffers		 5632000 bytes
SQL> 

SQL> create spfile from pfile; 

File created.

11 开始进行 duplicate 

这个操作主备库都可以,只要在 RMAN 连接时没写错就可以了。

[oracle@localhost orcl]$ rman target sys/oracle@orcl_pd auxiliary sys/oracle@orcl_st

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Apr 19 18:15:53 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (mounted)
connected to auxiliary database: ORCL (not mounted)
RMAN> duplicate target database for standby from active database; 



--如果路径相同,使用这个: duplicate target database for standby from active database nofilenamecheck;

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

Starting Duplicate Db at 19-APR-17
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK

contents of Memory Script:
{
 backup as copy reuse
 targetfile '/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl' auxiliary format 
 '/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl' ;
}
executing Memory Script

RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT row
RMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and V$RMAN_OUTPUT rows
ORACLE error from target database: 
ORA-19922: there is no parent row with id 0 and level 1

Starting backup at 19-APR-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Finished backup at 19-APR-17

contents of Memory Script:
{
 backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/orcl/control01.ctl';
 restore clone controlfile to '/u01/app/oracle/fast_recovery_area/orcl/control02.ctl' from 
 '/u01/app/oracle/oradata/orcl/control01.ctl';
}
executing Memory Script

Starting backup at 19-APR-17
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.0/db_1/dbs/snapcf_orcl.f tag=TAG20170419T181723 RECID=2 STAMP=941739444
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 19-APR-17

Starting restore at 19-APR-17
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 19-APR-17

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/app/oracle/oradata/orcl/temp01.dbf";
 switch clone tempfile all;
 set newname for datafile 1 to 
 "/u01/app/oracle/oradata/orcl/system01.dbf";
 set newname for datafile 2 to 
 "/u01/app/oracle/oradata/orcl/sysaux01.dbf";
 set newname for datafile 3 to 
 "/u01/app/oracle/oradata/orcl/undotbs01.dbf";
 set newname for datafile 4 to 
 "/u01/app/oracle/oradata/orcl/users01.dbf";
 set newname for datafile 5 to 
 "/u01/app/oracle/oradata/orcl/example01.dbf";
 backup as copy reuse
 datafile 1 auxiliary format 
 "/u01/app/oracle/oradata/orcl/system01.dbf" datafile 
 2 auxiliary format 
 "/u01/app/oracle/oradata/orcl/sysaux01.dbf" datafile 
 3 auxiliary format 
 "/u01/app/oracle/oradata/orcl/undotbs01.dbf" datafile 
 4 auxiliary format 
 "/u01/app/oracle/oradata/orcl/users01.dbf" datafile 
 5 auxiliary format 
 "/u01/app/oracle/oradata/orcl/example01.dbf" ;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/orcl/temp01.dbf 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 19-APR-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
output file name=/u01/app/oracle/oradata/orcl/system01.dbf tag=TAG20170419T181733
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
output file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf tag=TAG20170419T181733
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
output file name=/u01/app/oracle/oradata/orcl/example01.dbf tag=TAG20170419T181733
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=/u01/app/oracle/oradata/orcl/undotbs01.dbf
output file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf tag=TAG20170419T181733
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output file name=/u01/app/oracle/oradata/orcl/users01.dbf tag=TAG20170419T181733
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 19-APR-17

contents of Memory Script:
{
 switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=941739537 file name=/u01/app/oracle/oradata/orcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=941739537 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=941739537 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=941739537 file name=/u01/app/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=941739537 file name=/u01/app/oracle/oradata/orcl/example01.dbf
Finished Duplicate Db at 19-APR-17

RMAN> 

12 启动备库 

--完成 duplicate 之后,备库就是 mount 状态:
 

SQL> select open_mode from v$database; 

OPEN_MODE
--------------------
MOUNTED

SQL> alter database open; 

Database altered.

SQL> select open_mode from v$database; 

OPEN_MODE
--------------------
READ ONLY
 13 启动 MRP 进程 

 
SQL> alter database recover managed standby database disconnect from session; 

Database altered.

SQL> select open_mode from v$database; 

OPEN_MODE
--------------------
READ ONLY WITH APPLY
14 验证



主库


 
SQL> create table leo (x number(10)); Table created. SQL> insert into leo values(10); 1 row created. SQL> commit; Commit complete. SQL> alter system switch logfiel; alter system switch logfiel * ERROR at line 1: ORA-01900: LOGFILE keyword expected SQL> alter system switch logfile; System altered.

备库

SQL> desc leo;
 Name					 Null? Type
 ----------------------------------------- -------- ----------------------------
 X						 NUMBER(10)

SQL> select * from leo;

	 X
----------
	10

标签:datafile,DG,app,ADG,orcl,oradata,oracle,Oracle,u01
来源: https://blog.csdn.net/leo__1990/article/details/91435581