rac数据库RMAN 备份与恢复

rac数据库RMAN 备份与恢复

一、数据库备份
在主库上通过rman 每天对数据库进行备份,并且保留两份备份
 
在主库删除归档和进行rman 备份的脚本:
[oracle@rac1 arch]$ pwd
/opt/app/arch
[oracle@rac1 arch]$ more del_arch.sh
export ORACLE_SID=orcl1
export ORACLE_BASE=/opt/app/oracle
export ORACLE_TERM=xterm
export ORACLE_HOME=/opt/app/oracle/product/10.2.0/db_1
source /opt/app/arch/orcl1/del_arch.list
source /opt/app/arch/orcl2/del_arch.list
 
/opt/app/oracle/product/10.2.0/db_1/bin/rman target / log='/opt/app/arch/rman.log' <<EOF
delete obsolete recovery window of 3 days;
crosscheck archivelog all;
delete noprompt obsolete;
delete noprompt expired archivelog all;
crosscheck backup;
delete noprompt expired backup;
backup format='/opt/app/arch/rman/orcl_full_%U_%T' tag='orcl_full' database;
backup current controlfile tag='orcl_ctlfile' format='/opt/app/arch/rman/orcl_ctlfile_%U_%T';
backup spfile tag='orcl_spfile' format='/opt/app/arch/rman/orcl_spfile_%U_%T';
exit
EOF
执行时间:
[oracle@rac1 arch]$ crontab -l
30 02 * *     0    /opt/app/arch/del_arch.sh
30 02 * *     1    /opt/app/arch/del_arch.sh
30 02 * *     2    /opt/app/arch/del_arch.sh
30 02 * *     3    /opt/app/arch/del_arch.sh
30 02 * *     4    /opt/app/arch/del_arch.sh
30 02 * *     5    /opt/app/arch/del_arch.sh
30 02 * *     6    /opt/app/arch/del_arch.sh
 
每天的备份文件放在/opt/app/arch/rman/目录下
二、数据库恢复
 
如果数据库出现故障,可以从备份文件中恢复数据库,最早可以恢复到两天前的备份时间点
 
RAC 下的RMAN 讲究的是备份和还原的策略要一致。备份策略的不同,会导致备份结果的分步不同,进而影响恢复的策略和步骤。一般情况下,恢复策略和备份策略必须是对应的。如果备份策略进行了修改,那么恢复也应该采用相同的策略。
 
恢复步骤
 
 
2.1 先停止数据库
[oracle@rac1 bin]$ srvctl stop db -d orcl
[oracle@rac1 bin]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.orcl.db application OFFLINE OFFLINE
ora....oltp.cs application OFFLINE OFFLINE
ora....cl1.srv application OFFLINE OFFLINE
ora....cl2.srv application OFFLINE OFFLINE
ora....l1.inst application OFFLINE OFFLINE
ora....l2.inst application OFFLINE OFFLINE
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
 
 
 
2.2 将节点启动到mount 状态:
备份集存在在2个节点的情况(2个节点的RAC),在这种情况下,需要分配2个通道分别连接对应的节点。 每个节点都需要启动到mount状态。 因为每个节点都有备份文件,所以在每个节点都需要执行restore,如果没有启动的话,就会报错,对于备份集存放在共享设备的就不用这么麻烦。
 
 
[oracle@rac1 bin]$ export ORACLE_SID=orcl1
[oracle@rac1 bin]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Sep 27 02:56:55 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup mount;
Oracle instance started
database mounted
Total System Global Area 180355072 bytes
Fixed Size 1218388 bytes
Variable Size 100665516 bytes
Database Buffers 75497472 bytes
Redo Buffers 2973696 bytes
[oracle@rac2 bin]$ export ORACLE_SID=orcl2
[oracle@rac2 bin]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Sep 27 02:57:44 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup mount;
Oracle instance started
database mounted
Total System Global Area 180355072 bytes
Fixed Size 1218388 bytes
Variable Size 83888300 bytes
Database Buffers 92274688 bytes
Redo Buffers 2973696 bytes
 
2.3 完全恢复                             
在任意一个节点上执行:
RMAN> RUN {
restore database;
recover database;
}
 
RMAN> sql 'alter database open';
sql statement: alter database open
 
 
 
2.4 不完全恢复
基于时间点的恢复
RMAN> RUN {
set until time "to_date('2011/10/27 03:30:00','yyyy/mm/dd hh24:mi:ss')";
restore database;
recover database;
}
 
RMAN>
恢复完成之后,在两个节点执行:
alter database open resetlogs;
打开数据即可。
 

你可能感兴趣的:(备份,rman,恢复,休闲,rac数据库)