Oracle12c_DataGuard_part_1

一、系统环境:

	数据库	操作系统	Ip		Service_name	db_unique_name  备注
	orcl	RHEL6.5	192.168.56.92	orcl		orcl        	Primary DB
	orcl	RHEL6.5	192.168.56.94	orcl,orcldg	orcldg  	Physical Standby DB
 
	[root@ora12102 ~]# cat /etc/hosts
	127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
	::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
	192.168.56.92 ora12102
	192.168.56.93 ora12102fs
	192.168.56.94 ora12102dg

二、配置primary/standby :
2.1 配置强制归档

	SQL> shutdown immediate
	SQL> startup mount
	SQL> ALTER DATABASE archivelog;
	SQL> ALTER DATABASE OPEN;
	SQL> ALTER DATABASE force logging;
	SQL> archive log list;
	DATABASE log mode              Archive Mode
	Automatic archival             Enabled
	Archive destination            /backup/archivelog
	Oldest online log SEQUENCE     67
	NEXT log SEQUENCE TO archive   69
	CURRENT log SEQUENCE           69

2.2 配置参数文件:

	SQL> ALTER system SET db_unique_name=orcl scope=spfile;
	SQL> ALTER system SET log_archive_config='dg_config=(orcl,orcldg)' scope=spfile;
	SQL> ALTER system SET log_archive_dest_1='location=/backup/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcl' scope=spfile; 
	SQL> ALTER system SET log_archive_dest_2='SERVICE=orcldg lgwr sync affirm VALID_FOr=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcldg' scope=spfile;
	SQL> ALTER system SET standby_file_management=auto;
	SQL> ALTER system SET fal_server=orcldg;
	SQL> ALTER system SET fal_client=orcl;
	SQL> ALTER system SET archive_lag_target=900;
	SQL> ALTER system SET log_archive_dest_state_2=enable;
	SQL> ALTER DATABASE ADD standby logfile GROUP 4 ('/oradata/orcl/sby_redo04.log') SIZE 50m;
	SQL> ALTER DATABASE ADD standby logfile GROUP 5 ('/oradata/orcl/sby_redo05.log') SIZE 50m;
	SQL> ALTER DATABASE ADD standby logfile GROUP 6 ('/oradata/orcl/sby_redo06.log') SIZE 50m;
	SQL> ALTER DATABASE ADD standby logfile GROUP 7 ('/oradata/orcl/sby_redo07.log') SIZE 50m;
	SQL> shutdown immediate
	SQL> startup
 
	SQL> CREATE pfile FROM spfile;

2.3 主库配置监听

	[oracle@ora12102 ~]$ cd  $ORACLE_HOME
	[oracle@ora12102 db_1]$ cd network/admin/
	[oracle@ora12102 admin]$ vi listener.ora 
	[oracle@ora12102 admin]$ cat listener.ora 
	# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
	# Generated BY Oracle configuration tools.
 
	LISTENER =
	  (DESCRIPTION_LIST =
	    (DESCRIPTION =
	      (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521))
	      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
	    )
	  )

2.4 主库配置tnsname

	[oracle@ora12102 admin]$ cat tnsnames.ora 
	# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/tnsnames.ora
	# Generated by Oracle configuration tools.
 
	LISTENER_TEST =
	  (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521))
 
 
	TEST =
	  (DESCRIPTION =
	    (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521))
	    (CONNECT_DATA =
	      (SERVER = DEDICATED)
	      (SERVICE_NAME = test)
	    )
	  )
	orcl =
	  (DESCRIPTION =
	    (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521))
	    (CONNECT_DATA =
	      (SERVER = DEDICATED)
	      (SERVICE_NAME = orcl)
	    )
	  )
 
 
	orcldg =
	  (DESCRIPTION =
	    (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102dg)(PORT = 1521))
	    (CONNECT_DATA =
	      (SERVER = DEDICATED)
	      (SERVICE_NAME = orcldg)
	    )
	  )

2.5 备份主库数据文件
这步可以不错

	RMAN>  backup full format '/backup/backup_%t_%s_%p' database;
	RMAN>  backup current controlfile for standby format='/backup/dg_cfile.%U'; 
	把备份文件传输到备库端相同的位置下

2.6 在备份端建立目录

	mkdir -p /u01/app/oracle/admin/orcl
	mkdir -p /u01/app/oracle/admin/orcldg/adump
	mkdir -p /oradata/archivelog
	mkdir -p /oradata/orcl
	#pdb directory
	mkdir -p /oradata/orcl/pdbseed/
	mkdir -p /oradata/orcl/travel/

