[root@rhel5 ~]# at /etc/exports /orabackup *(rw,async,anonuid=65534,anongid=65534) [root@rhel5 ~]# service nfs start
6.2.2 在辅助库上挂载源库的目录,注意,mount命令必须以root用户执行 [root@rhel5 orabackup]# mount -t nfs -o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0 192.168.99.91:/orabackup /orabackup -- 注意: 在挂载NFS的时候,一定要加上-t -o 参数,不然在RMAN 复制的时候会报错: --ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
RMAN> run { allocate channel t1 type disk; allocate channel t2 type disk; allocate channel t3 type disk; allocate auxiliary channel a2 type disk; allocate auxiliary channel a3 type disk; allocate auxiliary channel a4 type disk; duplicate target database to orcl2 nofilenamecheck logfile "/oradata/orcl2/redo01.dbf" size 50m, "/oradata/orcl2/redo02.dbf" size 50m, "/oradata/orcl2/redo03.dbf" size 50m; }
注: 这个地方有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
contents of Memory Script: { sql clone "alter system set db_name = ""ORCL2"" comment= ""Modified by RMAN duplicate"" scope=spfile"; sql clone "alter system set db_unique_name = ""ORCL2"" 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 = ""ORCL2"" comment= ""Modified by RMAN duplicate"" scope=spfile sql statement: alter system set db_unique_name = ""ORCL2"" comment= ""Modified by RMAN duplicate"" scope=spfile Oracle instance shut down Oracle instance started Total System Global Area 849530880 bytes
contents of Memory Script: { set until scn 883198; set newname for datafile 1 to "/oradata/orcl2/datafilessystem01.dbf"; set newname for datafile 2 to "/oradata/orcl2/datafilessysaux01.dbf"; set newname for datafile 3 to "/oradata/orcl2/datafilesundotbs01.dbf"; set newname for datafile 4 to "/oradata/orcl2/datafileSUSErs01.dbf"; set newname for datafile 5 to "/oradata/orcl2/datafilesexample01.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 22-OCT-13
channel a2: starting datafile backup set restore channel a2: specifying datafile(s) to restore from backup set channel a2: restoring datafile 00001 to /oradata/orcl2/datafilessystem01.dbf channel a2: restoring datafile 00004 to /oradata/orcl2/datafilesusers01.dbf channel a2: reading from backup piece /orabackup/full_22_33_1_20131022 channel a3: starting datafile backup set restore channel a3: specifying datafile(s) to restore from backup set channel a3: restoring datafile 00002 to /oradata/orcl2/datafilessysaux01.dbf channel a3: restoring datafile 00003 to /oradata/orcl2/datafilesundotbs01.dbf channel a3: restoring datafile 00005 to /oradata/orcl2/datafilesexample01.dbf channel a3: reading from backup piece /orabackup/full_22_34_1_20131022 channel a3: piece handle=/orabackup/full_22_34_1_20131022 tag=TAG20131022T140657 channel a3: restored backup piece 1 channel a3: restore complete, elapsed time: 00:01:09 channel a2: piece handle=/orabackup/full_22_33_1_20131022 tag=TAG20131022T140657 channel a2: restored backup piece 1 channel a2: restore complete, elapsed time: 00:01:21 Finished restore at 22-OCT-13
contents of Memory Script: { set until scn 883198; recover clone database delete archivelog ; } executing Memory Script executing command: SET until clause Starting recover at 22-OCT-13 starting media recovery
contents of Memory Script: { shutdown clone immediate; startup clone nomount; sql clone "alter system set db_name = ""ORCL2"" 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 849530880 bytes
Fixed Size 1339824 bytes Variable Size 629149264 bytes Database Buffers 213909504 bytes Redo Buffers 5132288 bytes allocated channel: a2 channel a2: SID=19 device type=DISK allocated channel: a3 channel a3: SID=20 device type=DISK allocated channel: a4 channel a4: SID=21 device type=DISK sql statement: alter system set db_name = ""ORCL2"" 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 849530880 bytes
Fixed Size 1339824 bytes Variable Size 629149264 bytes Database Buffers 213909504 bytes Redo Buffers 5132288 bytes allocated channel: a2 channel a2: SID=19 device type=DISK allocated channel: a3 channel a3: SID=20 device type=DISK allocated channel: a4 channel a4: SID=21 device type=DISK sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL2" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 "/oradata/orcl2/redo01.dbf" SIZE 50 M , GROUP 2 "/oradata/orcl2/redo02.dbf" SIZE 50 M , GROUP 3 "/oradata/orcl2/redo03.dbf" SIZE 50 M DATAFILE "/oradata/orcl2/datafilessystem01.dbf" CHARACTER SET ZHS16GBK
contents of Memory Script: { set newname for tempfile 1 to "/oradata/orcl2/datafilestemp01.dbf"; switch clone tempfile all; catalog clone datafilecopy "/oradata/orcl2/datafilessysaux01.dbf", "/oradata/orcl2/datafilesundotbs01.dbf", "/oradata/orcl2/datafilesusers01.dbf", "/oradata/orcl2/datafilesexample01.dbf"; switch clone datafile all; } executing Memory Script executing command: SET NEWNAME renamed tempfile 1 to /oradata/orcl2/datafilestemp01.dbf in control file cataloged datafile copy datafile copy file name=/oradata/orcl2/datafilessysaux01.dbf RECID=1 STAMP=829493815 cataloged datafile copy datafile copy file name=/oradata/orcl2/datafilesundotbs01.dbf RECID=2 STAMP=829493815 cataloged datafile copy datafile copy file name=/oradata/orcl2/datafilesusers01.dbf RECID=3 STAMP=829493815 cataloged datafile copy datafile copy file name=/oradata/orcl2/datafilesexample01.dbf RECID=4 STAMP=829493815
contents of Memory Script: { Alter clone database open resetlogs; } executing Memory Script
database opened Finished Duplicate Db at 22-OCT-13 released channel: t1 released channel: t2 released channel: t3 released channel: a2 released channel: a3 released channel: a4
使用示例如下: [oracle@rhel5 datafiles]$ nid target=/ dbname=orcl3 DBNEWID: Release 11.2.0.1.0 - Production on Tue Oct 22 15:09:05 2013 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. Connected to database ORCL2 (DBID=810333637) Connected to server version 11.2.0 Control Files in database: /oradata/orcl2/datafiles/control01.ctl /oradata/orcl2/datafiles/control02.ctl Change database ID and database name ORCL2 to ORCL3? (Y/[N]) => y Proceeding with operation Changing database ID from 810333637 to 760600658 Changing database name from ORCL2 to ORCL3 Control File /oradata/orcl2/datafiles/control01.ctl - modified Control File /oradata/orcl2/datafiles/control02.ctl - modified Datafile /oradata/orcl2/datafilessystem01.db - dbid changed, wrote new name Datafile /oradata/orcl2/datafilessysaux01.db - dbid changed, wrote new name Datafile /oradata/orcl2/datafilesundotbs01.db - dbid changed, wrote new name Datafile /oradata/orcl2/datafilesusers01.db - dbid changed, wrote new name Datafile /oradata/orcl2/datafilesexample01.db - dbid changed, wrote new name Datafile /oradata/orcl2/datafilestemp01.db - dbid changed, wrote new name Control File /oradata/orcl2/datafiles/control01.ctl - dbid changed, wrote new name Control File /oradata/orcl2/datafiles/control02.ctl - dbid changed, wrote new name Instance shut down Database name changed to ORCL3. Modify parameter file and generate a new password file before restarting. Database ID for database ORCL3 changed to 760600658. All previous backups and archived redo logs for this database are unusable. Database has been shutdown, open database with RESETLOGS option. Succesfully changed database name and ID. DBNEWID - Completed succesfully.--------------------------------------推荐阅读 --------------------------------------RMAN 配置归档日志删除策略 http://www.linuxidc.com/Linux/2013-11/92670.htmOracle基础教程之通过RMAN复制数据库 http://www.linuxidc.com/Linux/2013-07/87072.htmRMAN备份策略制定参考内容 http://www.linuxidc.com/Linux/2013-03/81695.htmRMAN备份学习笔记 http://www.linuxidc.com/Linux/2013-03/81892.htmOracle数据库备份加密 RMAN加密 http://www.linuxidc.com/Linux/2013-03/80729.htm--------------------------------------分割线 --------------------------------------更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址