rac rman 备份和恢复 2

原创转载请注明出处

4、再次在2个节点进行多次日志切换

SQL> alter system switch logfile;

 

System altered.

 

SQL> r

  1* alter system switch logfile

 

5、  全部关闭ORACLEC RAC数据库

Srvctl stop database –d ppzhu

6、  在节点2启动到nomount状态,并且进行控制文件恢复

SQL> startup nomount;

ORACLE instance started.

 

Total System Global Area  608174080 bytes

Fixed Size                  1275104 bytes

Variable Size             192940832 bytes

Database Buffers          406847488 bytes

   

 

RMAN> restore controlfile from '/archivelog/bak_745771065_14_1.bak';

 

Starting restore at 14-MAR-11

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output filename=/dev/raw/raw21

output filename=/dev/raw/raw22

output filename=/dev/raw/raw23

Finished restore at 14-MAR-11

7、  启动数据库在MOUNT节点准备RESTORE 数据文件

RMAN> sql 'alter database mount';

 

sql statement: alter database mount

released channel: ORA_DISK_1

 

8、  进行数据文件恢复,我这里使用的数据文件是第一次备份时候的数据文件,而控制文件是第二次备份的时候的控制文件。使用FROM TAG就能控制恢复的数据文件备份集,TAG就是一个对备份片的标示而已。

RMAN> restore database from tag='TAG20110314T142928'; 

 

Starting restore at 14-MAR-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=151 instance=ppzhu1 devtype=DISK

 

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /dev/raw/raw5

restoring datafile 00002 to /dev/raw/raw7

restoring datafile 00003 to /dev/raw/raw6

restoring datafile 00004 to /dev/raw/raw10

restoring datafile 00005 to /dev/raw/raw8

channel ORA_DISK_1: reading from backup piece /archivelog/bak_10_1_745770568.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/archivelog/bak_10_1_745770568.bak tag=TAG20110314T142928

channel ORA_DISK_1: restore complete, elapsed time: 00:00:35

Finished restore at 14-MAR-11

9、  进行不完全恢复,因为新的控制文件中没有归档备份

archive log filename=/archivelog/1_133_743871413.dbf recid=36 stamp=745771084

archive log filename=/archivelog/2_104_743871413.dbf recid=35 stamp=745771067

的信息,所以这里只能进行不完全恢复,使用UNTIL 可以控制。

RMAN> recover database until sequence 132;

 

Starting recover at 14-MAR-11

using channel ORA_DISK_1

 

starting media recovery

 

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=129

channel ORA_DISK_1: restoring archive log

archive log thread=2 sequence=100

channel ORA_DISK_1: restoring archive log

archive log thread=2 sequence=101

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=130

channel ORA_DISK_1: restoring archive log

archive log thread=2 sequence=102

channel ORA_DISK_1: restoring archive log

archive log thread=2 sequence=103

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=131

channel ORA_DISK_1: reading from backup piece /archivelog/arch_745770993_12_1.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/archivelog/arch_745770993_12_1.bak tag=TAG20110314T143632

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archive log filename=/archivelog/2_100_743871413.dbf thread=2 sequence=100

archive log filename=/archivelog/1_129_743871413.dbf thread=1 sequence=129

archive log filename=/archivelog/2_101_743871413.dbf thread=2 sequence=101

archive log filename=/archivelog/1_130_743871413.dbf thread=1 sequence=130

archive log filename=/archivelog/2_102_743871413.dbf thread=2 sequence=102

archive log filename=/archivelog/2_103_743871413.dbf thread=2 sequence=103

archive log filename=/archivelog/1_131_743871413.dbf thread=1 sequence=131

media recovery complete, elapsed time: 00:00:03

Finished recover at 14-MAR-11

 

RMAN> recover database until sequence  133;

Starting recover at 14-MAR-11

using channel ORA_DISK_1

starting media recovery

archive log thread 2 sequence 103 is already on disk as file /archivelog/2_103_743871413.dbf

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=132

channel ORA_DISK_1: reading from backup piece /archivelog/arch_745770993_12_1.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/archivelog/arch_745770993_12_1.bak tag=TAG20110314T143632

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archive log filename=/archivelog/1_132_743871413.dbf thread=1 sequence=132

archive log filename=/archivelog/2_103_743871413.dbf thread=2 sequence=103

media recovery complete, elapsed time: 00:00:02

Finished recover at 14-MAR-11

我这里第一次使用sequence 132 发现133没有用到所以再一次使用了 sequence 133

其实这里只要一次recover database until sequence  133;就可以了。

10、    启动数据库使用RESETLOGS

 

SQL> alter database open resetlogs;

 

Database altered.

 

11、    启动另外一个节点

SQL> startup;

ORACLE instance started.

 

Total System Global Area  608174080 bytes

Fixed Size                  1275104 bytes

Variable Size             218106656 bytes

Database Buffers          381681664 bytes

Redo Buffers                7110656 bytes

Database mounted.

Database opened.

到此数据库恢复完成。

所以在RAC备份时候最好把归档日志文件和备份集合都放在一个可以共享的目录下,并且目录名要相同,方便恢复。

 
上一篇:文件下载案例 | 手把手教你入门Python之九十八


下一篇:Check Point携手 Microsoft Intune 保护企业移动安全