2.7 修改备库配置参数
复制密码文件

	[oracle@ora12102dg dbs]$ vi $ORACLE_HOME/dbs/initorcl.ora
	[oracle@ora12102dg dbs]$ cat $ORACLE_HOME/dbs/initorcl.ora
	db_name=orcl

2.8 修改备库监听

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

2.8 配置备库tnsname

	 cat tnsnames.ora 
	# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/tnsnames.ora
	# Generated by Oracle configuration tools.
 
	LISTENER_TEST =
	  (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521))
 
 
	TEST =
	  (DESCRIPTION =
	    (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521))
	    (CONNECT_DATA =
	      (SERVER = DEDICATED)
	      (SERVICE_NAME = test)
	    )
	  )
	orcl =
	  (DESCRIPTION =
	    (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521))
	    (CONNECT_DATA =
	      (SERVER = DEDICATED)
	      (SERVICE_NAME = orcl)
	    )
	  )
 
 
	orcldg =
	  (DESCRIPTION =
	    (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102dg)(PORT = 1521))
	    (CONNECT_DATA =
	      (SERVER = DEDICATED)
	      (SERVICE_NAME = orcldg)
	    )
	  )

2.9 验证网络监听
主库

	[oracle@ora12102 ~]$ tnsping orcl
 
	TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 10-MAY-2015 14:04:20
 
	Copyright (c) 1997, 2014, Oracle.  All rights reserved.
 
	Used parameter files:
 
 
	Used TNSNAMES adapter to resolve the alias
	Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
	OK (0 msec)
	[oracle@ora12102 ~]$ tnsping orcldg
 
	TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 10-MAY-2015 14:04:23
 
	Copyright (c) 1997, 2014, Oracle.  All rights reserved.
 
	Used parameter files:
 
 
	Used TNSNAMES adapter to resolve the alias
	Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102dg)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcldg)))
	OK (0 msec)
	[oracle@ora12102 ~]$ 
	备库
	[oracle@ora12102dg ~]$ tnsping orcl
 
	TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 10-MAY-2015 14:05:35
 
	Copyright (c) 1997, 2014, Oracle.  All rights reserved.
 
	Used parameter files:
 
 
	Used TNSNAMES adapter to resolve the alias
	Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
	OK (10 msec)
	[oracle@ora12102dg ~]$ tnsping orcldg
 
	TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 10-MAY-2015 14:05:37
 
	Copyright (c) 1997, 2014, Oracle.  All rights reserved.
 
	Used parameter files:
 
 
	Used TNSNAMES adapter to resolve the alias
	Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12102dg)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcldg)))
	OK (10 msec)

2.10 恢复备库

	    CONNECT target sys/oracle@orcl
	    CONNECT auxiliary sys/oracle@orcldg
	    run {
	       allocate channel c1 TYPE disk;
	       allocate auxiliary channel s1 TYPE disk;
	       duplicate target DATABASE
	            FOR standby
	            FROM active DATABASE nofilenamecheck
	            dorecover
	            spfile
	            parameter_value_convert 'orcl','orcldg'
	            SET db_unique_name='orcldg'
	            SET db_create_file_dest='/oradata/orcl'
	            SET db_file_name_convert='/orcl/','/orcl/'
	            SET log_file_name_convert='/orcl/','/orcl/'
	            SET control_files='/oradata/orcl/control01.ctl','/oradata/orcl/control02.ctl'
	            SET fal_client='orcldg'
	            SET fal_server='orcl'
	            SET standby_file_management='AUTO'
	            SET log_archive_config='dg_config=(orcl,orcldg)'
	            SET log_archive_dest_1='location=/oradata/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcldg'
	            SET log_archive_dest_2='service=orcl LGWR SYNC affirm valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=orcl'
	            SET log_archive_dest_state_2='enable'
	           ;
	          SQL channel c1 "alter system archive log current";
	          SQL channel s1 "alter database recover managed standby database disconnect";
	         }

这里配置SYNC affirm传输方式,oracle在12c支持SYNC noaffirm方式

