duplicate複製資料庫(rac-單例項)

zhangsharp20發表於2017-04-23
輔助庫配置(auxiliary):

建立pfile和密碼口令檔案(複製主庫的密碼口令檔案到備庫)

pfile:

*.db_name='test'
*.compatible='11.2.0.4.0'
*.control_files='/dup1/control01.ctl'
*.db_create_file_dest='/dup1'
*.db_file_name_convert='+oradata','/dup1'
*.db_recovery_file_dest='/arch'
*.db_recovery_file_dest_size=4621074432
*.log_file_name_convert='+oradata','/dup1','+rcy','/dup2'

在備庫上配置監聽
LISTENER=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.162.120)(PORT=1521))))
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=dup1)
      (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME=test)))

配置完成重啟監聽


[oracle@ora3 admin]$ lsnrctl status


LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 24-MAR-2017 04:33:42


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


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.162.120)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                01-JAN-2017 14:10:43
Uptime                    81 days 14 hr. 23 min. 19 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/ora3/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora3)(PORT=1521)))
Services Summary...
Service "dup1" has 1 instance(s).
  Instance "dup1", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully
[oracle@ora3 admin]$ lsnrctl stop


LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 24-MAR-2017 04:33:49


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


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.162.120)(PORT=1521)))
The command completed successfully
[oracle@ora3 admin]$ lsnrctl start


LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 24-MAR-2017 04:33:55


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


Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...


TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/ora3/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.162.120)(PORT=1521)))


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.162.120)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                24-MAR-2017 04:33:55
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ora3/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.162.120)(PORT=1521)))
Services Summary...
Service "dup1" has 1 instance(s).
  Instance "dup1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

測試sys遠端連線


[root@ora1 ~]# su - oracle
[oracle@ora1 ~]$ sqlplus sys/oracle@192.168.162.120/dup1 as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 3 19:42:32 2017


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




Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> select instance_name ,status from v$instance;


INSTANCE_NAME    STATUS
---------------- ------------
dup1             STARTED


SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


目標庫配置:

1、配置tnsname.ora



dup1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.162.120)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
  )


2、開啟最小日誌


SQL> select log_mode,force_logging from v$database;


LOG_MODE     FOR
------------ ---
ARCHIVELOG   NO


SQL> alter database force logging;


Database altered.


SQL> select log_mode,force_logging from v$database;


LOG_MODE     FOR
------------ ---
ARCHIVELOG   YES



3、登入rman


rman target / auxiliary sys/oracle@dup1 nocatalog

4、執行duplicate

RMAN> DUPLICATE TARGET DATABASE to 'test' FROM ACTIVE DATABASE;


Starting Duplicate Db at 08-MAR-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=111 device type=DISK


contents of Memory Script:
{
   sql clone "create spfile from memory";
}
executing Memory Script


sql statement: create spfile from memory


contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script


Oracle instance shut down


connected to auxiliary database (not started)
Oracle instance started


Total System Global Area     217157632 bytes


Fixed Size                     2251816 bytes
Variable Size                159384536 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5189632 bytes


contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''TEST'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''TEST'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/dup1/control01.ctl';
   alter clone database mount;
}
executing Memory Script


sql statement: alter system set  db_name =  ''TEST'' comment= ''Modified by RMAN duplicate'' scope=spfile


sql statement: alter system set  db_unique_name =  ''TEST'' comment= ''Modified by RMAN duplicate'' scope=spfile


Oracle instance shut down


Oracle instance started


Total System Global Area     217157632 bytes


Fixed Size                     2251816 bytes
Variable Size                159384536 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5189632 bytes


Starting backup at 08-MAR-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=55 instance=test1 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_test1.f tag=TAG20170308T214750 RECID=13 STAMP=938123275
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 08-MAR-17


database mounted


contents of Memory Script:
{
   set newname for datafile  1 to 
 "/dup1/test/datafile/system.256.922082001";
   set newname for datafile  2 to 
 "/dup1/test/datafile/sysaux.257.922082003";
   set newname for datafile  3 to 
 "/dup1/test/datafile/undotbs1.258.922082003";
   set newname for datafile  4 to 
 "/dup1/test/datafile/users.259.922082003";
   set newname for datafile  5 to 
 "/dup1/test/datafile/example.264.922082123";
   set newname for datafile  6 to 
 "/dup1/test/datafile/undotbs2.265.922082349";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/dup1/test/datafile/system.256.922082001"   datafile 
 2 auxiliary format 
 "/dup1/test/datafile/sysaux.257.922082003"   datafile 
 3 auxiliary format 
 "/dup1/test/datafile/undotbs1.258.922082003"   datafile 
 4 auxiliary format 
 "/dup1/test/datafile/users.259.922082003"   datafile 
 5 auxiliary format 
 "/dup1/test/datafile/example.264.922082123"   datafile 
 6 auxiliary format 
 "/dup1/test/datafile/undotbs2.265.922082349"   ;
   sql 'alter system archive log current';
}
executing Memory Script


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 backup at 08-MAR-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+ORADATA/test/datafile/sysaux.257.922082003






