oracle11gRAC环境使用RMAN备份方案

前端之家收集整理的这篇文章主要介绍了oracle11gRAC环境使用RMAN备份方案前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

初始:
[oracle@zx ~]$ rman target /


Recovery Manager: Release 11.2.0.1.0 - Production on Thu Oct 16 18:20:57 2014


Copyright (c) 1982,2009,Oracle and/or its affiliates. All rights reserved.


connected to target database: zx (DBID=2731354802)


RMAN> show all;


using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name zx are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_zx1.f'; # default


开始设置备份策略
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/rman/controlfile/%F';


修改后的
RMAN> show all;


RMAN configuration parameters for database with db_unique_name zx are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/rman/controlfile/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_zx1.f'; # default


开启块跟踪
[oracle@zx ~]$ sqlplus / as sysdba
sql> alter database enable block change tracking using file '+RCY1' ;
查看
sql> col filename for a50
sql> select * from v$block_change_tracking;
STATUS FILENAME BYTES
---------- -------------------------------------------------- ----------
ENABLED +RCY1/zx/changetracking/ctf.298.861133721 11599872




*****************************************************************************
增量备份
只备份从上次备份发生变化的块。
1)增量备份首先做全备:
0,1,2,3,4,5
2)增量备份的好处是加快备份时间。
3)oracle增量备份有两种:1.差异增量备份 2.累计增量备份
4)0级备份就是全被,做其他级别的备份前必须有0级,否则系统会做0级备份。
5)差异增量备份:backup incremental level 0 format
只要等于或小于自己的级别,前面的备份就可以作为备份的起点。
日 一 二 三 四 五 六 日
0 2 2 1 2 2 2 0
全 一 一 三 一 一 一 全
周一周二只备份一天就行了,但周三需要把周一二三的都备一遍,因为它级别比前面的备份低,周四就只备一天就行了,周日又要做全备了。
比如周三早晨挂了,需要周日周一周二才能恢复到周三早晨,但如果周四早晨就只需要周日,周三就能恢复。周六挂需要周日,周三,周四,周五四个备份集。
6)累计增量备份:backup incremental level 0 cumulative format
只看备份级别比自己低的。
日 一 二 三 四 五 六 日
0 2 2 1 2 2 2 0
全 一 二 三 一 二 三 全
周日全备,周一备份一天的,周二备份2天的。周三备份周一二三的。
周四只备份一天的,周五备份两天的,周六备份3天的。周日全备。
假如周三恢复,需要0级别和一个到周二 的备份就行了。恢复更快。
周六挂需要周日,周三,周五三个备份集。
*************************************************************************
zx数据库使用差异增量备份
日 一 二 三 四 五 六 日
0 2 2 1 2 2 2 0
全 一 一 三 一 一 一 全
周日全备,周一周二只备份一天就行了,但周三需要把周一二三的都备一遍,因为它级别比前面的备份低,周四周五周六就只备一天就行了,周日又要做全备了。
编辑备份脚本
脚本存放位置/home/oracle/scripts/rman/bin/
日志存放位置/home/oracle/scripts/rman/log/
备份存放位置+rcy1/backup/hrman_bak/


热备0级脚本
[oracle@zx bin]$ cat hrman0.sh
#!/bin/bash
export ORACLE_SID=zx1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin
rman target / <
run{
sql'alter system switch logfile';
allocate channel c1 type disk;
allocate channel c2 type disk;
crosscheck archivelog all;
backup as compressed backupset incremental level 0 format '+rcy1/backup/hrman_bak/%d_%T_%U_0.bak' database plus archivelog;
delete noprompt obsolete;
}
quit;
EOF
热备1级脚本
[oracle@zx bin]$ cat hrman1.sh
#!/bin/bash
export ORACLE_SID=zx1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin
rman target / <
run{
sql'alter system switch logfile';
allocate channel c1 type disk;
allocate channel c2 type disk;
crosscheck archivelog all;
backup as compressed backupset incremental level 1 format '+rcy1/backup/hrman_bak/%d_%T_%U_1.bak' database plus archivelog;
delete noprompt obsolete;
}
quit;
EOF


热备2级脚本
[oracle@zx bin]$ cat hrman2.sh
#!/bin/bash
export ORACLE_SID=zx1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin
rman target / <
run{
sql'alter system switch logfile';

allocate channel c1 type disk;

allocate channel c2 type disk;

crosscheck archivelog all;

backup as compressed backupset incremental level 2 format '+rcy1/backup/hrman_bak/%d_%T_%U_2.bak' database plus archivelog;
delete noprompt obsolete;
}
quit;
EOF
设置权限
[oracle@zx bin]$ chmod -R 777 hrman0.sh
[oracle@zx bin]$ chmod -R 777 hrman1.sh
[oracle@zx bin]$ chmod -R 777 hrman2.sh
[oracle@zx bin]$ ll
total 12
-rwxrwxrwx 1 oracle oinstall 468 Oct 21 17:03 hrman0.sh
-rwxrwxrwx 1 oracle oinstall 468 Oct 21 17:05 hrman1.sh
-rwxrwxrwx 1 oracle oinstall 468 Oct 21 17:06 hrman2.sh
配置作业
一个crontab文件中包含有六个字段:
分钟 0-59
小时 0-23
月中的第几天 1-31
月份 1 - 12
星期几 0 - 6,with 0 = Sunday

配置
[oracle@zx ~]$ crontab -e
查看
[oracle@zx ~]$ crontab -l
0 2 * * 0 sh /home/oracle/scripts/rman/bin/hrman0.sh >> /home/oracle/scripts/rman/log/backup0.log 2>&1
0 2 * * 3 sh /home/oracle/scripts/rman/bin/hrman1.sh >> /home/oracle/scripts/rman/log/backup1.log 2>&1
0 2 * * 1,5,6 sh /home/oracle/scripts/rman/bin/hrman2.sh >> /home/oracle/scripts/rman/log/backup2.log 2>&1
日志变大可清空
[oracle@zx ~]$ cat /dev/null > /home/oracle/scripts/rman/log/backup0.log
[oracle@zx ~]$ cat /dev/null > /home/oracle/scripts/rman/log/backup1.log
[oracle@zx ~]$ cat /dev/null > /home/oracle/scripts/rman/log/backup2.log
[oracle@zx ~]$ ll /home/oracle/scripts/rman/log
total 432
-rwxrwxrwx 1 oracle dba 0 Jul 15 16:12 backup0.log
-rwxrwxrwx 1 oracle dba 0 Jul 15 16:12 backup1.log
-rwxrwxrwx 1 oracle dba 0 Jul 15 16:12 backup2.log<><><>

原文链接:https://www.f2er.com/oracle/213423.html

猜你在找的Oracle相关文章