Maximum Availability mode now allows the LOG_ARCHIVE_DEST_n attributes SYNC and NOAFFIRM to be used together. This enables a synchronous standby database to be deployed at a further distance from the primary site without increasing the impact on primary database performance. (In an Oracle Data Guard broker configuration, this is referred to as FASTSYNC mode.)
RMAN> connect target sys/oracle@orcl
 
	connect auxiliary sys/oracle@orcldg
	run {
	   allocate channel c1 type disk;
	   allocate auxiliary channel s1 type disk;
	   duplicate target database
	        for standby
	        from active database nofilenamecheck
	        dorecover
	        spfile
	        parameter_value_convert 'orcl','orcldg'
	        set db_unique_name='orcldg'
	        set db_create_file_dest='/oradata/orcl'
	connected to target database: ORCL (DBID=1399018635)
 
	        set db_file_name_convert='/orcl/','/orcl/'
	RMAN> 
	        set log_file_name_convert='/orcl/','/orcl/'
	        set control_files='/oradata/orcl/control01.ctl','/oradata/orcl/control02.ctl'
	        set fal_client='orcldg'
	        set fal_server='orcl'
	        set standby_file_management='AUTO'
	        set log_archive_config='dg_config=(orcl,orcldg)'
	connected to auxiliary database: ORCL (not mounted)
	        set log_archive_dest_1='location=/oradata/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcldg'
 
	RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20>         set log_archive_dest_2='service=orcl LGWR SYNC affirm valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=orcl'
	21>         set log_archive_dest_state_2='enable'
	22>    ;
	23>   sql channel c1 "alter system archive log current";
	24>   sql channel s1 "alter database recover managed standby database disconnect";
	25> }
 
	using target database control file instead of recovery catalog
	allocated channel: c1
	channel c1: SID=44 device type=DISK
 
	allocated channel: s1
	channel s1: SID=22 device type=DISK
 
	Starting Duplicate Db at 2015-05-10 14:38:46
	current log archived
 
	contents of Memory Script:
	{
	   backup as copy reuse
	   targetfile  '/u01/app/oracle/product/12.1.0/db_1/dbs/orapworcl' auxiliary format 
	 '/u01/app/oracle/product/12.1.0/db_1/dbs/orapworcl'   ;
	   restore clone from service  'orcl' spfile to 
	 '/u01/app/oracle/product/12.1.0/db_1/dbs/spfileorcl.ora';
	   sql clone "alter system set spfile= ''/u01/app/oracle/product/12.1.0/db_1/dbs/spfileorcl.ora''";
	}
	executing Memory Script
 
	Starting backup at 2015-05-10 14:38:47
	Finished backup at 2015-05-10 14:38:48
 
	Starting restore at 2015-05-10 14:38:48
 
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: restoring SPFILE
	output file name=/u01/app/oracle/product/12.1.0/db_1/dbs/spfileorcl.ora
	channel s1: restore complete, elapsed time: 00:00:01
	Finished restore at 2015-05-10 14:38:49
 
	sql statement: alter system set spfile= ''/u01/app/oracle/product/12.1.0/db_1/dbs/spfileorcl.ora''
 
	contents of Memory Script:
	{
	   sql clone "alter system set  audit_file_dest = 
	 ''/u01/app/oracle/admin/orcldg/adump'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  dispatchers = 
	 ''(PROTOCOL=TCP) (SERVICE=orcldgXDB)'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  db_unique_name = 
	 ''orcldg'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  db_create_file_dest = 
	 ''/oradata/orcl'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  db_file_name_convert = 
	 ''/orcl/'', ''/orcl/'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  log_file_name_convert = 
	 ''/orcl/'', ''/orcl/'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  control_files = 
	 ''/oradata/orcl/control01.ctl'', ''/oradata/orcl/control02.ctl'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  fal_client = 
	 ''orcldg'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  fal_server = 
	 ''orcl'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  standby_file_management = 
	 ''AUTO'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  log_archive_config = 
	 ''dg_config=(orcl,orcldg)'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  log_archive_dest_1 = 
	 ''location=/oradata/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcldg'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  log_archive_dest_2 = 
	 ''service=orcl LGWR SYNC affirm valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=orcl'' comment=
	 '''' scope=spfile";
	   sql clone "alter system set  log_archive_dest_state_2 = 
	 ''enable'' comment=
	 '''' scope=spfile";
	   shutdown clone immediate;
	   startup clone nomount;
	}
	executing Memory Script
 
	sql statement: alter system set  audit_file_dest =  ''/u01/app/oracle/admin/orcldg/adump'' comment= '''' scope=spfile
 
	sql statement: alter system set  dispatchers =  ''(PROTOCOL=TCP) (SERVICE=orcldgXDB)'' comment= '''' scope=spfile
 
	sql statement: alter system set  db_unique_name =  ''orcldg'' comment= '''' scope=spfile
 
	sql statement: alter system set  db_create_file_dest =  ''/oradata/orcl'' comment= '''' scope=spfile
 
	sql statement: alter system set  db_file_name_convert =  ''/orcl/'', ''/orcl/'' comment= '''' scope=spfile
 
	sql statement: alter system set  log_file_name_convert =  ''/orcl/'', ''/orcl/'' comment= '''' scope=spfile
 
	sql statement: alter system set  control_files =  ''/oradata/orcl/control01.ctl'', ''/oradata/orcl/control02.ctl'' comment= '''' scope=spfile
 
	sql statement: alter system set  fal_client =  ''orcldg'' comment= '''' scope=spfile
 
	sql statement: alter system set  fal_server =  ''orcl'' comment= '''' scope=spfile
 
	sql statement: alter system set  standby_file_management =  ''AUTO'' comment= '''' scope=spfile
 
	sql statement: alter system set  log_archive_config =  ''dg_config=(orcl,orcldg)'' comment= '''' scope=spfile
 
	sql statement: alter system set  log_archive_dest_1 =  ''location=/oradata/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcldg'' comment= '''' scope=spfile
 
	sql statement: alter system set  log_archive_dest_2 =  ''service=orcl LGWR SYNC affirm valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=orcl'' comment= '''' scope=spfile
 
	sql statement: alter system set  log_archive_dest_state_2 =  ''enable'' comment= '''' scope=spfile
 
	Oracle instance shut down
 
	connected to auxiliary database (not started)
	Oracle instance started
 
	Total System Global Area    1073741824 bytes
 
	Fixed Size                     2932632 bytes
	Variable Size                339738728 bytes
	Database Buffers             515899392 bytes
	Redo Buffers                   5455872 bytes
	In-Memory Area               209715200 bytes
	allocated channel: s1
	channel s1: SID=21 device type=DISK
 
	contents of Memory Script:
	{
	   restore clone from service  'orcl' standby controlfile;
	}
	executing Memory Script
 
	Starting restore at 2015-05-10 14:39:08
 
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: restoring control file
	channel s1: restore complete, elapsed time: 00:00:01
	output file name=/oradata/orcl/control01.ctl
	output file name=/oradata/orcl/control02.ctl
	Finished restore at 2015-05-10 14:39:10
 
	contents of Memory Script:
	{
	   sql clone 'alter database mount standby database';
	}
	executing Memory Script
 
	sql statement: alter database mount standby database
	Using previous duplicated file /oradata/orcl/system01.dbf for datafile 1 with checkpoint SCN of 2714023
	Using previous duplicated file /oradata/orcl/sysaux01.dbf for datafile 3 with checkpoint SCN of 2714064
	Using previous duplicated file /oradata/orcl/undotbs01.dbf for datafile 4 with checkpoint SCN of 2714094
 
	contents of Memory Script:
	{
	   set newname for tempfile  1 to 
	 "/oradata/orcl/temp01.dbf";
	   set newname for tempfile  2 to 
	 "/oradata/orcl/pdbseed/pdbseed_temp012015-02-09_06-32-26-PM.dbf";
	   set newname for tempfile  3 to 
	 "/oradata/orcl/travel/travel_temp012015-03-19_01-30-29-PM.dbf";
	   switch clone tempfile all;
	   set newname for datafile  1 to 
	 "/oradata/orcl/system01.dbf";
	   set newname for datafile  3 to 
	 "/oradata/orcl/sysaux01.dbf";
	   set newname for datafile  4 to 
	 "/oradata/orcl/undotbs01.dbf";
	   set newname for datafile  5 to 
	 "/oradata/orcl/pdbseed/system01.dbf";
	   set newname for datafile  6 to 
	 "/oradata/orcl/users01.dbf";
	   set newname for datafile  7 to 
	 "/oradata/orcl/pdbseed/sysaux01.dbf";
	   set newname for datafile  21 to 
	 "/oradata/orcl/travel/system01.dbf";
	   set newname for datafile  22 to 
	 "/oradata/orcl/travel/sysaux01.dbf";
	   set newname for datafile  23 to 
	 "/oradata/orcl/travel/SAMPLE_SCHEMA_users01.dbf";
	   set newname for datafile  24 to 
	 "/oradata/orcl/travel/example01.dbf";
	   restore
	   from service  'orcl'   clone datafile
	    5, 6, 7, 21, 22, 23, 24   ;
	   sql 'alter system archive log current';
	}
	executing Memory Script
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	renamed tempfile 1 to /oradata/orcl/temp01.dbf in control file
	renamed tempfile 2 to /oradata/orcl/pdbseed/pdbseed_temp012015-02-09_06-32-26-PM.dbf in control file
	renamed tempfile 3 to /oradata/orcl/travel/travel_temp012015-03-19_01-30-29-PM.dbf in control file
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	executing command: SET NEWNAME
 
	Starting restore at 2015-05-10 14:39:15
 
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: specifying datafile(s) to restore from backup set
	channel s1: restoring datafile 00005 to /oradata/orcl/pdbseed/system01.dbf
	channel s1: restore complete, elapsed time: 00:00:07
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: specifying datafile(s) to restore from backup set
	channel s1: restoring datafile 00006 to /oradata/orcl/users01.dbf
	channel s1: restore complete, elapsed time: 00:00:01
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: specifying datafile(s) to restore from backup set
	channel s1: restoring datafile 00007 to /oradata/orcl/pdbseed/sysaux01.dbf
	channel s1: restore complete, elapsed time: 00:00:15
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: specifying datafile(s) to restore from backup set
	channel s1: restoring datafile 00021 to /oradata/orcl/travel/system01.dbf
	channel s1: restore complete, elapsed time: 00:00:07
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: specifying datafile(s) to restore from backup set
	channel s1: restoring datafile 00022 to /oradata/orcl/travel/sysaux01.dbf
	channel s1: restore complete, elapsed time: 00:00:15
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: specifying datafile(s) to restore from backup set
	channel s1: restoring datafile 00023 to /oradata/orcl/travel/SAMPLE_SCHEMA_users01.dbf
	channel s1: restore complete, elapsed time: 00:00:01
	channel s1: starting datafile backup set restore
	channel s1: using network backup set from service orcl
	channel s1: specifying datafile(s) to restore from backup set
	channel s1: restoring datafile 00024 to /oradata/orcl/travel/example01.dbf
	channel s1: restore complete, elapsed time: 00:00:16
	Finished restore at 2015-05-10 14:40:17
 
	sql statement: alter system archive log current
	current log archived
 
	contents of Memory Script:
	{
	   restore clone force from service  'orcl' 
	           archivelog from scn  2714023;
	   catalog clone datafilecopy  "/oradata/orcl/system01.dbf", 
	 "/oradata/orcl/sysaux01.dbf", 
	 "/oradata/orcl/undotbs01.dbf";
	   switch clone datafile  1 to datafilecopy 
	 "/oradata/orcl/system01.dbf";
	   switch clone datafile  3 to datafilecopy 
	 "/oradata/orcl/sysaux01.dbf";
	   switch clone datafile  4 to datafilecopy 
	 "/oradata/orcl/undotbs01.dbf";
	   switch clone datafile all;
	}
	executing Memory Script
 
	Starting restore at 2015-05-10 14:40:20
 
	channel s1: starting archived log restore to default destination
	channel s1: using network backup set from service orcl
	channel s1: restoring archived log
	archived log thread=1 sequence=75
	channel s1: restore complete, elapsed time: 00:00:01
	channel s1: starting archived log restore to default destination
	channel s1: using network backup set from service orcl
	channel s1: restoring archived log
	archived log thread=1 sequence=76
	channel s1: restore complete, elapsed time: 00:00:01
	channel s1: starting archived log restore to default destination
	channel s1: using network backup set from service orcl
	channel s1: restoring archived log
	archived log thread=1 sequence=77
	channel s1: restore complete, elapsed time: 00:00:01
	channel s1: starting archived log restore to default destination
	channel s1: using network backup set from service orcl
	channel s1: restoring archived log
	archived log thread=1 sequence=78
	channel s1: restore complete, elapsed time: 00:00:01
	channel s1: starting archived log restore to default destination
	channel s1: using network backup set from service orcl
	channel s1: restoring archived log
	archived log thread=1 sequence=79
	channel s1: restore complete, elapsed time: 00:00:01
	channel s1: starting archived log restore to default destination
	channel s1: using network backup set from service orcl
	channel s1: restoring archived log
	archived log thread=1 sequence=80
	channel s1: restore complete, elapsed time: 00:00:01
	channel s1: starting archived log restore to default destination
	channel s1: using network backup set from service orcl
	channel s1: restoring archived log
	archived log thread=1 sequence=81
	channel s1: restore complete, elapsed time: 00:00:01
	Finished restore at 2015-05-10 14:40:28
 
	cataloged datafile copy
	datafile copy file name=/oradata/orcl/system01.dbf RECID=11 STAMP=879345628
	cataloged datafile copy
	datafile copy file name=/oradata/orcl/sysaux01.dbf RECID=12 STAMP=879345628
	cataloged datafile copy
	datafile copy file name=/oradata/orcl/undotbs01.dbf RECID=13 STAMP=879345628
 
	datafile 1 switched to datafile copy
	input datafile copy RECID=11 STAMP=879345628 file name=/oradata/orcl/system01.dbf
 
	datafile 3 switched to datafile copy
	input datafile copy RECID=12 STAMP=879345628 file name=/oradata/orcl/sysaux01.dbf
 
	datafile 4 switched to datafile copy
	input datafile copy RECID=13 STAMP=879345628 file name=/oradata/orcl/undotbs01.dbf
 
	datafile 5 switched to datafile copy
	input datafile copy RECID=14 STAMP=879345629 file name=/oradata/orcl/pdbseed/system01.dbf
	datafile 6 switched to datafile copy
	input datafile copy RECID=15 STAMP=879345629 file name=/oradata/orcl/users01.dbf
	datafile 7 switched to datafile copy
	input datafile copy RECID=16 STAMP=879345629 file name=/oradata/orcl/pdbseed/sysaux01.dbf
	datafile 21 switched to datafile copy
	input datafile copy RECID=17 STAMP=879345629 file name=/oradata/orcl/travel/system01.dbf
	datafile 22 switched to datafile copy
	input datafile copy RECID=18 STAMP=879345629 file name=/oradata/orcl/travel/sysaux01.dbf
	datafile 23 switched to datafile copy
	input datafile copy RECID=19 STAMP=879345629 file name=/oradata/orcl/travel/SAMPLE_SCHEMA_users01.dbf
	datafile 24 switched to datafile copy
	input datafile copy RECID=20 STAMP=879345629 file name=/oradata/orcl/travel/example01.dbf
 
	contents of Memory Script:
	{
	   set until scn  2715969;
	   recover
	   standby
	   clone database
	    delete archivelog
	   ;
	}
	executing Memory Script
 
	executing command: SET until clause
 
	Starting recover at 2015-05-10 14:40:29
 
	starting media recovery
 
	archived log for thread 1 with sequence 75 is already on disk as file /oradata/archivelog/1_75_871237903.dbf
	archived log for thread 1 with sequence 76 is already on disk as file /oradata/archivelog/1_76_871237903.dbf
	archived log for thread 1 with sequence 77 is already on disk as file /oradata/archivelog/1_77_871237903.dbf
	archived log for thread 1 with sequence 78 is already on disk as file /oradata/archivelog/1_78_871237903.dbf
	archived log for thread 1 with sequence 79 is already on disk as file /oradata/archivelog/1_79_871237903.dbf
	archived log for thread 1 with sequence 80 is already on disk as file /oradata/archivelog/1_80_871237903.dbf
	archived log for thread 1 with sequence 81 is already on disk as file /oradata/archivelog/1_81_871237903.dbf
	archived log file name=/oradata/archivelog/1_75_871237903.dbf thread=1 sequence=75
	archived log file name=/oradata/archivelog/1_76_871237903.dbf thread=1 sequence=76
	archived log file name=/oradata/archivelog/1_77_871237903.dbf thread=1 sequence=77
	archived log file name=/oradata/archivelog/1_78_871237903.dbf thread=1 sequence=78
	archived log file name=/oradata/archivelog/1_79_871237903.dbf thread=1 sequence=79
	archived log file name=/oradata/archivelog/1_80_871237903.dbf thread=1 sequence=80
	archived log file name=/oradata/archivelog/1_81_871237903.dbf thread=1 sequence=81
	media recovery complete, elapsed time: 00:00:00
	Finished recover at 2015-05-10 14:40:30
	Finished Duplicate Db at 2015-05-10 14:40:32
 
	sql statement: alter system archive log current
 
	sql statement: alter database recover managed standby database disconnect
	released channel: c1
	released channel: s1
 
	RMAN> 
	/*
	sqlplus / as sysdba
	shutdown immediate;
	!rm -rf /u01/app/oracle/product/12.1.0/db_1/dbs/spfileorcl.ora
 
	startup nomount;
	*/

