1、启动监听
[oracle@odd201 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-JAN-2023 15:28:08
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=odd201)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@odd201 ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-JAN-2023 15:28:14
Copyright (c) 1991, 2009, 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.1.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/odd201/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=odd201)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=odd201)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 28-JAN-2023 15:28:14
Uptime 0 days 0 hr. 0 min. 22 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/odd201/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=odd201)(PORT=1521)))
The listener supports no services
The command completed successfully
2、启动源数据库
[oracle@odd201 ~]$ ps -ef|grep ora_
oracle 3295 1 0 14:22 ? 00:00:00 ora_pmon_PROD3
oracle 3297 1 0 14:22 ? 00:00:00 ora_vktm_PROD3
oracle 3301 1 0 14:22 ? 00:00:00 ora_gen0_PROD3
oracle 3303 1 0 14:22 ? 00:00:00 ora_diag_PROD3
oracle 3305 1 0 14:22 ? 00:00:00 ora_dbrm_PROD3
oracle 3307 1 0 14:22 ? 00:00:00 ora_psp0_PROD3
oracle 3309 1 0 14:22 ? 00:00:00 ora_dia0_PROD3
oracle 3318 1 0 14:22 ? 00:00:00 ora_mman_PROD3
oracle 3320 1 0 14:22 ? 00:00:00 ora_dbw0_PROD3
3、复制并修改参数文件
[oracle@odd201 dbs]$ cp initPROD3.ora initPROD4.ora
db_name='PROD4'
instance_name='PROD4'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/PROD4/adump'
audit_trail ='db'
db_block_size=8192
deferred_segment_creation=false
db_domain='PROD4.oracle.com'
db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = ('/u01/app/oracle/oradata/PROD4/control01.ctl','/u01/app/oracle/oradata/PROD4/con
trol02.ctl')
db_file_name_convert=('/u01/app/oracle/oradata/PROD3','/u01/app/oracle/oradata/PROD4')
log_file_name_convert=('/u01/app/oracle/oradata/PROD3','/u01/app/oracle/oradata/PROD4')
compatible =11.2.0.0.0
4、创建存放数据文件目录
[oracle@odd201 dbs]$ mkdir -p /u01/app/oracle/admin/PROD4/adump
[oracle@odd201 dbs]$ mkdir /u01/app/oracle/oradata/PROD4/
5、复制密码文件
[oracle@odd201 dbs]$ cp orapwPROD3 orapwPROD4
6、启动实例到nomount
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 616566616 bytes
Database Buffers 444596224 bytes
Redo Buffers
7、添加静态监听
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM = extproc)
)
)
8、配置tns
prod4 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = odd201)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD4)
)
)
[oracle@odd201 admin]$ tnsping prod4
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 28-JAN-2023 20:14:17
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = odd201)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD4)))
OK (0 msec)
[oracle@odd201 admin]$
9、备份数据库
RMAN> backup database include current controlfile plus archivelog all delete input;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "all": expecting one of: "auxiliary, channel, delete, diskratio, filesperset, force, format, from, include, keep, maxsetsize, noexclude, nokeep, not, pool, reuse, section, skip readonly, skip, tag, to, ;"
RMAN-01007: at line 2 column 61 file: standard input
RMAN> backup database include current controlfile plus archivelog;
Starting backup at 29-JAN-23
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=7 RECID=1 STAMP=1127067141
input archived log thread=1 sequence=8 RECID=2 STAMP=1127067141
input archived log thread=1 sequence=9 RECID=3 STAMP=1127068181
input archived log thread=1 sequence=10 RECID=4 STAMP=1127068216
input archived log thread=1 sequence=11 RECID=5 STAMP=1127068274
input archived log thread=1 sequence=12 RECID=6 STAMP=1127068457
input archived log thread=1 sequence=13 RECID=7 STAMP=1127072897
input archived log thread=1 sequence=14 RECID=8 STAMP=1127082650
input archived log thread=1 sequence=15 RECID=9 STAMP=1127082650
input archived log thread=1 sequence=16 RECID=10 STAMP=1127091893
input archived log thread=1 sequence=17 RECID=11 STAMP=1127095578
input archived log thread=1 sequence=18 RECID=12 STAMP=1127138430
input archived log thread=1 sequence=19 RECID=13 STAMP=1127162845
input archived log thread=1 sequence=20 RECID=14 STAMP=1127163539
input archived log thread=1 sequence=21 RECID=15 STAMP=1127163963
input archived log thread=1 sequence=22 RECID=16 STAMP=1127232200
input archived log thread=1 sequence=23 RECID=17 STAMP=1127312586
input archived log thread=1 sequence=24 RECID=18 STAMP=1127383579
input archived log thread=1 sequence=25 RECID=19 STAMP=1127397371
channel ORA_DISK_1: starting piece 1 at 29-JAN-23
channel ORA_DISK_1: finished piece 1 at 29-JAN-23
piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_annnn_TAG20230129T135611_kxd2mvpm_.bkp tag=TAG20230129T135611 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
Finished backup at 29-JAN-23
Starting backup at 29-JAN-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD3/test01.dbf
input datafile file number=00008 name=/nfs/app/oracle/oradata/PROD3/nfs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD3/index.dbf
channel ORA_DISK_1: starting piece 1 at 29-JAN-23
channel ORA_DISK_1: finished piece 1 at 29-JAN-23
piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_nnndf_TAG20230129T135636_kxd2nnyp_.bkp tag=TAG20230129T135636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD3/system01.dbf
channel ORA_DISK_1: starting piece 1 at 29-JAN-23
channel ORA_DISK_1: finished piece 1 at 29-JAN-23
piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_nnndf_TAG20230129T135636_kxd2np2m_.bkp tag=TAG20230129T135636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD3/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 29-JAN-23
channel ORA_DISK_1: finished piece 1 at 29-JAN-23
piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_nnndf_TAG20230129T135636_kxd2o58y_.bkp tag=TAG20230129T135636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD3/undotbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/PROD3/oltp.dbf
channel ORA_DISK_1: starting piece 1 at 29-JAN-23
channel ORA_DISK_1: finished piece 1 at 29-JAN-23
piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_nnndf_TAG20230129T135636_kxd2odj8_.bkp tag=TAG20230129T135636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/PROD3/tools.dbf
channel ORA_DISK_1: starting piece 1 at 29-JAN-23
channel ORA_DISK_1: finished piece 1 at 29-JAN-23
piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_nnndf_TAG20230129T135636_kxd2ofo0_.bkp tag=TAG20230129T135636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 29-JAN-23
channel ORA_DISK_1: finished piece 1 at 29-JAN-23
piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_ncsnf_TAG20230129T135636_kxd2ohsy_.bkp tag=TAG20230129T135636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-JAN-23
Starting backup at 29-JAN-23
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=26 RECID=20 STAMP=1127397424
channel ORA_DISK_1: starting piece 1 at 29-JAN-23
channel ORA_DISK_1: finished piece 1 at 29-JAN-23
piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_annnn_TAG20230129T135704_kxd2ok2h_.bkp tag=TAG20230129T135704 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-JAN-23
10、复制数据库
[oracle@odd201 ~]$ export ORACLE_SID=PROD3
[oracle@odd201 ~]$ rman target / auxiliary sys/oracle@prod4
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jan 30 15:36:39 2023
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD3 (DBID=1740238102)
connected to auxiliary database: PROD4 (not mounted)
RMAN> duplicate target database to prod4;
Starting Duplicate Db at 30-JAN-23
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 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 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 620760920 bytes
Database Buffers 440401920 bytes
Redo Buffers 5554176 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''PROD3'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''PROD4'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''PROD3'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''PROD4'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 620760920 bytes
Database Buffers 440401920 bytes
Redo Buffers 5554176 bytes
Starting restore at 30-JAN-23
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_ncnnf_TAG20230129T164312_kxddf24q_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_ncnnf_TAG20230129T164312_kxddf24q_.bkp tag=TAG20230129T164312
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/PROD4/control01.ctl
output file name=/u01/app/oracle/oradata/PROD4/control02.ctl
Finished restore at 30-JAN-23
database mounted
contents of Memory Script:
{
set until scn 587419;
set newname for datafile 1 to
"/u01/app/oracle/oradata/PROD4/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/PROD4/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/PROD4/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/PROD4/test01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/PROD4/index.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/PROD4/tools.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/PROD4/oltp.dbf";
set newname for datafile 8 to
"/u01/app/oracle/oradata/PROD4/nfs01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET until clause
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 30-JAN-23
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/PROD4/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD4/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD4/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD4/test01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD4/index.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD4/tools.dbf
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/PROD4/oltp.dbf
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/PROD4/nfs01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_nnndf_TAG20230129T164132_kxdd9x20_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/PROD3/backupset/2023_01_29/o1_mf_nnndf_TAG20230129T164132_kxdd9x20_.bkp tag=TAG20230129T164132
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:46
Finished restore at 30-JAN-23
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=1127490223 file name=/u01/app/oracle/oradata/PROD4/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=1127490223 file name=/u01/app/oracle/oradata/PROD4/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=1127490223 file name=/u01/app/oracle/oradata/PROD4/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=1127490223 file name=/u01/app/oracle/oradata/PROD4/test01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=13 STAMP=1127490223 file name=/u01/app/oracle/oradata/PROD4/index.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=14 STAMP=1127490223 file name=/u01/app/oracle/oradata/PROD4/tools.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=15 STAMP=1127490223 file name=/u01/app/oracle/oradata/PROD4/oltp.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=16 STAMP=1127490223 file name=/u01/app/oracle/oradata/PROD4/nfs01.dbf
contents of Memory Script:
{
set until scn 587419;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 30-JAN-23
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 27 is already on disk as file /home/oracle/files/arch1/1_27_1127064534.dbf
archived log for thread 1 with sequence 28 is already on disk as file /home/oracle/files/arch1/1_28_1127064534.dbf
archived log file name=/home/oracle/files/arch1/1_27_1127064534.dbf thread=1 sequence=27
archived log file name=/home/oracle/files/arch1/1_28_1127064534.dbf thread=1 sequence=28
media recovery complete, elapsed time: 00:00:00
Finished recover at 30-JAN-23
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''PROD4'' 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
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 620760920 bytes
Database Buffers 440401920 bytes
Redo Buffers 5554176 bytes
sql statement: alter system set db_name = ''PROD4'' 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 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 620760920 bytes
Database Buffers 440401920 bytes
Redo Buffers 5554176 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "PROD4" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/PROD4/redo01.log' ) SIZE 100 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/PROD4/redo02.log' ) SIZE 100 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/PROD4/redo03.log' ) SIZE 100 M REUSE
DATAFILE
'/u01/app/oracle/oradata/PROD4/system01.dbf'
CHARACTER SET US7ASCII
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/PROD4/temp01.dbf";
set newname for tempfile 2 to
"/u01/app/oracle/oradata/PROD4/temp1.dbf";
set newname for tempfile 3 to
"/u01/app/oracle/oradata/PROD4/temp2.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/PROD4/sysaux01.dbf",
"/u01/app/oracle/oradata/PROD4/undotbs01.dbf",
"/u01/app/oracle/oradata/PROD4/test01.dbf",
"/u01/app/oracle/oradata/PROD4/index.dbf",
"/u01/app/oracle/oradata/PROD4/tools.dbf",
"/u01/app/oracle/oradata/PROD4/oltp.dbf",
"/u01/app/oracle/oradata/PROD4/nfs01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/PROD4/temp01.dbf in control file
renamed tempfile 2 to /u01/app/oracle/oradata/PROD4/temp1.dbf in control file
renamed tempfile 3 to /u01/app/oracle/oradata/PROD4/temp2.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD4/sysaux01.dbf RECID=1 STAMP=1127490496
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD4/undotbs01.dbf RECID=2 STAMP=1127490496
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD4/test01.dbf RECID=3 STAMP=1127490496
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD4/index.dbf RECID=4 STAMP=1127490497
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD4/tools.dbf RECID=5 STAMP=1127490497
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD4/oltp.dbf RECID=6 STAMP=1127490497
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD4/nfs01.dbf RECID=7 STAMP=1127490497
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=1127490496 file name=/u01/app/oracle/oradata/PROD4/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1127490496 file name=/u01/app/oracle/oradata/PROD4/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1127490496 file name=/u01/app/oracle/oradata/PROD4/test01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=1127490497 file name=/u01/app/oracle/oradata/PROD4/index.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=1127490497 file name=/u01/app/oracle/oradata/PROD4/tools.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=1127490497 file name=/u01/app/oracle/oradata/PROD4/oltp.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=7 STAMP=1127490497 file name=/u01/app/oracle/oradata/PROD4/nfs01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 30-JAN-23
10、验证数据和表情况
[oracle@odd201 ~]$ export ORACLE_SID=PROD4
[oracle@odd201 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Jan 30 15:51:35 2023
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select count(*) from scott.t;
COUNT(*)
----------
0
SQL> select instance_name , status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
PROD4 OPEN
本机无备份下也可复制
[oracle@lt168 oracle]$ rman target / auxiliary sys/system@prod
Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jan 31 15:44:27 2023
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1653981483)
connected to auxiliary database: PROD (not mounted)
RMAN> duplicate target database to prod from active database ;
Starting Duplicate Db at 31-JAN-23
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK
contents of Memory Script:
{
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 1071333376 bytes
Fixed Size 1349732 bytes
Variable Size 620758940 bytes
Database Buffers 444596224 bytes
Redo Buffers 4628480 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''ORCL'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''PROD'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/u01/oracle/oradata/prod/control01.ctl';
restore clone controlfile to '/u01/oracle/fast_recovery_area/prod/control02.ctl' from
'/u01/oracle/oradata/prod/control01.ctl';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''PROD'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 1071333376 bytes
Fixed Size 1349732 bytes
Variable Size 620758940 bytes
Database Buffers 444596224 bytes
Redo Buffers 4628480 bytes
Starting backup at 31-JAN-23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=39 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/oracle/product/11.2.0.3/dbhome_1/dbs/snapcf_orcl.f tag=TAG20230131T154517 RECID=3 STAMP=1127576718
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 31-JAN-23
Starting restore at 31-JAN-23
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=17 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 31-JAN-23
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"/u01/oracle/oradata/prod/system01.dbf";
set newname for datafile 2 to
"/u01/oracle/oradata/prod/sysaux01.dbf";
set newname for datafile 3 to
"/u01/oracle/oradata/prod/undotbs01.dbf";
set newname for datafile 4 to
"/u01/oracle/oradata/prod/users01.dbf";
set newname for datafile 5 to
"/u01/oracle/oradata/prod/example01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/oracle/oradata/prod/system01.dbf" datafile
2 auxiliary format
"/u01/oracle/oradata/prod/sysaux01.dbf" datafile
3 auxiliary format
"/u01/oracle/oradata/prod/undotbs01.dbf" datafile
4 auxiliary format
"/u01/oracle/oradata/prod/users01.dbf" datafile
5 auxiliary format
"/u01/oracle/oradata/prod/example01.dbf" ;
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
Starting backup at 31-JAN-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/oracle/oradata/orcl/system01.dbf
output file name=/u01/oracle/oradata/prod/system01.dbf tag=TAG20230131T154526
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/oracle/oradata/orcl/sysaux01.dbf
output file name=/u01/oracle/oradata/prod/sysaux01.dbf tag=TAG20230131T154526
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=/u01/oracle/oradata/orcl/example01.dbf
output file name=/u01/oracle/oradata/prod/example01.dbf tag=TAG20230131T154526
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/oracle/oradata/orcl/undotbs01.dbf
output file name=/u01/oracle/oradata/prod/undotbs01.dbf tag=TAG20230131T154526
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbf
output file name=/u01/oracle/oradata/prod/users01.dbf tag=TAG20230131T154526
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 31-JAN-23
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/u01/oracle/fast_recovery_area/ORCL/archivelog/2023_01_31/o1_mf_1_9_kxkkxs9k_.arc" auxiliary format
"/u01/oracle/fast_recovery_area/PROD/archivelog/2023_01_31/o1_mf_1_9_%u_.arc" ;
catalog clone recovery area;
switch clone datafile all;
}
executing Memory Script
Starting backup at 31-JAN-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=9 RECID=4 STAMP=1127576891
output file name=/u01/oracle/fast_recovery_area/PROD/archivelog/2023_01_31/o1_mf_1_9_0e1jat9s_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:03
Finished backup at 31-JAN-23
searching for all files in the recovery area
List of Files Unknown to the Database
=====================================
File Name: /u01/oracle/fast_recovery_area/PROD/archivelog/2023_01_31/o1_mf_1_9_0e1jat9s_.arc
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/oracle/fast_recovery_area/PROD/archivelog/2023_01_31/o1_mf_1_9_0e1jat9s_.arc
datafile 1 switched to datafile copy
input datafile copy RECID=3 STAMP=1127576896 file name=/u01/oracle/oradata/prod/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=4 STAMP=1127576896 file name=/u01/oracle/oradata/prod/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=1127576896 file name=/u01/oracle/oradata/prod/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=1127576896 file name=/u01/oracle/oradata/prod/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=1127576896 file name=/u01/oracle/oradata/prod/example01.dbf
contents of Memory Script:
{
set until scn 893229;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 31-JAN-23
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 9 is already on disk as file /u01/oracle/fast_recovery_area/PROD/archivelog/2023_01_31/o1_mf_1_9_0e1jat9s_.arc
archived log file name=/u01/oracle/fast_recovery_area/PROD/archivelog/2023_01_31/o1_mf_1_9_0e1jat9s_.arc thread=1 sequence=9
media recovery complete, elapsed time: 00:00:01
Finished recover at 31-JAN-23
Oracle instance started
Total System Global Area 1071333376 bytes
Fixed Size 1349732 bytes
Variable Size 620758940 bytes
Database Buffers 444596224 bytes
Redo Buffers 4628480 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''PROD'' 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 = ''PROD'' 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 1071333376 bytes
Fixed Size 1349732 bytes
Variable Size 620758940 bytes
Database Buffers 444596224 bytes
Redo Buffers 4628480 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "PROD" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/oracle/oradata/prod/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/oracle/oradata/prod/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u01/oracle/oradata/prod/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/oracle/oradata/prod/system01.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/oracle/oradata/prod/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/oracle/oradata/prod/sysaux01.dbf",
"/u01/oracle/oradata/prod/undotbs01.dbf",
"/u01/oracle/oradata/prod/users01.dbf",
"/u01/oracle/oradata/prod/example01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/oracle/oradata/prod/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/oracle/oradata/prod/sysaux01.dbf RECID=1 STAMP=1127576916
cataloged datafile copy
datafile copy file name=/u01/oracle/oradata/prod/undotbs01.dbf RECID=2 STAMP=1127576916
cataloged datafile copy
datafile copy file name=/u01/oracle/oradata/prod/users01.dbf RECID=3 STAMP=1127576916
cataloged datafile copy
datafile copy file name=/u01/oracle/oradata/prod/example01.dbf RECID=4 STAMP=1127576916
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=1127576916 file name=/u01/oracle/oradata/prod/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1127576916 file name=/u01/oracle/oradata/prod/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1127576916 file name=/u01/oracle/oradata/prod/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=1127576916 file name=/u01/oracle/oradata/prod/example01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 31-JAN-23