output file name=/dup1/test/datafile/sysaux.257.922082003 tag=TAG20170308T214806
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+ORADATA/test/datafile/system.256.922082001
output file name=/dup1/test/datafile/system.256.922082001 tag=TAG20170308T214806
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+ORADATA/test/datafile/example.264.922082123
output file name=/dup1/test/datafile/example.264.922082123 tag=TAG20170308T214806
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=+ORADATA/test/datafile/undotbs2.265.922082349
output file name=/dup1/test/datafile/undotbs2.265.922082349 tag=TAG20170308T214806
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=+ORADATA/test/datafile/undotbs1.258.922082003
output file name=/dup1/test/datafile/undotbs1.258.922082003 tag=TAG20170308T214806
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=+ORADATA/test/datafile/users.259.922082003
output file name=/dup1/test/datafile/users.259.922082003 tag=TAG20170308T214806
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 08-MAR-17


sql statement: alter system archive log current


contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "+RCY/test/archivelog/2017_03_08/thread_1_seq_127.362.938123417" auxiliary format 
 "/arch/TEST/archivelog/2017_02_13/o1_mf_1_127_%u_.arc"   archivelog like 
 "+RCY/test/archivelog/2017_03_06/thread_2_seq_118.366.937928291" auxiliary format 
 "/arch/TEST/archivelog/2017_02_13/o1_mf_2_118_%u_.arc"   archivelog like 
 "+RCY/test/archivelog/2017_03_06/thread_2_seq_119.363.937929993" auxiliary format 
 "/arch/TEST/archivelog/2017_02_13/o1_mf_2_119_%u_.arc"   ;
   catalog clone recovery area;
   switch clone datafile all;
}
executing Memory Script


Starting backup at 08-MAR-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=127 RECID=259 STAMP=938123417
output file name=/arch/TEST/archivelog/2017_02_13/o1_mf_1_127_2srul84r_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archived log copy
input archived log thread=2 sequence=118 RECID=256 STAMP=937928290
output file name=/arch/TEST/archivelog/2017_02_13/o1_mf_2_118_2trul84s_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archived log copy
input archived log thread=2 sequence=119 RECID=258 STAMP=937929994
output file name=/arch/TEST/archivelog/2017_02_13/o1_mf_2_119_2urul84t_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 08-MAR-17


searching for all files in the recovery area


List of Files Unknown to the Database
=====================================
File Name: /arch/TEST/archivelog/2017_02_13/o1_mf_2_118_2trul84s_.arc
File Name: /arch/TEST/archivelog/2017_02_13/o1_mf_2_119_2urul84t_.arc
File Name: /arch/TEST/archivelog/2017_02_13/o1_mf_1_127_2srul84r_.arc
cataloging files...
cataloging done


List of Cataloged Files
=======================
File Name: /arch/TEST/archivelog/2017_02_13/o1_mf_2_118_2trul84s_.arc
File Name: /arch/TEST/archivelog/2017_02_13/o1_mf_2_119_2urul84t_.arc
File Name: /arch/TEST/archivelog/2017_02_13/o1_mf_1_127_2srul84r_.arc


datafile 1 switched to datafile copy
input datafile copy RECID=13 STAMP=935818090 file name=/dup1/test/datafile/system.256.922082001
datafile 2 switched to datafile copy
input datafile copy RECID=14 STAMP=935818090 file name=/dup1/test/datafile/sysaux.257.922082003
datafile 3 switched to datafile copy
input datafile copy RECID=15 STAMP=935818090 file name=/dup1/test/datafile/undotbs1.258.922082003
datafile 4 switched to datafile copy
input datafile copy RECID=16 STAMP=935818090 file name=/dup1/test/datafile/users.259.922082003
datafile 5 switched to datafile copy
input datafile copy RECID=17 STAMP=935818090 file name=/dup1/test/datafile/example.264.922082123
datafile 6 switched to datafile copy
input datafile copy RECID=18 STAMP=935818090 file name=/dup1/test/datafile/undotbs2.265.922082349