三、验证:
验证备用服务器是否工作
验证网络连通性:

	# tnsping service_name
 
	SQL> CREATE TABLE dg_test AS SELECT * FROM dba_objects;
 
	TABLE created.

备库查看

	[oracle@ora12102dg ~]$ sqlplus "/ as sysdba"
 
	SQL*Plus: Release 12.1.0.2.0 Production ON Sun May 10 14:45:54 2015
 
	Copyright (c) 1982, 2014, Oracle.  ALL rights reserved.
 
 
	Connected TO:
	Oracle DATABASE 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
	WITH the Partitioning, OLAP, Advanced Analytics AND REAL Application Testing options
 
	SQL> @DESC dg_test
	           Name                            NULL?    TYPE
	           ------------------------------- -------- ----------------------------
	    1      OWNER                                    VARCHAR2(128)
	    2      OBJECT_NAME                              VARCHAR2(128)
	    3      SUBOBJECT_NAME                           VARCHAR2(128)
	    4      OBJECT_ID                                NUMBER
	    5      DATA_OBJECT_ID                           NUMBER
	    6      OBJECT_TYPE                              VARCHAR2(23)
	    7      CREATED                                  DATE
	    8      LAST_DDL_TIME                            DATE
	    9      TIMESTAMP                                VARCHAR2(19)
	   10      STATUS                                   VARCHAR2(7)
	   11      TEMPORARY                                VARCHAR2(1)
	   12      GENERATED                                VARCHAR2(1)
	   13      SECONDARY                                VARCHAR2(1)
	   14      NAMESPACE                                NUMBER
	   15      EDITION_NAME                             VARCHAR2(128)
	   16      SHARING                                  VARCHAR2(13)
	   17      EDITIONABLE                              VARCHAR2(1)
	   18      ORACLE_MAINTAINED                        VARCHAR2(1)

