根據(jù)RMAN的一個(gè)全備份進(jìn)行異機(jī)恢復(fù) |
發(fā)布時(shí)間: 2012/9/11 17:17:55 |
根據(jù)rman的一個(gè)全備份進(jìn)行異機(jī)恢復(fù) 一. Target 庫準(zhǔn)備工作: 備份db run { allocate channel ch1 device type disk maxpiecesize=10g; sql 'alter system archive log current'; - change archivelog all crosscheck; backup full database tag=ora10gdbfullbk format '/u01/backup/%d_db_%t_%s_%p' plus archivelog format '/u01/backup/%d_arch_%t_%s_%p' delete all input; backup current controlfile format '/u01/backup/%d_ctlfile_%t_%s_%p'; release channel ch1; } 查看備份文件 -bash-3.1$ ll /u01/backup total 850468 -rw-r--r-- 1 root root 1277 Apr 20 21:53 initora10g.ora -rw-r--r-- 1 root root 8484864 Apr 21 04:05 ORA10G_arch_749016313_41_1 -rw-r--r-- 1 root root 386560 Apr 21 04:11 ORA10G_arch_749016700_43_1 -rw-r--r-- 1 root root 7438336 Apr 21 04:11 ORA10G_ctlfile_749016703_44_1 -rw-r--r-- 1 root root 853688320 Apr 21 04:11 ORA10G_db_749016331_42_1 二. Auxiliary庫準(zhǔn)備工作: 1.創(chuàng)建口令文件 $ orapwd file=/u01/app/Oracle/product/10.2.0/db_1/dbs/orapwhy2 password=oracle 2.創(chuàng)建相關(guān)的目錄 $ mkdir oradata $ pwd /u01/oradata 3.拷貝target庫的pfile和備份的db到auxiliary庫。 4、使用pfile將auxiliary庫啟動(dòng)到nomount狀態(tài) SQL> startup nomount pfile=/u01/app/Oracle/product/10.2.0/db_1/dbs/orapwhy2; 5、恢復(fù)控制文件 $ export Oracle_SID=hy2 $ rman target / RMAN>restore controlfile from '/u01/backup/ORA10G_ctlfile_749016703_44_1'; 6、將db啟動(dòng)到mount狀態(tài) RMAN> alter database mount; 7、restore db 7.1恢復(fù)目錄不同的情況: RMAN> run { set newname for datafile 1 to "/u01/oradata/system01.dbf"; set newname for datafile 2 to "/u01/oradata/sysaux01.dbf"; set newname for datafile 3 to "/u01/oradata/undotbs01.dbf"; set newname for datafile 4 to "/u01/oradata/users01.dbf"; restore database; switch datafile all; } 7.2恢復(fù)目錄相同 RMAN>restore database; 8、recover db RMAN> recover database; $ export Oracle_SID=ora10g 9、用open resetlogs?打開數(shù)據(jù)庫 SQL> alter database open resetlogs; 10、mount數(shù)據(jù)庫 用NID命令修改DBID和DBNAME SQL> shutdown immediate SQL> startup mount; $nid target=sys/password dbname=hy2 SQL> alter system set db_name=hy2 scope=spfile; SQL> shutdown immediate SQL> startup SQL> alter database open resetlogs; 驗(yàn)證: SQL> select name,dbid from v$database; NAME DBID --------- ---------- HY2 2874673008
本文出自:億恩科技【mszdt.com】 服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM] |