基于LINUX的Oracle 10G RAC管理维护学习手记

v$asm_disk_stat where NAME is not null; GROUP_NUMBER PATH NAME MOUNT_S HEADER_STATU MODE_ST STATE ------------

---------------- ---------- ------- ------------ ------- 1 /dev/raw/raw3 DATA_0000 CACHED MEMBER ONLINE NORMAL 2 /dev/raw/raw4 DG1_0000 CACHED MEMBER ONLINE NORMAL 3 /dev/raw/raw6 DG6_0001 CACHED MEMBER ONLINE NORMAL 3 /dev/raw/raw7 DG6_DISK7 CACHED MEMBER ONLINE NORMAL

删除磁盘在某一节点操作即可,不做举例验证。关于ASM的更多管理命令,就不多列举了。

3.Database备份/恢复 RAC下的备份恢复跟单实例的备份恢复实质上没有太大的差别,需要注意的是备份/恢复的时候当前节点对所有数据文件/归档日志的可见。在一个数据文件和归档日志全部放在共享存储上的RAC系统,备份与恢复过程与单实例下的几乎一样。而归档日志如果采用的是本地磁盘,就需要另加注意。下面分别来模拟这个备份恢复过程。 (1).Archivelog对各节点可见的备份/恢复在这种模式下,备份恢复可以在任意一个可用节点执行即可,跟单实例并不太大区别。

对database进行备份

RMAN>run {allocate channel orademo type disk; backup database format '/backup/database/db_%s_%p_%t' plus archivelog format '/backup/database/arch_%s_%p_%t' delete input; backup current controlfile format '/backup/database/contr_%s_%p_%t';}

allocated channel: orademo channel orademo: sid=130 instance=demo2 devtype=DISK Starting backup at 03-MAY-08 current log archived channel orademo: starting archive log backupset channel orademo: specifying archive log(s) in backup set input archive log thread=1 sequence=5 recid=70 stamp=661823848 input archive log thread=1 sequence=6 recid=72

stamp=661823865 …………………………………….. Finished backup at 03-MAY-08 released channel: orademo

添加数据,用于测试恢复效果

SQL> create table kevinyuan.test_b as select * from dba_data_files; Table created SQL> alter system switch logfile; System altered

SQL> insert into kevinyuan.test_b select * from dba_data_files; 6 rows inserted SQL> commit; Commit complete

SQL> select count(*) from kevinyuan.test_b; COUNT(*) ---------- 12

模拟故障/恢复

RMAN> run {restore controlfile from

'/backup/database/contr_16_1_661823935'; sql 'alter database mount'; restore database; recover database;

sql 'alter database open resetlogs'; }

Starting restore at 04-MAY-08 allocated channel: ORA_DISK_1 ………………………………………………………………………….. archive log

filename=+DATA/demo/onlinelog/group_4.266.660615543

thread=2 sequence=11 archive log

filename=+DATA/demo/onlinelog/group_3.265.660615545 thread=2 sequence=12 media recovery complete, elapsed time: 00:00:00 Finished recover at 04-MAY-08 sql statement:

alter database open resetlogs 恢复完毕,来看一下验证数据:

SQL> select count(*) from kevinyuan.test_b; COUNT(*) ---------- 12

(2). Archivelog对各节点不可见的备份/恢复 如果arhivelog采用本地磁盘,归档日志并不是对任意节点可见。备份archivelog的时候,如果采用和上述类似的备份方案,必然会导致一些归档日志由于无法access而抛出异常。可以采取如下的备份方式,目的就是使得备份通道能够access所有的数据字典中记录的归档日志信息。恢复的时候,copy所有节点产生的相关备份片/集和归档日志文件到待恢复节点,在一个节点上执行restore/recover操作即可。模拟一下这个操作。

SQL> alter system set

log_archive_dest_1='location=/archive/demo1/' sid='demo1'; System altered SQL> alter system set

log_archive_dest_1='location=/archive/demo2/' sid='demo2'; System altered (1)备份数据库

RMAN>run {allocate channel orademo1 type disk connect sys/kevinyuan@demo1; allocate channel orademo2 type disk connect sys/kevinyuan@demo2; backup database format '/backup/database/db_%s_%p_%t' plus archivelog format '/backup/database/arch_%s_%p_%t' delete input; backup current controlfile format

'/backup/database/contr_%s_%p_%t;} allocated channel: orademo1 channel orademo1: sid=133 instance=demo1 devtype=DISK allocated channel: orademo2 channel orademo2: sid=151 instance=demo2 devtype=DISK Starting backup at 04-MAY-08 current log archived channel orademo2: starting archive log backupset channel

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4