四、PDB:
12c曾对pdb创建提供了 standby=all/none选择。默认为alL.
主库

		SQL> CREATE pluggable DATABASE pdb03 admin USER pdb03admin IDENTIFIED BY pdb03admin file_name_convert=('pdbseed','pdb03');
 
		Pluggable DATABASE created.
 
		SQL> SHOW pdbs
 
		    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
		---------- ------------------------------ ---------- ----------
		         2 PDB$SEED                       READ ONLY  NO
		         3 TRAVEL                         MOUNTED
		         4 PDB03                          MOUNTED
		SQL> SELECT name FROM v$datafile;
 
		NAME
		--------------------------------------------------------------------------------------------------------
		/oradata/orcl/system01.dbf
		/oradata/orcl/sysaux01.dbf
		/oradata/orcl/undotbs01.dbf
		/oradata/orcl/pdbseed/system01.dbf
		/oradata/orcl/users01.dbf
		/oradata/orcl/pdbseed/sysaux01.dbf
		/oradata/orcl/travel/system01.dbf
		/oradata/orcl/travel/sysaux01.dbf
		/oradata/orcl/travel/SAMPLE_SCHEMA_users01.dbf
		/oradata/orcl/travel/example01.dbf
		/oradata/orcl/pdb03/system01.dbf
		/oradata/orcl/pdb03/sysaux01.dbf
 
		12 ROWS selected.
 
		CREATE pluggable DATABASE pdb03 admin USER pdb03admin IDENTIFIED BY * file_name_convert=('pdbseed','pdb03')
		Sun May 10 14:52:13 2015
		 APEX_040200.WWV_FLOW_ADVISOR_CHECKS (CHECK_STATEMENT) - CLOB populated
		Sun May 10 14:52:27 2015
		****************************************************************
		Pluggable DATABASE PDB03 WITH pdb id - 4 IS created AS UNUSABLE.
		IF any errors are encountered BEFORE the pdb IS marked AS NEW,
		THEN the pdb must be dropped
		****************************************************************
		DATABASE Characterset FOR PDB03 IS ZHS16GBK
		Deleting OLD file#5 FROM file$ 
		Deleting OLD file#7 FROM file$ 
		Adding NEW file#25 TO file$(OLD file#5) 
		Adding NEW file#26 TO file$(OLD file#7) 
		Successfully created internal service pdb03 at OPEN
		ALTER SYSTEM: Flushing buffer cache inst=0 container=4 LOCAL
		****************************************************************
		Post plug operations are now complete.
		Pluggable DATABASE PDB03 WITH pdb id - 4 IS now marked AS NEW.
		****************************************************************
		Completed: CREATE pluggable DATABASE pdb03 admin USER pdb03admin IDENTIFIED BY * file_name_convert=('pdbseed','pdb03')

