duplicate複製資料庫(rac-單例項)
輔助庫配置(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
建立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
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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- duplicate搭建DG最大效能(rac-單例項)單例
- Rman duplicate資料庫複製(單系統)資料庫
- RMAN高階應用之Duplicate複製資料庫(2)輔助例項資料庫
- Oracle 之 Duplicate 複製資料庫Oracle資料庫
- DUPLICATE遠端複製資料庫資料庫
- SqlServer同例項複製資料庫方法SQLServer資料庫
- duplicate複製資料庫(rac-rac)資料庫
- 【RMAN】使用duplicate本地複製資料庫資料庫
- duplicate rman複製資料庫技術資料庫
- 簡單的單資料來源複製例項——流
- RMAN duplicate from active database 複製資料庫Database資料庫
- Duplicate 複製資料庫實驗過程資料庫
- 使用rman的命令duplicate複製資料庫資料庫
- RMAN高階應用之Duplicate複製資料庫(3)複製流程資料庫
- 【RMAN】使用RMAN duplicate複製同機資料庫資料庫
- 使用RMAN高階應用之Duplicate複製資料庫資料庫
- Oracle 11gR2 使用RMAN Duplicate複製資料庫Oracle資料庫
- Oracle11gR2使用RMAN duplicate複製資料庫Oracle資料庫
- RMAN實戰系列之一:用duplicate複製資料庫資料庫
- RMAN高階應用之Duplicate複製資料庫(1)概述資料庫
- 使用 Docker Compose 搭建 MySQL 資料庫主從複製例項DockerMySql資料庫
- 單例項的duplicate(non ASM)單例ASM
- 單例項資料庫工具轉化多例項資料庫單例資料庫
- 單例項資料庫手工轉化多例項資料庫單例資料庫
- RAC 例項 遷移到 單例項 -- 使用RMAN Duplicate單例
- oracle 11g duplicate from active database 複製資料庫(四)OracleDatabase資料庫
- oracle 11g duplicate from active database 複製資料庫(三)OracleDatabase資料庫
- oracle 11g duplicate from active database 複製資料庫(二)OracleDatabase資料庫
- oracle 11g duplicate from active database 複製資料庫(一)OracleDatabase資料庫
- RMAN高階應用之Duplicate複製資料庫(4)實戰資料庫
- RMAN高階應用之Duplicate複製資料庫(5)補充資料庫
- DG rman duplicate 複製庫錯誤
- 採用DUPLICATE 把asm資料庫複製到檔案系統ASM資料庫
- 實戰10g新特性之rman duplicate複製資料庫資料庫
- 【RMAN】使用RMAN duplicate複製同機資料庫遇到的問題資料庫
- RAC資料庫恢復到單例項資料庫資料庫單例
- 11GR2 Active Duplicate過程(單例項對單例項)單例
- 資料庫複製資料庫