Oracle Linux环境单实例迁移到异机单实例
一、Active database duplicate
目的:可实现不停机,备份不落地通过网络完成数据库RMAN的还原(复制)
源数据库
ip:192.168.212.233
db_name:orcl
目标数据库
ip:192.168.149.129
新db_name:orcl3
操作步骤:
1、编辑目标数据库的参数文件
[oracle@gs dbs]$vi $ORACLE_HOME/dbs/initorcl3.ora
control_files='/u01/app/oracle/oradata/orcl3/control01.ctl','/u01/app/oracle/oradata/orcl3/control02.ctl'
db_block_size=8192
db_name='orcl3'
audit_trail='DB'
db_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl3'
log_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl3'
log_archive_dest_1='location=/u01/arch3'
processes=1000
remote_login_passwordfile='EXCLUSIVE'
compatible='11.2.0.4.0'
sga_target=700m
pga_aggregate_target=300m
open_cursors=300
2、拷贝源数据库的密码文件到目标数据库并按规范重命名
[oracle@gs dbs]$ mv orapworcl orapworcl3
3、创建目标端文件目录结构
[oracle@gs rman]$ mkdir -p /u01/app/oracle/oradata/orcl3/
[oracle@gs rman]$ mkdir -p /u01/arch
[oracle@gs rman]$ mkdir -p /u01/app/oracle/admin/orcl3/adump
4、配置目标端静态监听
[oracle@gs dbs]$vi $ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl3)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = orcl3)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = gs)(PORT = 1521))
)
)
监听文件重新加载下
5、配置源数据库端以及目标端tnsnames用于连接源数据库以及辅助实例
[oracle@gs dbs]$vi $ORACLE_HOME/network/admin/tnsnames.ora
source =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.212.233)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
target =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = gs)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl3)
)
)
备注:源数据库需要与目标数据库使用相同的tnsnames内容,源数据库会通过TNS传输数据到目标数据库
6、在目标数据库启动到nomount状态
SQL> startup nomount;
ORACLE instance started.
7、在目标数据库用RMAN 连接源数据库以及辅助实例
[oracle@gs admin]$ rman target sys/ORACLE@source auxiliary sys/ORACLE@target
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jun 25 17:26:11 2018
Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1499390015)
connected to auxiliary database: ORCL3 (not mounted)
8、开始复制
RMAN> DUPLICATE TARGET DATABASE TO orcl3 FROM ACTIVE DATABASE NOFILENAMECHECK;
Starting Duplicate Db at 2018/06/25 17:54:40
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1149 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 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 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 =
''ORCL3'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/u01/app/oracle/oradata/orcl3/control01.ctl';
restore clone controlfile to '/u01/app/oracle/oradata/orcl3/control02.ctl' from
'/u01/app/oracle/oradata/orcl3/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 = ''ORCL3'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
Starting backup at 2018/06/25 17:54:58
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=577 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_orcl.f tag=TAG20180625T175539 RECID=1 STAMP=979754140
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 2018/06/25 17:55:01
Starting restore at 2018/06/25 17:55:01
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1149 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 2018/06/25 17:55:03
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"/u01/app/oracle/oradata/orcl3/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/orcl3/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/orcl3/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/orcl3/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/orcl3/cs1.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/orcl3/cs2.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/orcl3/cs.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/orcl3/system01.dbf" datafile
2 auxiliary format
"/u01/app/oracle/oradata/orcl3/sysaux01.dbf" datafile
3 auxiliary format
"/u01/app/oracle/oradata/orcl3/undotbs01.dbf" datafile
4 auxiliary format
"/u01/app/oracle/oradata/orcl3/users01.dbf" datafile
5 auxiliary format
"/u01/app/oracle/oradata/orcl3/cs1.dbf" datafile
6 auxiliary format
"/u01/app/oracle/oradata/orcl3/cs2.dbf" datafile
7 auxiliary format
"/u01/app/oracle/oradata/orcl3/cs.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
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 2018/06/25 17:55:07
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
output file name=/u01/app/oracle/oradata/orcl3/sysaux01.dbf tag=TAG20180625T175549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
output file name=/u01/app/oracle/oradata/orcl3/undotbs01.dbf tag=TAG20180625T175549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
output file name=/u01/app/oracle/oradata/orcl3/system01.dbf tag=TAG20180625T175549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/cs.dbf
output file name=/u01/app/oracle/oradata/orcl3/cs.dbf tag=TAG20180625T175549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/cs1.dbf
output file name=/u01/app/oracle/oradata/orcl3/cs1.dbf tag=TAG20180625T175549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/cs2.dbf
output file name=/u01/app/oracle/oradata/orcl3/cs2.dbf tag=TAG20180625T175549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output file name=/u01/app/oracle/oradata/orcl3/users01.dbf tag=TAG20180625T175549
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2018/06/25 18:00:15
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/arch/1_204_971609279.dbf" auxiliary format
"/u01/arch3/1_204_971609279.dbf" ;
catalog clone archivelog "/u01/arch3/1_204_971609279.dbf";
switch clone datafile all;
}
executing Memory Script
Starting backup at 2018/06/25 18:00:15
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=204 RECID=136 STAMP=979754457
output file name=/u01/arch3/1_204_971609279.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 2018/06/25 18:00:16
cataloged archived log
archived log file name=/u01/arch3/1_204_971609279.dbf RECID=136 STAMP=979754417
datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=979754417 file name=/u01/app/oracle/oradata/orcl3/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=2 STAMP=979754417 file name=/u01/app/oracle/oradata/orcl3/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=3 STAMP=979754417 file name=/u01/app/oracle/oradata/orcl3/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=979754417 file name=/u01/app/oracle/oradata/orcl3/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=5 STAMP=979754417 file name=/u01/app/oracle/oradata/orcl3/cs1.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=6 STAMP=979754417 file name=/u01/app/oracle/oradata/orcl3/cs2.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=7 STAMP=979754417 file name=/u01/app/oracle/oradata/orcl3/cs.dbf
contents of Memory Script:
{
set until scn 6302244;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 2018/06/25 18:00:17
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 204 is already on disk as file /u01/arch3/1_204_971609279.dbf
archived log file name=/u01/arch3/1_204_971609279.dbf thread=1 sequence=204
media recovery complete, elapsed time: 00:00:00
Finished recover at 2018/06/25 18:00:18
Oracle instance started
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''ORCL3'' 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 = ''ORCL3'' 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 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL3" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/orcl3/redo01.log' ) SIZE 100 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/orcl3/redo02.log' ) SIZE 100 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/orcl3/redo03.log' ) SIZE 100 M REUSE,
GROUP 4 ( '/u01/app/oracle/oradata/orcl3/redo04.log' ) SIZE 100 M REUSE,
GROUP 5 ( '/u01/app/oracle/oradata/orcl3/redo05.log' ) SIZE 100 M REUSE
DATAFILE
'/u01/app/oracle/oradata/orcl3/system01.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/orcl3/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl3/sysaux01.dbf",
"/u01/app/oracle/oradata/orcl3/undotbs01.dbf",
"/u01/app/oracle/oradata/orcl3/users01.dbf",
"/u01/app/oracle/oradata/orcl3/cs1.dbf",
"/u01/app/oracle/oradata/orcl3/cs2.dbf",
"/u01/app/oracle/oradata/orcl3/cs.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/orcl3/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/sysaux01.dbf RECID=1 STAMP=979754430
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/undotbs01.dbf RECID=2 STAMP=979754430
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/users01.dbf RECID=3 STAMP=979754430
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/cs1.dbf RECID=4 STAMP=979754430
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/cs2.dbf RECID=5 STAMP=979754430
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/cs.dbf RECID=6 STAMP=979754430
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=979754430 file name=/u01/app/oracle/oradata/orcl3/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=979754430 file name=/u01/app/oracle/oradata/orcl3/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=979754430 file name=/u01/app/oracle/oradata/orcl3/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=979754430 file name=/u01/app/oracle/oradata/orcl3/cs1.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=979754430 file name=/u01/app/oracle/oradata/orcl3/cs2.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=979754430 file name=/u01/app/oracle/oradata/orcl3/cs.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 2018/06/25 18:00:34
9、检查数据库状态
SQL> select status from v$instance;
STATUS
------------------------------------
OPEN
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ WRITE
duplicate之后数据库已经open
10、添加新数据库到/etc/oratab
orcl3:/u01/app/oracle/product/11.2.0/db_1:N
11、检查下dbs目录物理路径是否存在spfile
shutdown immediate;
create spfile from pfile;
startup;
二、Backup-based duplicate
DUPLICATE Without Target And Recovery Catalog Connection
源数据库
db_name:orcl
目标数据库
新db_name:orcl3
目的:可拷贝源数据库的RMAN备份到目标主机,实现基于备份文件的duplicate。
操作步骤:
1、拷贝源数据库RMAN备份(数据文件、控制文件、密码文件、归档备份)到目标主机RMAN备份目录
2、在目标主机编辑参数文件
[oracle@orcldb4 rman]$ vi /u01/app/oracle/product/11.2.0/db_1/dbs/initorcl3.ora
control_files='/u01/app/oracle/oradata/orcl3/control01.ctl','/u01/app/oracle/oradata/orcl3/control02.ctl'
db_block_size=8192
db_name='orcl3'
audit_trail='DB'
db_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl3'
log_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl3'
log_archive_dest_1='location=/u01/arch3'
processes=1000
remote_login_passwordfile='EXCLUSIVE'
compatible='11.2.0.4.0'
sga_target=700m
pga_aggregate_target=300m
open_cursors=300
3、创建目标端文件目录结构
[oracle@gs rman]$ mkdir -p /u01/app/oracle/oradata/orcl3/
[oracle@gs rman]$ mkdir -p /u01/arch
[oracle@gs rman]$ mkdir -p /u01/app/oracle/admin/orcl3/adump
4、目标数据库的辅助实例启动到nomount
5、RMAN连接辅助实例
[oracle@gs dbs]$ rman auxiliary /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jun 25 15:51:28 2018
Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to auxiliary database: ORCL3 (not mounted)
6、开始RMAN duplicate复制
RMAN> duplicate database to orcl3 backup location '/u01/rman3';
Starting Duplicate Db at 2018/06/25 15:51:34
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 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 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 =
''ORCL3'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile from '/u01/rman3/control_c-1499390015-20180625-01.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 = ''ORCL3'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
Starting restore at 2018/06/25 15:51:52
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1149 device type=DISK
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl3/control01.ctl
output file name=/u01/app/oracle/oradata/orcl3/control02.ctl
Finished restore at 2018/06/25 15:51:53
database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1149 device type=DISK
contents of Memory Script:
{
set until scn 6294249;
set newname for datafile 1 to
"/u01/app/oracle/oradata/orcl3/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/orcl3/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/orcl3/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/orcl3/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/orcl3/cs1.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/orcl3/cs2.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/orcl3/cs.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
Starting restore at 2018/06/25 15:51:58
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/orcl3/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl3/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl3/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl3/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl3/cs1.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl3/cs2.dbf
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/orcl3/cs.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman3/full_db_20180625_0ct6bcik_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman3/full_db_20180625_0ct6bcik_1_1.bak tag=DB_FULL
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 2018/06/25 15:52:13
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=979746733 file name=/u01/app/oracle/oradata/orcl3/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=9 STAMP=979746733 file name=/u01/app/oracle/oradata/orcl3/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=979746733 file name=/u01/app/oracle/oradata/orcl3/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=979746733 file name=/u01/app/oracle/oradata/orcl3/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=12 STAMP=979746733 file name=/u01/app/oracle/oradata/orcl3/cs1.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=13 STAMP=979746733 file name=/u01/app/oracle/oradata/orcl3/cs2.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=14 STAMP=979746733 file name=/u01/app/oracle/oradata/orcl3/cs.dbf
contents of Memory Script:
{
set until scn 6294249;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 2018/06/25 15:52:13
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=203
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman3/arch_20180625_0dt6bcir_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman3/arch_20180625_0dt6bcir_1_1.bak tag=TAG20180625T145523
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/arch3/1_203_971609279.dbf thread=1 sequence=203
channel clone_default: deleting archived log(s)
archived log file name=/u01/arch3/1_203_971609279.dbf RECID=1 STAMP=979746734
media recovery complete, elapsed time: 00:00:00
Finished recover at 2018/06/25 15:52:15
Oracle instance started
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''ORCL3'' 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 = ''ORCL3'' 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 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL3" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/orcl3/redo01.log' ) SIZE 100 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/orcl3/redo02.log' ) SIZE 100 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/orcl3/redo03.log' ) SIZE 100 M REUSE,
GROUP 4 ( '/u01/app/oracle/oradata/orcl3/redo04.log' ) SIZE 100 M REUSE,
GROUP 5 ( '/u01/app/oracle/oradata/orcl3/redo05.log' ) SIZE 100 M REUSE
DATAFILE
'/u01/app/oracle/oradata/orcl3/system01.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/orcl3/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl3/sysaux01.dbf",
"/u01/app/oracle/oradata/orcl3/undotbs01.dbf",
"/u01/app/oracle/oradata/orcl3/users01.dbf",
"/u01/app/oracle/oradata/orcl3/cs1.dbf",
"/u01/app/oracle/oradata/orcl3/cs2.dbf",
"/u01/app/oracle/oradata/orcl3/cs.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/orcl3/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/sysaux01.dbf RECID=1 STAMP=979746746
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/undotbs01.dbf RECID=2 STAMP=979746746
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/users01.dbf RECID=3 STAMP=979746746
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/cs1.dbf RECID=4 STAMP=979746746
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/cs2.dbf RECID=5 STAMP=979746746
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl3/cs.dbf RECID=6 STAMP=979746746
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=979746746 file name=/u01/app/oracle/oradata/orcl3/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=979746746 file name=/u01/app/oracle/oradata/orcl3/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=979746746 file name=/u01/app/oracle/oradata/orcl3/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=979746746 file name=/u01/app/oracle/oradata/orcl3/cs1.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=979746746 file name=/u01/app/oracle/oradata/orcl3/cs2.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=979746746 file name=/u01/app/oracle/oradata/orcl3/cs.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 2018/06/25 15:52:30
7、检查数据库状态
SQL> select status from v$instance;
STATUS
------------------------------------
OPEN
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ WRITE
duplicate之后数据库已经open
8、添加新数据库到/etc/oratab
orcl3:/u01/app/oracle/product/11.2.0/db_1:N
9、检查下dbs目录物理路径是否存在spfile
shutdown immediate;
create spfile from pfile;
startup;