contents of Memory Script:
{
   set until scn  4388069;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script


executing command: SET until clause


Starting recover at 08-MAR-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=111 device type=DISK


starting media recovery


archived log for thread 1 with sequence 127 is already on disk as file /arch/TEST/archivelog/2017_02_13/o1_mf_1_127_2srul84r_.arc
archived log for thread 2 with sequence 119 is already on disk as file /arch/TEST/archivelog/2017_02_13/o1_mf_2_119_2urul84t_.arc
archived log file name=/arch/TEST/archivelog/2017_02_13/o1_mf_1_127_2srul84r_.arc thread=1 sequence=127
archived log file name=/arch/TEST/archivelog/2017_02_13/o1_mf_2_119_2urul84t_.arc thread=2 sequence=119
media recovery complete, elapsed time: 00:00:01
Finished recover at 08-MAR-17
Oracle instance started


Total System Global Area     217157632 bytes


Fixed Size                     2251816 bytes
Variable Size                159384536 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5189632 bytes


contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''TEST'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script


sql statement: alter system set  db_name =  ''TEST'' comment= ''Reset to original value by RMAN'' scope=spfile


sql statement: alter system reset  db_unique_name scope=spfile


Oracle instance shut down


connected to auxiliary database (not started)
Oracle instance started


Total System Global Area     217157632 bytes


Fixed Size                     2251816 bytes
Variable Size                159384536 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5189632 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST" RESETLOGS ARCHIVELOG 
  MAXLOGFILES    192
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES    32
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '/dup2/test/onlinelog/group_1.257.922082089', '/dup1/test/onlinelog/group_1.261.922082087' ) SIZE 50 M  REUSE,
  GROUP   2 ( '/dup2/test/onlinelog/group_2.258.922082093', '/dup1/test/onlinelog/group_2.262.922082091' ) SIZE 50 M  REUSE
 DATAFILE
  '/dup1/test/datafile/system.256.922082001'
 CHARACTER SET AL32UTF8


sql statement: ALTER DATABASE ADD LOGFILE 
  
  INSTANCE 'i2' 
  GROUP   3 ( '/dup1/test/onlinelog/group_3.266.922082495', '/dup2/test/onlinelog/group_3.259.922082497' ) SIZE 50 M  REUSE,
  GROUP   4 ( '/dup1/test/onlinelog/group_4.267.922082501', '/dup2/test/onlinelog/group_4.260.922082503' ) SIZE 50 M  REUSE


contents of Memory Script:
{
   set newname for tempfile  1 to 
 "/dup1/test/tempfile/temp.263.922082111";
   switch clone tempfile all;
   catalog clone datafilecopy  "/dup1/test/datafile/sysaux.257.922082003", 
 "/dup1/test/datafile/undotbs1.258.922082003", 
 "/dup1/test/datafile/users.259.922082003", 
 "/dup1/test/datafile/example.264.922082123", 
 "/dup1/test/datafile/undotbs2.265.922082349";
   switch clone datafile all;
}
executing Memory Script


executing command: SET NEWNAME


renamed tempfile 1 to /dup1/test/tempfile/temp.263.922082111 in control file


cataloged datafile copy
datafile copy file name=/dup1/test/datafile/sysaux.257.922082003 RECID=1 STAMP=935818114
cataloged datafile copy
datafile copy file name=/dup1/test/datafile/undotbs1.258.922082003 RECID=2 STAMP=935818114
cataloged datafile copy
datafile copy file name=/dup1/test/datafile/users.259.922082003 RECID=3 STAMP=935818114
cataloged datafile copy
datafile copy file name=/dup1/test/datafile/example.264.922082123 RECID=4 STAMP=935818114
cataloged datafile copy
datafile copy file name=/dup1/test/datafile/undotbs2.265.922082349 RECID=5 STAMP=935818114


datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=935818114 file name=/dup1/test/datafile/sysaux.257.922082003
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=935818114 file name=/dup1/test/datafile/undotbs1.258.922082003
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=935818114 file name=/dup1/test/datafile/users.259.922082003
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=935818114 file name=/dup1/test/datafile/example.264.922082123
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=935818114 file name=/dup1/test/datafile/undotbs2.265.922082349
Reenabling controlfile options for auxiliary database
Executing: alter database force logging


contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script


database opened
Finished Duplicate Db at 08-MAR-17


RMAN> 



auxiliary庫檢視例項狀態發現資料庫例項已經處於OPEN狀態

[oracle@ora3 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 13 05:29:47 2017


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




Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> select instance_name ,status from v$instance;


INSTANCE_NAME    STATUS
---------------- ------------
test             OPEN

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29802484/viewspace-2137821/,如需轉載,請註明出處,否則將追究法律責任。

相關文章