备库

		SQL> SHOW pdbs
 
		    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
		---------- ------------------------------ ---------- ----------
		         2 PDB$SEED                       READ ONLY  NO
		         3 TRAVEL                         MOUNTED
		         4 PDB03                          MOUNTED
		SQL> SELECT name FROM v$datafile;
 
		NAME
		-------------------------------------------------------------------------------------
		/oradata/orcl/system01.dbf
		/oradata/orcl/sysaux01.dbf
		/oradata/orcl/undotbs01.dbf
		/oradata/orcl/pdbseed/system01.dbf
		/oradata/orcl/users01.dbf
		/oradata/orcl/pdbseed/sysaux01.dbf
		/oradata/orcl/travel/system01.dbf
		/oradata/orcl/travel/sysaux01.dbf
		/oradata/orcl/travel/SAMPLE_SCHEMA_users01.dbf
		/oradata/orcl/travel/example01.dbf
		/oradata/orcl/ORCLDG/15B5B309A0DA15D6E0535C38A8C087C0/datafile/system01.dbf
		/oradata/orcl/ORCLDG/15B5B309A0DA15D6E0535C38A8C087C0/datafile/sysaux01.dbf
 
		12 ROWS selected.
		Sun May 10 14:45:01 2015
		Recovery OF Online Redo Log: Thread 1 GROUP 4 Seq 85 Reading mem 0
		  Mem# 0: /oradata/orcl/sby_redo04.log
		Sun May 10 14:45:27 2015
		Resize operation completed FOR file# 1, OLD SIZE 808960K, NEW SIZE 819200K
		Sun May 10 14:52:27 2015
		Recovery created pluggable DATABASE PDB03
		Recovery copied files FOR tablespace SYSTEM
		Recovery successfully copied file /oradata/orcl/ORCLDG/15B5B309A0DA15D6E0535C38A8C087C0/datafile/system01.dbf FROM /oradata/orcl/pdbseed/system01.dbf
		Recovery created file /oradata/orcl/ORCLDG/15B5B309A0DA15D6E0535C38A8C087C0/datafile/system01.dbf
		Sun May 10 14:52:29 2015
		Errors IN file /u01/app/oracle/diag/rdbms/orcldg/orcl/trace/orcl_dbw0_3350.trc:
		ORA-01157: cannot identify/LOCK DATA file 203 - see DBWR trace file
		ORA-01110: DATA file 203: '/oradata/orcl/travel/travel_temp012015-03-19_01-30-29-PM.dbf'
		ORA-27037: unable TO obtain file STATUS
		Linux-x86_64 Error: 2: No such file OR directory
		Additional information: 3
		Sun May 10 14:52:29 2015
		Errors IN file /u01/app/oracle/diag/rdbms/orcldg/orcl/trace/orcl_dbw0_3350.trc:
		ORA-01186: file 203 failed verification tests
		ORA-01157: cannot identify/LOCK DATA file 203 - see DBWR trace file
		ORA-01110: DATA file 203: '/oradata/orcl/travel/travel_temp012015-03-19_01-30-29-PM.dbf'
		Sun May 10 14:52:29 2015
		File 203 NOT verified due TO error ORA-01157
		Sun May 10 14:52:29 2015
		Successfully added datafile 25 TO media recovery
		Datafile #25: '/oradata/orcl/ORCLDG/15B5B309A0DA15D6E0535C38A8C087C0/datafile/system01.dbf'
		Recovery copied files FOR tablespace SYSAUX
		Recovery successfully copied file /oradata/orcl/ORCLDG/15B5B309A0DA15D6E0535C38A8C087C0/datafile/sysaux01.dbf FROM /oradata/orcl/pdbseed/sysaux01.dbf
		Recovery created file /oradata/orcl/ORCLDG/15B5B309A0DA15D6E0535C38A8C087C0/datafile/sysaux01.dbf
		Sun May 10 14:52:35 2015
		Errors IN file /u01/app/oracle/diag/rdbms/orcldg/orcl/trace/orcl_dbw0_3350.trc:
		ORA-01157: cannot identify/LOCK DATA file 203 - see DBWR trace file
		ORA-01110: DATA file 203: '/oradata/orcl/travel/travel_temp012015-03-19_01-30-29-PM.dbf'
		ORA-27037: unable TO obtain file STATUS
		Linux-x86_64 Error: 2: No such file OR directory
		Additional information: 3
		Sun May 10 14:52:35 2015
		Errors IN file /u01/app/oracle/diag/rdbms/orcldg/orcl/trace/orcl_dbw0_3350.trc:
		ORA-01186: file 203 failed verification tests
		ORA-01157: cannot identify/LOCK DATA file 203 - see DBWR trace file
		ORA-01110: DATA file 203: '/oradata/orcl/travel/travel_temp012015-03-19_01-30-29-PM.dbf'
		Sun May 10 14:52:35 2015
		File 203 NOT verified due TO error ORA-01157
		Sun May 10 14:52:35 2015
		Successfully added datafile 26 TO media recovery
		Datafile #26: '/oradata/orcl/ORCLDG/15B5B309A0DA15D6E0535C38A8C087C0/datafile/sysaux01.dbf'
Sun May 10 14:54:10 2015
此条目发表在 未分类 分类目录。将固定链接加入收藏夹。

评论功能已关闭。