实验平台: IBM AIX 5L + Oracle 11g
目标库信息:
ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/11.2.0/db_1
ORACLE_SID:orcl
IP: 172.30.2.40
辅助库信息:
ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/11.2.0/db_1
ORACLE_SID:orcl
IP: 172.30.2.56
在这里,我们以实例名相同的为例,实例名不同也一样,在pfile里修改对应参数就可以了。
步骤如下:
(1)构建辅助数据库目录结构
(2)创建pfile,并复制到辅助数据库,修改相关内容
(3)创建辅助实例口令文件
(4)RMAN 备份源库
(5)添加配置监听
(6)将源库备份文件拷贝到辅助库相同位置
(7)用pfile文件,将辅助数据库启动到nomount 状态
(8)执行RMAN duplicate命令复制数据库
(9)创建spfile文件
一.构建辅助数据库目录结构
1.1 Oracle data 目录
$ mkdir -p /u01/app/oracle/oradata/orcl
1.2 其他目录
$ mkdir -p /u01/app/oracle/admin/orcl/adump
$ mkdir -p /u01/app/oracle/admin/orcl/dpdump
$ mkdir -p /u01/app/oracle/admin/orcl/pfile
$ mkdir -p /u01/app/oracle/admin/orcl/scripts
$ mkdir -p /u01/app/oracle/diag
$ mkdir -p /u01/app/oracle/flash_recovery_area/orcl
二.创建pfile,复制到辅助数据库,并修改相关参数
2.1 在源库上创建pfile 文件
$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 11 08:26:48 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
idle> conn /as sysdba
Connected.
sys@ORCL> create pfile='/u01/initorcl.ora' from spfile;
File created.
2.2 用scp 命令将pfile 文件传到辅助库,要放在$ORACLE_HOME/dbs目录下,不然ORACLE 不识别。
$ scp initorcl.ora 172.30.2.56:/$ORACLE_HOME/dbs
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
initorcl.ora 100% 921 0.9KB/s 00:00
2.3 在辅助库上确认文件是否传送过来
$ cd $ORACLE_HOME/dbs
$ ls
init.ora initorcl.ora orapworcl
2.4 在辅助库上修改pfile参数
orcl.__db_cache_size=3288334336
orcl.__java_pool_size=16777216
orcl.__large_pool_size=16777216
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=2751463424
orcl.__sga_target=4127195136
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=754974720
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/flash_recovery_area/orcl/
control02.ctl'
*.db_block_size=8192
*.db_domain='saci.com.cn'
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.memory_target=6867124224
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
说明,在这里我没有做修改,因为我异机duplicate实例名相同,存储位置也相同。如果说你复制的不同的话,就需要修改相关的实例名。如果存储位置不同的话,还需要添加以下参数,对数据文件位置进行转换。
db_file_name_convert = ('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/mahee')
三.创建辅助实例ORCL的口令文件(需要和目标数据库相同,最好从目标数据库拷贝过来)
$ cd $Oracle_HOME/bin
$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=oracle entries=8
$ cd $ORACLE_HOME/dbs
$ ls
init.ora initorcl.ora orapworcl
Windows下oracle默认的位置是$ORACLE_HOME/database目录,文件名格式是pwdSID.ora。
Linux下oracle默认的位置是$ORACLE_HOME/dbs目录,文件名格式是orapwSID。创建完后,数据库需要重启动,新的口令文件才能生效。
四.RMAN 备份源库(目标数据库orcl)
172.30.2.40(目标数据库orcl)
$ rman target sys/oracle@orcl
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 08:40:43 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1275959622)
RMAN> RUN {
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> BACKUP FORMAT '/u02/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE TAG orcl_hot_db_bk;
5> sql 'alter system archive log current';
6> BACKUP FORMAT '/u02/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;
7> backup current controlfile tag='bak_ctlfile' format='/u02/backup/ctl_file_%U_%T';
8> backup spfile tag='spfile' format='/u02/backup/ORCL_spfile_%U_%T';
9> release channel c2;
10> release channel c1;
11> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=195 device type=DISK
allocated channel: c2
channel c2: SID=10 device type=DISK
Starting backup at 11-APR-11
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel c1: starting piece 1 at 11-APR-11
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
channel c2: starting piece 1 at 11-APR-11
channel c1: finished piece 1 at 11-APR-11
piece handle=/u02/backup/orcl_0cm9ga44_1_1_20110411 tag=ORCL_HOT_DB_BK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
channel c2: finished piece 1 at 11-APR-11
piece handle=/u02/backup/orcl_0dm9ga44_1_1_20110411 tag=ORCL_HOT_DB_BK comment=NONE
channel c2: backup set complete, elapsed time: 00:00:03
Finished backup at 11-APR-11
Starting Control File and SPFILE Autobackup at 11-APR-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748169351_6t61pqbg_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 11-APR-11
sql statement: alter system archive log current
Starting backup at 11-APR-11
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=8 RECID=3 STAMP=748149036
input archived log thread=1 sequence=9 RECID=4 STAMP=748169352
channel c1: starting piece 1 at 11-APR-11
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=10 RECID=5 STAMP=748169352
channel c2: starting piece 1 at 11-APR-11
channel c1: finished piece 1 at 11-APR-11
piece handle=/u02/backup/arch_0fm9ga48_1_1_20110411 tag=TAG20110411T084912 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
channel c1: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_8_6t5fvwtm_.arc RECID=3 STAMP=748149036
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_9_6t61prft_.arc RECID=4 STAMP=748169352
channel c2: finished piece 1 at 11-APR-11
piece handle=/u02/backup/arch_0gm9ga48_1_1_20110411 tag=TAG20110411T084912 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c2: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_10_6t61prlf_.arc RECID=5 STAMP=748169352
Finished backup at 11-APR-11
Starting backup at 11-APR-11
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 11-APR-11
channel c1: finished piece 1 at 11-APR-11
piece handle=/u02/backup/ctl_file_0hm9ga4a_1_1_20110411 tag=BAK_CTLFILE comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-APR-11
Starting backup at 11-APR-11
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 11-APR-11
channel c1: finished piece 1 at 11-APR-11
piece handle=/u02/backup/ORCL_spfile_0im9ga4c_1_1_20110411 tag=SPFILE comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-APR-11
Starting Control File and SPFILE Autobackup at 11-APR-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748169357_6t61px9v_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 11-APR-11
released channel: c2
released channel: c1
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Full 436.09M DISK 00:00:02 11-APR-11
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: ORCL_HOT_DB_BK
Piece Name: /u02/backup/orcl_0dm9ga44_1_1_20110411
List of Datafiles in backup set 5
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 1081802 11-APR-11 /u01/app/oracle/oradata/orcl/sysaux01.dbf
3 Full 1081802 11-APR-11 /u01/app/oracle/oradata/orcl/undotbs01.dbf
5 Full 1081802 11-APR-11 /u01/app/oracle/oradata/orcl/example01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Full 593.82M DISK 00:00:02 11-APR-11
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: ORCL_HOT_DB_BK
Piece Name: /u02/backup/orcl_0cm9ga44_1_1_20110411
List of Datafiles in backup set 6
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1081801 11-APR-11 /u01/app/oracle/oradata/orcl/system01.dbf
4 Full 1081801 11-APR-11 /u01/app/oracle/oradata/orcl/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7 Full 7.42M DISK 00:00:00 11-APR-11
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20110411T084911
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748169351_6t61pqbg_.bkp
SPFILE Included: Modification time: 10-APR-11
SPFILE db_unique_name: ORCL
Control File Included: Ckp SCN: 1081809 Ckp time: 11-APR-11
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
8 2.00K DISK 00:00:00 11-APR-11
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20110411T084912
Piece Name: /u02/backup/arch_0gm9ga48_1_1_20110411
List of Archived Logs in backup set 8
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 10 1081825 11-APR-11 1081833 11-APR-11
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
9 15.56M DISK 00:00:00 11-APR-11
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20110411T084912
Piece Name: /u02/backup/arch_0fm9ga48_1_1_20110411
List of Archived Logs in backup set 9
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 8 1066859 11-APR-11 1071335 11-APR-11
1 9 1071335 11-APR-11 1081825 11-APR-11
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 7.39M DISK 00:00:01 11-APR-11
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: BAK_CTLFILE
Piece Name: /u02/backup/ctl_file_0hm9ga4a_1_1_20110411
Control File Included: Ckp SCN: 1081853 Ckp time: 11-APR-11
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11 Full 80.00K DISK 00:00:00 11-APR-11
BP Key: 11 Status: AVAILABLE Compressed: NO Tag: SPFILE
Piece Name: /u02/backup/ORCL_spfile_0im9ga4c_1_1_20110411
SPFILE Included: Modification time: 10-APR-11
SPFILE db_unique_name: ORCL
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12 Full 7.42M DISK 00:00:00 11-APR-11
BP Key: 12 Status: AVAILABLE Compressed: NO Tag: TAG20110411T084917
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748169357_6t61px9v_.bkp
SPFILE Included: Modification time: 10-APR-11
SPFILE db_unique_name: ORCL
Control File Included: Ckp SCN: 1081866 Ckp time: 11-APR-11
RMAN>
五.添加,配置监听
5.1 在辅助库的listener.ora 文件中,添加如下内容
$ cd $Oracle_HOME/network/admin
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.2.56)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl.saci.com.cn)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = orcl)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
5.2 修改辅助库的tnsnames.ora 文件,添加如下内容
TARGETORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.2.40)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl.saci.com.cn)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.2.56)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.saci.com.cn)
)
)
AUXORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.2.56)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl.saci.com.cn)
)
)
5.3 修改源库的tnsnames.ora 文件,添加如下内容:
TARGETORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.2.40)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl.saci.com.cn)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.2.40)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.saci.com.cn)
)
)
AUXORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.2.56)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl.saci.com.cn)
)
)
建议使用net manager 工具从界面来修改,这样不容易出错.
六. 将源库的备份拷贝到辅助数据库的相同位置
这里有两种方法,一种直接在辅助库上建相同的目录结构,在用SCP 命令把这些备份文件copy过去,但是这样会占用大量的网络资源。还有一种就是建好目录结构后用NFS直接mount上去,我这里的实验是在局域网环境中,在这里我采用前一种方法。
6.1 在辅助库上建相同的备份目录结构
因为我们在源库上备份是备份到/u02/backup目录中的,所以我们在辅助库上也建这个目录
# mkdir -p /u02/backup
# chown Oracle:oinstall /u02/backup
# chmod 775 /u02/backup
6.2 利用scp拷贝目标数据库备份集到辅助数据库
$ cd /u02/backup
$ scp oracle@172.30.2.40:/u02/backup/* .
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
ORCL_spfile_0im9ga4c_1_1_20110411 100% 96KB 96.0KB/s 00:00
arch_0fm9ga48_1_1_20110411 100% 16MB 15.6MB/s 00:00
arch_0gm9ga48_1_1_20110411 100% 2560 2.5KB/s 00:00
ctl_file_0hm9ga4a_1_1_20110411 100% 7584KB 7.4MB/s 00:00
orcl_0cm9ga44_1_1_20110411 100% 594MB 59.4MB/s 00:10
orcl_0dm9ga44_1_1_20110411 100% 436MB 62.3MB/s 00:07
$ mkdir -p /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11
$ cd /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11
$ scp oracle@172.30.2.40:/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748169351_6t61pqbg_.bkp .
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
o1_mf_s_748169351_6t61pqbg_.bkp 100% 7616KB 7.4MB/s 00:00
$ scp oracle@172.30.2.40:/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748169357_6t61px9v_.bkp .
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
o1_mf_s_748169357_6t61px9v_.bkp 100% 7616KB 7.4MB/s 00:00
$ ls
o1_mf_s_748169351_6t61pqbg_.bkp o1_mf_s_748169357_6t61px9v_.bkp
七.启动辅助库至nomount 状态,注意使用pfile参数启动
$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 11 09:20:36 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup nomount pfile=?/dbs/initorcl.ora
ORACLE instance started.
Total System Global Area 6847938560 bytes
Fixed Size 2219808 bytes
Variable Size 3539992800 bytes
Database Buffers 3288334336 bytes
Redo Buffers 17391616 bytes
SQL> quit -- 启动后就退出session,因为在duplicata的时候不能有session连接
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
八.RMAN 连接到目标实例和辅助实例,运行duplicate 命令复制数据库
$ rman target sys/oracle@orcl auxiliary sys/oracle@auxorcl;
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 09:23:14 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1275959622)
connected to auxiliary database: ORCL (not mounted)
RMAN> duplicate target database to orcl nofilenamecheck
2> logfile
3> '/u01/app/oracle/oradata/orcl/redo01.dbf' size 50m,
4> '/u01/app/oracle/oradata/orcl/redo02.dbf' size 50m,
5> '/u01/app/oracle/oradata/orcl/redo03.dbf' size 50m;
Starting Duplicate Db at 11-APR-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=63 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;
-- 如果此时,辅助实例上有session连在上面,将一直等到session退出才能执行,如果等了很长时间还没有执行,不妨检查一下,有没有session连在数据库上。
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 6847938560 bytes
Fixed Size 2219808 bytes
Variable Size 3556770016 bytes
Database Buffers 3271557120 bytes
Redo Buffers 17391616 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 =
''ORCL'' 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 = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 6847938560 bytes
Fixed Size 2219808 bytes
Variable Size 3556770016 bytes
Database Buffers 3271557120 bytes
Redo Buffers 17391616 bytes
Starting restore at 11-APR-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=63 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
-- 开始restore 数据文件
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748169357_6t61px9v_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748169357_6t61px9v_.bkp tag=TAG20110411T084917
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/orcl/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/orcl/control02.ctl
Finished restore at 11-APR-11
database mounted
contents of Memory Script:
{
set until scn 1081833;
set newname for datafile 1 to
"/u01/app/oracle/oradata/orcl/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/orcl/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/orcl/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/orcl/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/orcl/example01.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
Starting restore at 11-APR-11
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/orcl/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/orcl_0cm9ga44_1_1_20110411
channel ORA_AUX_DISK_1: piece handle=/u02/backup/orcl_0cm9ga44_1_1_20110411 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
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 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/orcl_0dm9ga44_1_1_20110411
channel ORA_AUX_DISK_1: piece handle=/u02/backup/orcl_0dm9ga44_1_1_20110411 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 11-APR-11
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=3 STAMP=748171541 file name=/u01/app/oracle/oradata/orcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=4 STAMP=748171541 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=748171541 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=748171541 file name=/u01/app/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=748171541 file name=/u01/app/oracle/oradata/orcl/example01.dbf
contents of Memory Script:
{
set until scn 1081833;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 11-APR-11
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=9
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_0fm9ga48_1_1_20110411
channel ORA_AUX_DISK_1: piece handle=/u02/backup/arch_0fm9ga48_1_1_20110411 tag=TAG20110411T084912
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/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_9_6t63v6q8_.arc thread=1 sequence=9
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_9_6t63v6q8_.arc RECID=6 STAMP=748171542
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=10
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_0gm9ga48_1_1_20110411
channel ORA_AUX_DISK_1: piece handle=/u02/backup/arch_0gm9ga48_1_1_20110411 tag=TAG20110411T084912
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/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_10_6t63v7ys_.arc thread=1 sequence=10
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_10_6t63v7ys_.arc RECID=7 STAMP=748171543
media recovery complete, elapsed time: 00:00:00
Finished recover at 11-APR-11
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''ORCL'' 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 6847938560 bytes
Fixed Size 2219808 bytes
Variable Size 3556770016 bytes
Database Buffers 3271557120 bytes
Redo Buffers 17391616 bytes
sql statement: alter system set db_name = ''ORCL'' 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 6847938560 bytes
Fixed Size 2219808 bytes
Variable Size 3556770016 bytes
Database Buffers 3271557120 bytes
Redo Buffers 17391616 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG -- 创建新的控制文件
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/orcl/redo01.dbf' SIZE 50 M ,
GROUP 2 '/u01/app/oracle/oradata/orcl/redo02.dbf' SIZE 50 M ,
GROUP 3 '/u01/app/oracle/oradata/orcl/redo03.dbf' SIZE 50 M
DATAFILE
'/u01/app/oracle/oradata/orcl/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/orcl/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/sysaux01.dbf",
"/u01/app/oracle/oradata/orcl/undotbs01.dbf",
"/u01/app/oracle/oradata/orcl/users01.dbf",
"/u01/app/oracle/oradata/orcl/example01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/orcl/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf RECID=1 STAMP=748171563
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf RECID=2 STAMP=748171563
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/users01.dbf RECID=3 STAMP=748171563
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/example01.dbf RECID=4 STAMP=748171563
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=748171563 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=748171563 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=748171563 file name=/u01/app/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=748171563 file name=/u01/app/oracle/oradata/orcl/example01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 11-APR-11
RMAN>
注明: 这里地方有2个地方需要说明:
(1) nofilenamecheck 参数:
如果在复制时,位置不同时,我们会用参数db_file_name_convert 对文件位置进行转换。 但是在这个复制示例中我们用的是相同的位置。 所以这里必须加上nofilenamecheck参数。 该参数通知复制操作不必在执行还原操作前确认文件名是不同的。如果没有指定nofilenamecheck参数,rman会给出如下错误:
RMAN-05001: auxiliary filename /u01/app/oracle/oradata/orcl/example01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u01/app/oracle/oradata/orcl/users01.dbf conflicts with a file used by the target database
(2) logfile 参数:
在完成复制进程并执行最后一条open resetlogs命令时,RMAN 必须为辅助数据库构建全新的日志文件。 如上面命令所示,我们可以在duplicate 命令中指定logfile参数,并指定使用的日志文件的大小,数目和位置。 还可以在pfile里指定log_file_name_convert 参数来进行转换。 这种方法相对而言要简单一点。
九.创建spfile,并验证数据库
通过上面8步的操作,复制操作已经完成,我们现在创建一个spfile。
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora';
File created.
SQL> select name from v$database;
NAME
---------
ORCL
SQL> select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME FILE_NAME
------------------ --------------------------------------------------
SYSTEM /u01/app/oracle/oradata/orcl/system01.dbf
SYSAUX /u01/app/oracle/oradata/orcl/sysaux01.dbf
UNDOTBS1 /u01/app/oracle/oradata/orcl/undotbs01.dbf
USERS /u01/app/oracle/oradata/orcl/users01.dbf
EXAMPLE /u01/app/oracle/oradata/orcl/example01.dbf
到此,Oracle 11g 异机duplicate数据库实验完成。
相关推荐
Oracle 11gR2 使用 RMAN duplicate from active database 复制数据库 Oracle 11gR2 中使用 RMAN duplicate from active database 复制数据库是一种高效的数据库复制方法。这种方法可以直接从活动数据库复制,省去...
在异机复制数据库的场景中,RMAN允许我们将一个数据库的完整副本复制到另一台机器上,这对于灾难恢复、测试环境的构建或数据迁移等任务非常有用。以下是如何使用RMAN进行异机复制数据库的详细步骤: 1. **构建辅助...
本文档主要介绍 Oracle Rman Active Database Duplicate 迁移方案,适用于 Oracle 11g/12c 版本。该方案旨在帮助数据库管理员快速迁移数据库,减少迁移时间和风险。 第 1 章概述 ================ 本文档将介绍 ...
### ORACLE RMAN DUPLICATE 数据库复制详解 #### 概述 在Oracle环境中,通过RMAN(Recovery Manager)工具可以高效地复制整个数据库。本文将详细介绍如何利用RMAN的`DUPLICATE`命令来实现数据库的复制,并针对两种...
在 **Oracle 11g R2** 版本中,提供了两种主要的方式来创建 Duplicate Database: 1. **Active Database Duplication**:这是一种通过网络直接将目标数据库的数据复制到辅助数据库的方式。这种方式不需要先对目标...
### RMAN高级应用之Duplicate复制数据库 #### 一、基本概述 在Oracle环境中,RMAN (Recovery Manager) 是一种非常强大的工具,用于备份、恢复和灾难恢复等操作。其中,“Duplicate”命令允许用户在保留现有数据库...
Oracle数据库在windows上的复制方法。
### Oracle 数据库通过 RMAN 实现 Data Guard 部署详解 #### 一、概述 在企业级应用环境中,为了确保数据的安全性与业务连续性,Oracle Data Guard 成为了一种广泛采用的数据保护技术。本文将详细介绍如何通过 ...
至于提供的第二个文件"MySQL主从复制、搭建、状态检查、中断排查及备库重做 实战手册.pdf",虽然与Oracle 11gR2的RMAN和Data Guard不直接相关,但它讲述了MySQL的主从复制,这是另一种数据库高可用性方案,适用于对...
RMAN高级应用之Duplicate复制数据库
RMAN(Recovery Manager)是Oracle提供的一种强大的数据库备份和恢复工具。在本文中,我们将深入探讨如何使用Legato配合RMAN来备份Oracle数据库中的数据文件和归档日志。 一、RMAN简介 RMAN是Oracle数据库管理员的...
### Oracle数据库RMAN手册知识点详解 #### 一、概述 Oracle Recovery Manager (RMAN) 是一个功能强大的工具,用于备份、恢复以及灾难恢复Oracle数据库。RMAN为DBA提供了全面的解决方案来保护数据库免受数据丢失的...
Oracle数据库11g是一个企业级关系型数据库管理系统,它支持高度的数据可用性和大规模数据量的管理。在本文中,我们将讨论如何将Oracle 11g RAC(Real Application Clusters)环境搭建为单实例的物理备库。这是一个...
在Oracle数据库管理中,创建一个备用数据库(standby database)是灾难恢复策略的重要组成部分。...通过RMAN的`duplicate`命令,你可以高效地创建和管理Oracle备用数据库,从而提高系统的可用性和灾难恢复能力。
Oracle 11g RMAN (Recovery Manager) 是Oracle数据库管理系统中的一个重要工具,主要用于数据库备份、恢复以及数据库的复制。在Linux环境下,使用RMAN复制数据库可以高效且安全地克隆一个现有的数据库到另一个系统。...
Oracle 11g Active Data Guard 是Oracle数据库系统中一种高级的数据保护和灾难恢复技术,它在主数据库运行的同时,创建并维护一个或多个只读的物理 standby 数据库。Active Data Guard 提供了实时的数据保护,使得在...
Oracle 11g RMAN (Recovery Manager) 是Oracle数据库管理系统中的一个重要工具,主要用于数据库的备份、恢复以及复制。在本教程中,我们将探讨如何在Linux环境下使用RMAN复制一个Oracle 11g数据库。 首先,环境设定...