整体流程:对A机的数据库来一个热备,并且是一个全备,然后通过scp命令把备份传到B机,然后把A库停掉(注意关库不会触发归档),之后再把归档日志和redo日志传给B机,最后再在B库上 restore 和recover
数据文件,控制文件,参数文件 的恢复过程:根据数据库的启动流程,可以知道最先读取数据文件,所以应该先还原参数文件,然后会读控制文件,所以你要再修复控制文件,最后再修复数据文件,
具体操作流程:
一:对A库做一个热全备,
RMAN> backup as backupset database include current controlfile plus archivelog format '/u01/app/Oracle/arch_%U.rmn' delete all input;
省列。。。。
Finished backup at 14-AUG-14
二:把所做的备份用scp传给B机。 如红色命令会把A机的ENMOEDU接到B机的Oracle/下,,即Oracle/ENMOEDU
[oracle@ENMOEDU ENMOEDU]$ scp -r /u01/app/oracle/fast_recovery_area/ENMOEDU oracle@192.168.80.11:/u01/app/oracle/
The authenticity of host '192.168.80.11 (192.168.80.11)' can't be established.
RSA key fingerprint is 54:78:71:4c:93:51:01:f4:e3:83:b5:35:8f:9f:d5:b1.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.80.11' (RSA) to the list of known hosts.
oracle@192.168.80.11's password:
o1_mf_nnndf_SECTION_DF1_9srh9o7k_.bkp 100% 148MB 36.9MB/s 00:04
o1_mf_ncnnf_SECTION_DF1_9srh9ws3_.bkp 100% 9568KB 9.3MB/s 00:01
o1_mf_nnndf_SECTION_DF1_9srh9n9o_.bkp 100% 97MB 24.2MB/s 00:04
o1_mf_nnsnf_SECTION_DF1_9srh9nml_.bkp 100% 96KB 96.0KB/s 00:00
o1_mf_nnndf_SECTION_DF1_9srh9o26_.bkp 100% 140MB 28.0MB/s 00:05
o1_mf_nnndf_SECTION_DF1_9srh9v71_.bkp 100% 145MB 29.0MB/s 00:05
o1_mf_nnndf_SECTION_DF1_9srhb0dh_.bkp 100% 81MB 27.0MB/s 00:03
o1_mf_ncsnf_TAG20140814T203309_9ysc8x14_.bkp 100% 9600KB 4.7MB/s 00:02
o1_mf_nnndf_TAG20140814T203309_9ysc46go_.bkp 100% 1140MB 24.3MB/s 00:47
control02.ctl 100% 9520KB 9.3MB/s 00:01
三:把A库数据库关闭,把归档和redo传给B机,(因为你备份的时候没有关闭数据库,难免会再产生新的归档和redo,为保证一致性,还有必要进行这步)
1.SYS@ENMOEDU> select * from v$log; #显示第三组 正在被使用,所以只传它就行(因为别的已经被归档,)
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC
---------- ---------- ---------- ---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------------- ------------- --------- ------------ ---------
1 1 100 52428800 512 1 YES
INACTIVE 1365811 14-AUG-14 1365876 14-AUG-14
2 1 101 52428800 512 1 YES
INACTIVE 1365876 14-AUG-14 1365981 14-AUG-14
3 1 102 52428800 512 1 NO
CURRENT 1365981 14-AUG-14 2.8147E+14
2.SYS@ENMOEDU> select * from v$logfile; #查看日志的具体位置
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_
---
1 ONLINE
/u01/app/oracle/oradata/ENMOEDU/redo01.log
NO
2 ONLINE
/u01/app/oracle/oradata/ENMOEDU/redo02.log
NO
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_
---
3 ONLINE
/u01/app/oracle/oradata/ENMOEDU/redo03.log
NO
[oracle@ENMOEDU ENMOEDU]$ scp /u01/app/oracle/oradata/ENMOEDU/redo03.log oracle@192.168.80.11:/u01/app/oracle
oracle@192.168.80.11's password:
redo03.log 100% 50MB 50.0MB/s 00:01
至于归档嘛 我在测试的时候没有切换日志,也不存在日志组写满的情况,所以没有产生归档,又因为我在备份的时候加上了delete all input 所以会把已经备份的归档删掉,所以你不会看到新的归档 也就不用传了 呵呵
四:在B机操作
1,开启伪实例,注意可不要把B机的数据库实例给打开了 因为我的测试B机也有数据库。
[oracle@ENMOEDU ~]$ set DBID=87396644 #设成A机的数据库编号
RMAN> startup #启动伪实例
[oracle@ENMOEDU ENMOEDU]$ rman target /
RMAN> restore spfile from '/u01/app/oracle/ENMOEDU/backupset/2014_08_14/o1_mf_ncsnf_TAG20140814T203309_9ysc8x14_.bkp';
Starting restore at 15-AUG-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/ENMOEDU/backupset/2014_08_14/o1_mf_ncsnf_TAG20140814T203309_9ysc8x14_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 15-AUG-14