八、如何使用RMANLOG
export Oracle_SID=orcl
export ORACLE_HOME=/u01/app/oracle/10.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
[oracle@rhel db_1]$ rman target / log /u02/rman_full.log append <<EOF
RMAN> run {
allocate channel c1 type disk;
allocate channel c2 type disk;
backup database filesperset 4 format '/u02/backup/full_%d_%T_%s_%p';
sql 'alter system archive log current';
backup archivelog all format '/u02/backup/arch_%d_%T_%s_%p' delete input;
backup current controlfile format '/u02/backup/ctl_%d_%T_%s_%p';
} EOF
九、 Rman的设置
分 配通道依据数据库的压力和磁盘的速度,每个通道占用磁盘的额i/o;filesperset依据数据库文件的大小,如果我的文件很大,我在每一个备份集里 面放的文件就少些,这样在数据库恢复的时候,我们会尽可能多的通道读取多个备份集,来更快的恢复文件。一个通道只能读取一个备份集,不可能多个通道读取一 个备份集。delete input 把备份走的归档自动删除,腾出空间。
十、 rman备份脚本归档
1,设置环境变量
export ORACLE_SID=orcl
export ORACLE_HOME==/u01/app/oracle/10.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
2,使用log输出
rman target / log /u02/rman_arch.log append <<EOF
3,开始备份
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
sql 'alter system archive log current';
backup archivelog all format '/u02/backup/arch_%d_%T_%s_%p' delete input;
backup current controlfile format '/u02/backup/ctl_%d_%T_%s_%p';
}
EOF
注:一旦控制文件损坏或者丢失,我们可以从最近的控制文件中,找到我们的备份集,找到我们的所需要恢复的归档日志。
十一、在rman中什么时候用crosscheck
更新控制文件,把已经删除的归档日志文件认为无效。当我们在归档目录下,不小心删除了一个归档日志,但是控制文件并不知道,所以在恢复的时候要找这个文件,
十二、oracle 冗余策略
1,recovery window
保留多长时间的备份集,rman认为在多少天之后的备份为无效。
2,redunancy
超过多少个,认为是无效的,他会删掉最早的一个备份。
Rman备份脚本-删除策略
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/10.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
[oracle@rhel backup]$ rman target / log /u02/rman_delete.log append <<EOF
allocate channel for maintenance type disk;
allocate channel for maintenance type sbt_tape;
corsscheck backup;
delete noprompt obsolete;
EOF
RMAN> [oracle@rhel backup]$
[oracle@rhel backup]$ crontab命令的功能是在一定的时间间隔调度一些命令的执行
编辑:crontab -e
查看:crontab -l
备份完全备,就删除冗余。
自动控制文件备份没有打开(备份到磁盘上)
十三、Rman恢复
[oracle@rhel backup]$ rman target / log /u02/rman_contorl.log
RMAN> run {
2> backup current controlfile format '/u02/backup/ctl_%d_%t_%s_%p';
3> }
RMA在rman中
[oracle@rhel backup]$ rman target / nocatalog log /u02/rman_contorl.log
RMAN> run {
2> allocate channel c1 type sbt_tape;
3> restore controlfile from '/u02/backup/ctl_ORCL_843158098_42_1';
[oracle@rhel backup]$ rman target / nocatalog log /u02/rman_contorl.log
RMAN> run {
2> allocate channel c1 type disk;
3> restore controlfile from '/u02/backup/ctl_ORCL_843158098_42_1';
4> }
十四、自动控制文件
备份打开(默认位置)(发起任何一个文件的备份,都会自动备份控制文件)从磁盘恢复打开控制文件自动备份数据库必须在mount或open
rman target /
rman> configure controlfile autobackup on;
rman> configure controlfile autobackup format for device type disk to '%F';
数据库恢复
*******************************************************************************
Rman target / nocatalog
Rman>set dbid
run{
allocate channel c1 type disk;
restore controlfile from auto backup;
}
注: 自动去找最近的一个控制文件的备份。如果控制文件的自动备份,不是默认的位置,在恢复控制文件的时候,需要把它给放在默认的位置。因为现在数据库还处于 nomunt的状态。在rman的show all;的参数里面,这些默认的参数是写在程序中的;修改的信息是记录在控制文件中的。所以当数据库启动到nomount的时候,在rman用 showall的时候,仍然是没有修改的默认信息。
十五、恢复控制文件
控制文件的默认位置$ORACLE_HOME/dbs
1, 复制拷贝
2,开始恢复
run{
set controlfile autobackup format for device type disk to '/oracle/%F';
restoreconfile from autobackup;
}
run{ set controlfile autobackup format for device type sbt_tape '%F';
在带库中找控制文件备份的备份集
Restore controlfile from auto backup;}
在带库中直接就是文件名,没有目录。
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-05/102313.htm
