基于RMAN的同机数据库克隆(四)
7.25)(PORT = 1531))
)
(CONNECT_DATA =
(SERVICE_NAME = SYBO3.ORASRV.COM)
)
)
f、实施数据库克隆
--下面先启动辅助实例到nomount状态
[oracle@linux3 ~]$ export ORACLE_SID=sybo5
[oracle@linux3 ~]$ sqlplus / as sysdba
SQL> startup nomount pfile=/u01/oracle/db_1/dbs/initsybo5.ora;
ORACLE instance started.
--调用RMAN连接到目标数据库与辅助数据库
[oracle@linux3 ~]$ rman target sys/oracle@sybo3 auxiliary sys/oracle@sybo5
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 25 14:32:51 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: SYBO3 (DBID=2347733014)
connected to auxiliary database: SYBO5 (not mounted)
RMAN> run{
2> set newname for datafile 1 to '/u01/database/sybo5/oradata/system01.dbf';
3> set newname for datafile 2 to '/u01/database/sybo5/oradata/sysaux01.dbf';
4> set newname for datafile 3 to '/u01/database/sybo5/oradata/undotbs01.dbf';
5> set newname for datafile 4 to '/u01/database/sybo5/oradata/users01.dbf';
6> set newname for datafile 5 to '/u01/database/sybo5/oradata/example01.dbf';
7> set newname for tempfile 1 to '/u01/database/sybo5/oradata/temp01.dbf';
8> duplicate target database to sybo5
9> logfile
10> group 1 ('/u01/database/sybo5/redo/redo01a.log','/u01/database/sybo5/redo/redo01b.log') size 10m,
11> group 2 ('/u01/database/sybo5/redo/redo02a.log','/u01/database/sybo5/redo/redo02b.log') size 10m,
12> group 3 ('/u01/database/sybo5/redo/redo03a.log','/u01/database/sybo5/redo/redo03b.log') size 10m;
13> switch datafile all;
14> }
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 Duplicate Db at 2013/07/25 14:33:14
using target database control file instead of recovery catalog ---->
使用了原数据库的控制文件
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=134 device type=DISK
contents of Memory Script: ------->Oracle会自动生成auxiliary db的spfile
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script: ------->下面的SQL使用spfile重启auxiliary db到nomount状态
{
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 376635392 bytes
Fixed Size 1336652 bytes
Variable Size 260049588 bytes
Database Buffers 109051904 bytes
Redo Buffers 6197248 bytes
contents of Memory Script: ----->下面的这段SQL完成了一系列任务,见后面的分解
{
sql clone "alter system set db_name =
''SYBO3'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''SYBO5'' 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 = ''SYBO3'' comment= ''Modified by RMAN duplicate'' scope=spfile -->修改db_name
sql statement: alter system set db_unique_name = ''SYBO5'' comment= ''Modified by RMAN duplicate'' scope=spfile -->修改db_unique_name
Oracle instance shut down