RMAN 異機(jī) 復(fù)制數(shù)據(jù)庫 收藏
關(guān)于RMAN 復(fù)制的理論知識(shí),參考我的Blog:
RMAN 復(fù)制目標(biāo)數(shù)據(jù)庫的理論知識(shí)
RMAN 異機(jī)復(fù)制和同機(jī)復(fù)制操作步驟是一樣的,,不同的是我們需要把備份的文件copy到輔助庫上去,,而且位置要和目標(biāo)庫上一直,因?yàn)閭浞菁奈恢檬菍懺诳刂莆募锏摹?/div> RMAN 同機(jī)復(fù)制數(shù)據(jù)庫 實(shí)驗(yàn)平臺(tái): REDHAT linux 4.7 + oracle 10g 目標(biāo)庫信息: ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/10.2.0/db_1
ORACLE_SID:orcl
IP: 192.168.1.20
輔助庫信息: ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/10.2.0/db_1
ORACLE_SID:orcl
IP: 192.168.1.21
我們以實(shí)例名相同的為例,實(shí)例名不同也一樣,在pfile里修改對應(yīng)參數(shù)就可以了。 步驟如下: (1)構(gòu)建輔助數(shù)據(jù)庫目錄結(jié)構(gòu)
(2)創(chuàng)建pfile,,并復(fù)制到輔助數(shù)據(jù)庫,修改相關(guān)內(nèi)容
(3)創(chuàng)建輔助實(shí)例口令文件
(4)RMAN 備份源庫
(5)添加配置監(jiān)聽
(6)將源庫備份文件拷貝到輔助庫相同位置
(7)用pfile文件,,將輔助數(shù)據(jù)庫啟動(dòng)到nomount 狀態(tài)
(8)執(zhí)行RMAN duplicate命令復(fù)制數(shù)據(jù)庫
(9)創(chuàng)建spfile文件
(10)在磁帶上恢復(fù)備份
(11)使用DBNEWID程序生成新的DBID
一.構(gòu)建輔助數(shù)據(jù)庫目錄結(jié)構(gòu)
1.1 Oracle data 目錄
[oracle@localhost oracle]$ mkdir oradata
[oracle@localhost oracle]$ ls
oradata oraInventory product
[oracle@localhost oracle]$ cd oradata/
[oracle@localhost oracle]$ mkdir orcl
1.2 其他目錄 [oracle@localhost oracle]$ pwd
/u01/app/oracle
[oracle@localhost oracle]$ mkdir admin
[oracle@localhost oracle]$ ls
admin oradata oraInventory product
[oracle@localhost oracle]$ cd admin
[oracle@localhost admin]$ ls
[oracle@localhost admin]$ mkdir orcl
[oracle@localhost admin]$ ls
orcl
[oracle@localhost admin]$ cd orcl
[oracle@localhost orcl]$ mkdir adump
[oracle@localhost orcl]$ mkdir bdump
[oracle@localhost orcl]$ mkdir cdump
[oracle@localhost orcl]$ mkdir dpdump
[oracle@localhost orcl]$ mkdir pfile
[oracle@localhost orcl]$ mkdir udump
[oracle@localhost orcl]$ ls
adump bdump cdump dpdump pfile udump
二. 創(chuàng)建pfile,,復(fù)制到輔助數(shù)據(jù)庫,并修改相關(guān)參數(shù)
2.1 在源庫上創(chuàng)建pfile 文件 SQL> conn sys/admin@orcl as sysdba;
Connected.
SQL> create pfile from spfile;
File created.
2.2 用scp 命令將pfile 文件傳到輔助庫,。要放在$ORACLE_HOME/dbs目錄下,,不然ORACLE 不識(shí)別。 [oracle@db1 orcl]$ cd /u01/app/oracle/product/10.2.0/db_1/dbs
[oracle@db1 dbs]$ ls
hc_DAVE.dat initdw.ora lkDAVE orapworcl spfileorcl.ora
hc_orcl.dat init.ora lkORCL snapcf_orcl.f
initDAVE.ora initorcl.ora orapwDAVE spfileDAVE.ora
[oracle@db1 dbs]$ scp initorcl.ora 192.168.1.21:/$ORACLE_HOME/dbs
The authenticity of host '192.168.1.21 (192.168.1.21)' can't be established.
RSA key fingerprint is 1a:20:7a:05:bd:e0:ac:04:21:02:b1:72:01:69:40:d6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.21' (RSA) to the list of known hosts.
[email protected]'s password:
initorcl.ora 100% 1108 1.1KB/s 00:00
2.3 在輔助庫上確認(rèn)文件是否傳送過來 [oracle@localhost orcl]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ ls
initdw.ora init.ora initorcl.ora
2.4 在輔助庫上修改pfile參數(shù) [oracle@localhost dbs]$ more initorcl.ora
orcl.__db_cache_size=167772160
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__shared_pool_size=62914560
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.background_dump_dest='/u01/app/oracle/admin/orcl/bdump'
*.compatible='10.2.0.1.0'
*.control_file_record_keep_time=14
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/or
adata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/orcl/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/u01/archivelog'
*.open_cursors=300
*.pga_aggregate_target=81788928
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=246415360
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/orcl/udump'
說明,,在這里我沒有做修改,,因?yàn)槲耶悪C(jī)復(fù)制實(shí)例名相同,存儲(chǔ)位置也相同,。 如果說你復(fù)制的不同的話,,就需要修改相關(guān)的實(shí)例名。 如果存儲(chǔ)位置不同的話,,還需要添加以下參數(shù),,對數(shù)據(jù)文件位置進(jìn)行轉(zhuǎn)換。 db_file_name_convert = ('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/DAVE')
三.創(chuàng)建輔助實(shí)例ORCL 的口令文件
[oracle@localhost dbs]$ cd $ORACLE_HOME/bin [oracle@localhost bin]$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=admin
[oracle@localhost bin]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ ls
initdw.ora init.ora initorcl.ora orapworcl
windows下oracle默認(rèn)的位置是$ORACLE_HOME/database目錄,,文件名格式是pwdSID.ora,。 linux下oracle默認(rèn)的位置是$ORACLE_HOME/dbs目錄,文件名格式是orapwSID,。
創(chuàng)建完后,,數(shù)據(jù)庫需要重啟動(dòng),新的口令文件才能生效,。
關(guān)于口令文件創(chuàng)建,,詳細(xì)內(nèi)容參考blog: Oracle OS認(rèn)證 口令文件 密碼丟失處理
四.RMAN 備份源庫(orcl)
[oracle@db1 backup]$ rman target sys/admin@orcl
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Jul 18 18:26:16 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1248423599)
RMAN>RUN {
allocate channel c1 type disk;
allocate channel c2 type disk;
BACKUP FORMAT '/u02/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE TAG orcl_hot_db_bk;
sql 'alter system archive log current';
BACKUP FORMAT '/u02/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;
backup current controlfile tag='bak_ctlfile' format='/u02/backup/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u02/backup/ORCL_spfile_%U_%T';
release channel c2;
release channel c1;
}
備份腳本,,具體參考: Linux 平臺(tái)下 RMAN 全備 和 增量備份 shell 腳本
五.添加,配置監(jiān)聽 5.1 在輔助庫的Listener.ora 文件中,,添加如下內(nèi)容 SID_LIST_LISTENER = (SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = orcl)
)
)
5.2 修改輔助庫的tnsnames.ora 文件,,添加如下內(nèi)容
TARGETORCL = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.20)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
5.3 修改源庫的tnsnames.ora 文件,添加如下內(nèi)容: AUXORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.21)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
建議使用net manager 工具從界面來修改,,這樣不容易出錯(cuò) Oracle 數(shù)據(jù)庫監(jiān)聽配置
Oracle Listener 動(dòng)態(tài)注冊 與 靜態(tài)注冊 六. 將源庫的備份拷貝到輔助數(shù)據(jù)庫的相同位置 這里有兩種方法,,一種直接在輔助庫上建相同的目錄結(jié)構(gòu),在用SCP 命令把這些備份文件copy過去,,但是這樣會(huì)占用大量的網(wǎng)絡(luò)資源,。 還有一種就是建好目錄結(jié)構(gòu)后用NFS直接Mount上去。 在這里我們用后面一種方法試一下,。
6.1 在輔助庫上建相同的備份目錄結(jié)構(gòu) 因?yàn)槲覀冊谠磶焐蟼浞菔莻浞莸?u02/backup目錄中的,所以我們在輔助庫上也建這個(gè)目錄
[root@localhost /]# mkdir -p /u02/backup
[root@localhost /]# chown oracle /u02
[root@localhost /]# chmod 777 /u02
6.2 將源庫的備份掛載到輔助庫上
6.2.1 在源庫上將/u02/backup 目錄添加到共享 [root@db1 ~]# more /etc/exports
/u02/backup 192.168.1.21(rw,async,anonuid=65534,anongid=65534)
[root@db1 ~]# service nfs start
6.2.2 在輔助庫上掛載源庫的目錄,,注意,,mount命令必須以root用戶執(zhí)行 [root@localhost /]# mount -t nfs -o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0
10.85.10.1:/u02/backup /u02/backup
-- 注意: 在掛載NFS的時(shí)候,一定要加上-t -o 參數(shù),,不然在RMAN 復(fù)制的時(shí)候會(huì)報(bào)錯(cuò):
--ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
[root@localhost /]# cd /u02/backup/
[root@localhost backup]# ls
arch_3klj4676_1_1_20100718 orcl_3hlj45vf_1_1_20100718
arch_3llj4676_1_1_20100718 orcl_3ilj465c_1_1_20100718
ctl_file_3mlj467h_1_1_20100718 orcl_3jlj4661_1_1_20100718
orcl_3glj45vf_1_1_20100718 ORCL_spfile_3nlj467k_1_1_20100718
七. 啟動(dòng)輔助庫至nomount 狀態(tài),,注意使用pfile參數(shù)啟動(dòng) [oracle@localhost dbs]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jul 20 03:53:53 2010
Copyright (c) 1982, 2005, 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 247463936 bytes
Fixed Size 1218772 bytes
Variable Size 79693612 bytes
Database Buffers 163577856 bytes
Redo Buffers 2973696 bytes
SQL> exit -- 啟動(dòng)后就退出session,因?yàn)樵赿uplicata的時(shí)候不能有session連接
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
八. RMAN 連接到目標(biāo)實(shí)例和輔助實(shí)例,,運(yùn)行duplicate 命令復(fù)制數(shù)據(jù)庫 [oracle@db1 ~]$ rman target sys/admin@orcl auxiliary sys/admin@auxorcl;
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Jul 18 20:41:19 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1248423599)
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;
注: 這個(gè)地方有2個(gè)地方需要說明: (1) Nofilenamecheck 參數(shù):
如果在復(fù)制時(shí),,位置不同時(shí),我們會(huì)用參數(shù)db_file_name_convert 對文件位置進(jìn)行轉(zhuǎn)換,。 但是在這個(gè)復(fù)制示例中我們用的是相同的位置,。 所以這里必須加上nofilenamecheck參數(shù)。 該參數(shù)通知復(fù)制操作不必在執(zhí)行還原操作前確認(rèn)文件名是不同的,。如果沒有指定nofilenamecheck參數(shù),,rman會(huì)給出如下錯(cuò)誤:
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 參數(shù): 在完成復(fù)制進(jìn)程并執(zhí)行最有一條open resetlogs命令時(shí),RMAN 必須為輔助數(shù)據(jù)庫構(gòu)建全新的日志文件,。 如上面命令所示,,我們可以在duplicate 命令中指定logfile參數(shù),并指定使用的日志文件的大小,,數(shù)目和位置,。
還可以在pfile里指定log_file_name_convert 參數(shù)來進(jìn)行轉(zhuǎn)換。 這種方法相對而言要簡單一點(diǎn),。 但因?yàn)槲覀冊赗MAN 同機(jī)復(fù)制數(shù)據(jù)庫的例子中用的就是這種方法,,所以就換種方法來測試。
Starting Duplicate Db at 18-JUL-10 using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
contents of Memory Script:
{
set until scn 733545;
set newname for datafile 1 to "/u01/app/oracle/oradata/orcl/system01.dbf";
set newname for datafile 2 to "/u01/app/oracle/oradata/orcl/undotbs01.dbf";
set newname for datafile 3 to "/u01/app/oracle/oradata/orcl/sysaux01.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
check readonly
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 18-JUL-10 using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore -- 開始restore 數(shù)據(jù)文件
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/orcl_3plj4ejl_1_1_20100718
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/orcl_3plj4ejl_1_1_20100718 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:48
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/orcl_3olj4ejk_1_1_20100718
channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/backup/orcl_3olj4ejk_1_1_20100718 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:14
Finished restore at 18-JUL-10
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG
-- 創(chuàng)建源庫的控制文件,,然后根據(jù)這個(gè)文件進(jìn)行相關(guān)的恢復(fù)
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 WE8ISO8859P1
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1 datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=724831148 filename=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=724831148 filename=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=724831148 filename=/u01/app/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=724831148 filename=/u01/app/oracle/oradata/orcl/example01.dbf
contents of Memory Script: {
set until scn 733545;
recover
clone database
delete archivelog ;
}
executing Memory Script
executing command: SET until clause Starting recover at 18-JUL-10 allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
starting media recovery channel ORA_AUX_DISK_1: starting archive log restore to default destination channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=46
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_3tlj4er7_1_1_20100718
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/arch_3tlj4er7_1_1_20100718 tag=TAG20100718T205809
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=45
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_3slj4er7_1_1_20100718
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/arch_3slj4er7_1_1_20100718 tag=TAG20100718T205809
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
archive log filename=/u01/archivelog/1_45_720642866.dbf thread=1 sequence=45
channel clone_default: deleting archive log(s)
archive log filename=/u01/archivelog/1_45_720642866.dbf recid=2 stamp=724831155
archive log filename=/u01/archivelog/1_46_720642866.dbf thread=1 sequence=46
channel clone_default: deleting archive log(s)
archive log filename=/u01/archivelog/1_46_720642866.dbf recid=1 stamp=724831153
media recovery complete, elapsed time: 00:00:02
Finished recover at 18-JUL-10
contents of Memory Script: {
shutdown clone;
startup clone nomount ;
-- 如果此時(shí),,輔助實(shí)例上有session連在上面,,將一直等到session退出才能執(zhí)行,如果等了很長時(shí)間還沒有執(zhí)行,,不妨檢查一下,,有沒有session連在數(shù)據(jù)庫上。
}
executing Memory Script
database dismounted Oracle instance shut down
connected to auxiliary database (not started) Oracle instance started
Total System Global Area 247463936 bytes Fixed Size 1218772 bytes
Variable Size 79693612 bytes
Database Buffers 163577856 bytes
Redo Buffers 2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG
-- 創(chuàng)建新的控制文件
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 WE8ISO8859P1
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/undotbs01.dbf";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/sysaux01.dbf";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/users01.dbf";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/example01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME renamed temporary file 1 to /u01/app/oracle/oradata/orcl/temp01.dbf in control file cataloged datafile copy datafile copy filename=/u01/app/oracle/oradata/orcl/undotbs01.dbf recid=1 stamp=724831185 cataloged datafile copy datafile copy filename=/u01/app/oracle/oradata/orcl/sysaux01.dbf recid=2 stamp=724831186
cataloged datafile copy datafile copy filename=/u01/app/oracle/oradata/orcl/users01.dbf recid=3 stamp=724831186
cataloged datafile copy datafile copy filename=/u01/app/oracle/oradata/orcl/example01.dbf recid=4 stamp=724831186
datafile 2 switched to datafile copy input datafile copy recid=1 stamp=724831185 filename=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=724831186 filename=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=724831186 filename=/u01/app/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=724831186 filename=/u01/app/oracle/oradata/orcl/example01.dbf
contents of Memory Script: {
Alter clone database open resetlogs;
}
executing Memory Script
executing Memory Script
database opened Finished Duplicate Db at 18-JUL-10
九. 創(chuàng)建spfile,,并驗(yàn)證數(shù)據(jù)庫 通過上面8步的操作,,復(fù)制操作已經(jīng)完成。 我們現(xiàn)在創(chuàng)建一個(gè)spfile,。
SQL> create spfile from pfile='/u01/app/oracle/product/10.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
UNDOTBS1 /u01/app/oracle/oradata/orcl/undotbs01.dbf
SYSAUX /u01/app/oracle/oradata/orcl/sysaux01.dbf
USERS /u01/app/oracle/oradata/orcl/users01.dbf
EXAMPLE /u01/app/oracle/oradata/orcl/example01.dbf
十. 在遠(yuǎn)程服務(wù)器上復(fù)制磁帶備份 如果在遠(yuǎn)程服務(wù)器上復(fù)制磁帶備份,,必須配置輔助通道,以反映介質(zhì)管理器的需求,。 除了指定介質(zhì)管理器和用于常規(guī)通道的類或池外,,還必須指定目標(biāo)客戶端名稱,如下所示:
RMAN> configure auxiliary channel 1 device type sbt parms="env=(nb_ora_serv=db1,nb_ora_client=db2)";
十一. 使用DBNEWID 適用程序的不完全復(fù)制
復(fù)制時(shí)最令人不滿意的一點(diǎn)是不存在"可重啟的復(fù)制",,也就是說,,如果在執(zhí)行還原所有文件的步驟(復(fù)制進(jìn)程中最常出錯(cuò))時(shí)出錯(cuò)。比如在恢復(fù)操作期間出錯(cuò),,就必須再次重啟復(fù)制進(jìn)程并重新還原文件,。我們無法修復(fù)復(fù)制進(jìn)程(如使丟失的歸檔日志可用),只能重新開始整個(gè)過程,。
將resote optimization 選項(xiàng)設(shè)置為on,, rman 就不會(huì)在還原位置中再次還原具有相同數(shù)據(jù)文件頭SCN信息文件。這也適合用于復(fù)制操作,。 如果復(fù)制操作還原一個(gè)文件,,然后重新啟動(dòng)該復(fù)制操作,RMAN 將不會(huì)再次還原該文件,。 然后,,如果將一個(gè)歸檔日志應(yīng)用于該文件,則會(huì)再次還原該歸檔日志,。 在Oracle 10g中,,使用DBNEWID使用程序可以部分修復(fù)恢復(fù)進(jìn)程,這個(gè)使用程序以安全和可控的方式為復(fù)制的數(shù)據(jù)庫指定新的DBID,。 我們可以手工恢復(fù)復(fù)制的數(shù)據(jù)庫,,準(zhǔn)備所有元素,然后再次運(yùn)行DBNEWID實(shí)用程序完成由復(fù)制操作啟動(dòng)的進(jìn)程,。 這就允許我們至少可以手工完成復(fù)制操作,。
DBNEWID 使用程序的用法很簡單。 首先,,必須確認(rèn)在使用實(shí)用程序前生成了有效的備份,,盡管要執(zhí)行驗(yàn)證備份的進(jìn)程,,但是在修改DBID期間仍然可能會(huì)遇到不可恢復(fù)的錯(cuò)誤。 確認(rèn)備份有效后,,還必須在一致的狀態(tài)中關(guān)閉數(shù)據(jù)庫,,然后將數(shù)據(jù)庫切換回加載狀態(tài)。
使用示例如下: SQL> shutdown immediate Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 247463936 bytes
Fixed Size 1218772 bytes
Variable Size 79693612 bytes
Database Buffers 163577856 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> !
[oracle@localhost u01]$ nid target=/
DBNEWID: Release 10.2.0.1.0 - Production on Tue Jul 20 07:20:37 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database ORCL (DBID=1252611919)
Connected to server version 10.2.0
Control Files in database: /u01/app/oracle/oradata/orcl/control01.ctl
/u01/app/oracle/oradata/orcl/control02.ctl
/u01/app/oracle/oradata/orcl/control03.ctl
Change database ID of database ORCL? (Y/[N]) => y Proceeding with operation Changing database ID from 1252611919 to 1252672326
Control File /u01/app/oracle/oradata/orcl/control01.ctl - modified
Control File /u01/app/oracle/oradata/orcl/control02.ctl - modified
Control File /u01/app/oracle/oradata/orcl/control03.ctl - modified
Datafile /u01/app/oracle/oradata/orcl/system01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/undotbs01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/sysaux01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/users01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/example01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/temp01.dbf - dbid changed
Control File /u01/app/oracle/oradata/orcl/control01.ctl - dbid changed
Control File /u01/app/oracle/oradata/orcl/control02.ctl - dbid changed
Control File /u01/app/oracle/oradata/orcl/control03.ctl - dbid changed
Instance shut down
Database ID for database ORCL changed to 1252672326. All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
本文來自CSDN博客,,轉(zhuǎn)載請標(biāo)明出處:http://blog.csdn.net/tianlesoftware/archive/2010/07/20/5749932.aspx
|
|