Rman 實現oracle11g資料庫clone

heming96發表於2008-07-31

Rman clone資料庫的文件看了好幾次了,就是沒時間做,今天試試看:

cd $ORACLE_HOME/dbs

cp initnqaddite.ora initclone.ora

cp orapwnqaddite orapwclone 或者

orapwd file=$ORACLE_HOME/dbs/orapwclone password=clone entries=4

修改initclone.ora

[@more@]

手動替換nqaddite 成 clone vi 執行 :%s/nqaddite/clone/g

或者 perl -p -i -e 's/nqaddite/clone/g' initclone.ora

新增到引數檔案裡面

*.db_file_name_convert = ('nqaddite','clone')
*.log_file_name_convert = ('nqaddite','clone')

nomount啟動clone資料庫例項

export ORACLE_SID=clone

sqlplus "/ as sysdba" <

--create spfile from pfile;

startup nomount;

exit;

EOF

執行clone :

RMAN> run{
2> ALLOCATE auxiliary channel d1 device TYPE DISK;
3> duplicate target DATABASE TO "CLONE";
4> }
allocated channel: d1
channel d1: SID=152 device type=DISK
Starting Duplicate Db at 01-AUG-08
released channel: d1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 08/01/2008 07:24:16
RMAN-20208: UNTIL CHANGE is before RESETLOGS change
看一下資料庫是否歸檔沒有歸檔,關閉資料庫,修改資料庫啟動引數加入:
*.log_archive_dest_1='LOCATION=/oracle/oradata/nqaddite/archive'
create spfile from pfile;
startup mount;
alter database archivelog;
alter database open;
再執行clone還是不行
RMAN> run{
2> SET UNTIL logseq 1583 thread 1;
3> ALLOCATE auxiliary channel d1 TYPE DISK;
4> duplicate target DATABASE TO "CLONE";
5> }
executing command: SET until clause
allocated channel: d1
channel d1: SID=152 device type=DISK
Starting Duplicate Db at 01-AUG-08
released channel: d1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 08/01/2008 07:24:24
RMAN-20208: UNTIL CHANGE is before RESETLOGS change
RMAN> run{
2> SET UNTIL scn 946655988;
3> ALLOCATE auxiliary channel d1 TYPE DISK;
4> duplicate target DATABASE TO "CLONE";
5> }
executing command: SET until clause
allocated channel: d1
channel d1: SID=152 device type=DISK
Starting Duplicate Db at 01-AUG-08
released channel: d1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 08/01/2008 07:24:44
RMAN-06457: UNTIL SCN (946655988) is ahead of last SCN in archived logs ()
怎麼試都不行
我也執行資料庫備份先
備份完再執行還是一樣的錯誤。
看了一下歸檔日誌目錄好像沒有日誌 ,切換一下日誌試試
[oracle@nq-data-center nqaddite]$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Aug 1 07:28:49 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter system switch logfile ;
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oracle/oradata/nqaddite/archive
Oldest online log sequence 1581
Next log sequence to archive 1583
Current log sequence 1583
再執行clone試試 , 這回成功了
RMAN> run{
2> SET UNTIL logseq 1583 thread 1;
3> ALLOCATE auxiliary channel d1 TYPE DISK;
4> duplicate target DATABASE TO "CLONE";
5> }
executing command: SET until clause
allocated channel: d1
channel d1: SID=152 device type=DISK
Starting Duplicate Db at 01-AUG-08
contents of Memory Script:
{
set until scn 946741401;
set newname for datafile 1 to
"/oracle/oradata/clone/system01.dbf";
set newname for datafile 2 to
"/oracle/oradata/clone/sysaux01.dbf";
set newname for datafile 3 to
"/oracle/oradata/clone/undotbs01.dbf";
set newname for datafile 4 to
"/oracle/oradata/clone/users01.dbf";
set newname for datafile 5 to
"/oracle/oradata/clone/example01.dbf";
set newname for datafile 6 to
"/oracle/oradata/clone/ADDITEM.dbf";
set newname for datafile 7 to
"/oracle/oradata/clone/ADDITEM2.dbf";
set newname for datafile 8 to
"/oracle/oradata/clone/ADDITEM_INDEX.dbf";
set newname for datafile 9 to
"/oracle/oradata/clone/ADDITEM_INDEX2.dbf";
set newname for datafile 10 to
"/oracle/oradata/clone/ADDITEM_INDEX3.dbf";
set newname for datafile 11 to
"/oracle/oradata/clone/ADDITEM3.dbf";
set newname for datafile 12 to
"/oracle/oradata/clone/ADDFILE.dbf";
set newname for datafile 13 to
"/oracle/oradata/clone/ADDITEM4.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
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 01-AUG-08
channel d1: starting datafile backup set restore
channel d1: specifying datafile(s) to restore from backup set
channel d1: restoring datafile 00001 to /oracle/oradata/clone/system01.dbf
channel d1: restoring datafile 00002 to /oracle/oradata/clone/sysaux01.dbf
channel d1: restoring datafile 00003 to /oracle/oradata/clone/undotbs01.dbf
channel d1: restoring datafile 00004 to /oracle/oradata/clone/users01.dbf
channel d1: restoring datafile 00005 to /oracle/oradata/clone/example01.dbf
channel d1: restoring datafile 00006 to /oracle/oradata/clone/ADDITEM.dbf
channel d1: restoring datafile 00007 to /oracle/oradata/clone/ADDITEM2.dbf
channel d1: restoring datafile 00008 to /oracle/oradata/clone/ADDITEM_INDEX.dbf
channel d1: restoring datafile 00009 to /oracle/oradata/clone/ADDITEM_INDEX2.dbf
channel d1: restoring datafile 00010 to /oracle/oradata/clone/ADDITEM_INDEX3.dbf
channel d1: restoring datafile 00011 to /oracle/oradata/clone/ADDITEM3.dbf
channel d1: restoring datafile 00012 to /oracle/oradata/clone/ADDFILE.dbf
channel d1: restoring datafile 00013 to /oracle/oradata/clone/ADDITEM4.dbf
channel d1: reading from backup piece /oracle/flash_recovery_area/NQADDITEM/backupset/2008_08_01/o1_mf_nnndf_TAG20080801T070607_494kcb1w_.bkp
channel d1: piece handle=/oracle/flash_recovery_area/NQADDITEM/backupset/2008_08_01/o1_mf_nnndf_TAG20080801T070607_494kcb1w_.bkp tag=TAG20080801T070607
channel d1: restored backup piece 1
channel d1: restore complete, elapsed time: 00:05:59
Finished restore at 01-AUG-08
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 1168
LOGFILE
GROUP 1 ( '/oracle/oradata/clone/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/oracle/oradata/clone/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/oracle/oradata/clone/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/oracle/oradata/clone/system01.dbf'
CHARACTER SET ZHS16GBK

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=661592112 file name=/oracle/oradata/clone/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=661592112 file name=/oracle/oradata/clone/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=661592112 file name=/oracle/oradata/clone/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=661592112 file name=/oracle/oradata/clone/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=661592112 file name=/oracle/oradata/clone/ADDITEM.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=661592112 file name=/oracle/oradata/clone/ADDITEM2.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=7 STAMP=661592112 file name=/oracle/oradata/clone/ADDITEM_INDEX.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=8 STAMP=661592112 file name=/oracle/oradata/clone/ADDITEM_INDEX2.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=9 STAMP=661592112 file name=/oracle/oradata/clone/ADDITEM_INDEX3.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=10 STAMP=661592112 file name=/oracle/oradata/clone/ADDITEM3.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=11 STAMP=661592112 file name=/oracle/oradata/clone/ADDFILE.dbf
datafile 13 switched to datafile copy
input datafile copy RECID=12 STAMP=661592112 file name=/oracle/oradata/clone/ADDITEM4.dbf
contents of Memory Script:
{
set until scn 946741401;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 01-AUG-08
starting media recovery
archived log for thread 1 with sequence 1582 is already on disk as file /oracle/oradata/nqaddite/archive/1_1582_649874090.dbf
archived log file name=/oracle/oradata/nqaddite/archive/1_1582_649874090.dbf thread=1 sequence=1582
media recovery complete, elapsed time: 00:00:01
Finished recover at 01-AUG-08
contents of Memory Script:
{
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 217157632 bytes
Fixed Size 2142976 bytes
Variable Size 159386880 bytes
Database Buffers 50331648 bytes
Redo Buffers 5296128 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 1168
LOGFILE
GROUP 1 ( '/oracle/oradata/clone/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/oracle/oradata/clone/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/oracle/oradata/clone/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/oracle/oradata/clone/system01.dbf'
CHARACTER SET ZHS16GBK

contents of Memory Script:
{
set newname for tempfile 1 to
"/oracle/oradata/clone/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/oracle/oradata/clone/sysaux01.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/undotbs01.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/users01.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/example01.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/ADDITEM.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/ADDITEM2.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/ADDITEM_INDEX.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/ADDITEM_INDEX2.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/ADDITEM_INDEX3.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/ADDITEM3.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/ADDFILE.dbf";
catalog clone datafilecopy "/oracle/oradata/clone/ADDITEM4.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /oracle/oradata/clone/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/sysaux01.dbf RECID=1 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/undotbs01.dbf RECID=2 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/users01.dbf RECID=3 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/example01.dbf RECID=4 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/ADDITEM.dbf RECID=5 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/ADDITEM2.dbf RECID=6 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/ADDITEM_INDEX.dbf RECID=7 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/ADDITEM_INDEX2.dbf RECID=8 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/ADDITEM_INDEX3.dbf RECID=9 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/ADDITEM3.dbf RECID=10 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/ADDFILE.dbf RECID=11 STAMP=661592126
cataloged datafile copy
datafile copy file name=/oracle/oradata/clone/ADDITEM4.dbf RECID=12 STAMP=661592126
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=661592126 file name=/oracle/oradata/clone/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=661592126 file name=/oracle/oradata/clone/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=661592126 file name=/oracle/oradata/clone/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=661592126 file name=/oracle/oradata/clone/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=661592126 file name=/oracle/oradata/clone/ADDITEM.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=661592126 file name=/oracle/oradata/clone/ADDITEM2.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=7 STAMP=661592126 file name=/oracle/oradata/clone/ADDITEM_INDEX.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=8 STAMP=661592126 file name=/oracle/oradata/clone/ADDITEM_INDEX2.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=9 STAMP=661592126 file name=/oracle/oradata/clone/ADDITEM_INDEX3.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=10 STAMP=661592126 file name=/oracle/oradata/clone/ADDITEM3.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=11 STAMP=661592126 file name=/oracle/oradata/clone/ADDFILE.dbf
datafile 13 switched to datafile copy
input datafile copy RECID=12 STAMP=661592126 file name=/oracle/oradata/clone/ADDITEM4.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 01-AUG-08
RMAN>
修改 listener.ora tnsnames.ora 加入 clone 重啟監聽器就好了。
參考:

如果需要配置dbconsole的話
[oracle@nq~]$ emca -config dbcontrol db -repos recreate

EMCA 開始於 2008-8-1 9:02:05
EM Configuration Assistant, 11.1.0.5.0 正式版
版權所有 (c) 2003, 2005, Oracle。保留所有權利。

輸入以下資訊:
資料庫 SID: clone
監聽程式埠號: 1521
SYS 使用者的口令:
DBSNMP 使用者的口令:
SYSMAN 使用者的口令:
SYSMAN 使用者的口令: 通知的電子郵件地址 (可選): heming@netqin.com
通知的發件 (SMTP) 伺服器 (可選): mail.netqin.com
-----------------------------------------------------------------

已指定以下設定

資料庫 ORACLE_HOME ................ /oracle/product/11.1.0/11g

本地主機名 ................ nq-data-center
監聽程式埠號 ................ 1521
資料庫 SID ................ clone
通知的電子郵件地址 ............... heming@netqin.com
通知的發件 (SMTP) 伺服器 ............... mail.netqin.com

-----------------------------------------------------------------
是否繼續? [是(Y)/否(N)]: y
2008-8-1 9:02:54 oracle.sysman.emcp.EMConfig perform
資訊: 正在將此操作記錄到 /oracle/cfgtoollogs/emca/clone/emca_2008_08_01_09_02_05.log。
2008-8-1 9:02:55 oracle.sysman.emcp.EMReposConfig invoke
資訊: 正在刪除 EM 資料檔案庫 (此操作可能需要一段時間)...

2008-8-1 9:10:49 oracle.sysman.emcp.EMReposConfig invoke
資訊: 已成功刪除資料檔案庫
2008-8-1 9:10:49 oracle.sysman.emcp.EMReposConfig createRepository
資訊: 正在建立 EM 資料檔案庫 (此操作可能需要一段時間)...
2008-8-1 9:17:43 oracle.sysman.emcp.EMReposConfig invoke
資訊: 已成功建立資料檔案庫
2008-8-1 9:17:48 oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
資訊: 正在將配置資料上載到 EM 資料檔案庫 (此操作可能需要一段時間)...
2008-8-1 9:18:36 oracle.sysman.emcp.EMReposConfig invoke
資訊: 已成功上載配置資料
2008-8-1 9:18:39 oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib
資訊: 軟體庫已配置成功。
2008-8-1 9:18:39 oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
資訊: 正在部署預配檔案...
2008-8-1 9:18:48 oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
資訊: 預配檔案部署成功。
2008-8-1 9:18:48 oracle.sysman.emcp.util.DBControlUtil secureDBConsole
資訊: 正在保護 Database Control (此操作可能需要一段時間)...
2008-8-1 9:19:02 oracle.sysman.emcp.util.DBControlUtil secureDBConsole
資訊: 已成功保護 Database Control。
2008-8-1 9:19:02 oracle.sysman.emcp.util.DBControlUtil startOMS
資訊: 正在啟動 Database Control (此操作可能需要一段時間)...
2008-8-1 9:19:31 oracle.sysman.emcp.EMDBPostConfig performConfiguration
資訊: 已成功啟動 Database Control
2008-8-1 9:19:31 oracle.sysman.emcp.EMDBPostConfig performConfiguration
資訊: >>>>>>>>>>> Database Control URL 為

應改是 emca -config dbcontrol db -repos create 快一些

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9614263/viewspace-1008219/,如需轉載,請註明出處,否則將追究法律責任。

相關文章