CentOS6u9 Oracle11g RAC 搭建部署(五)备份策略部署

9-备份策略部署:

1° 备份存放在共享存储划分的某块LUN中,直接格式化成ext文件系统挂载到某一节点即可:

# 如果节点1作为备份节点,则节点1操作
# 因为生产的备份盘大小会超过2T,因此使用parted格式化
parted /dev/mapper/lun_back01 mklabel gpt
parted /dev/mapper/lun_back01 mkpart primary 1 4294
parted /dev/mapper/lun_back01 p
# 此命令想当危险,会直接提交分区操作,需要慎重执行
# 分区后,其他节点需要重启多路软件才可以识别到新分区
mkfs.ext4 /dev/mapper/lun_back01p1
echo '/dev/mapper/lun_back01p1 /backup ext4 defaults 0 0'>>/etc/fstab
mount -a
mkdir -p /backup/rman/script
mkdir -p /backup/autobackup
mkdir -p /backup/backupset
chown -R oracle: /backup

2° 归档留存时间、块追踪、备份留存策略部署:

# 节点1操作
su - oracle
sqlplus / as sysdba
alter system set control_file_record_keep_time=30;
alter database enable block change tracking using file '+DATADG/ORCL/track.file';
exit
# 块改变追踪要放到ASM盘组中,否则卡死

rman target /
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/autobackup/%F';
exit

# 删除当前归档
rman target /
run{
allocate channel c1 type disk connect 'sys/[email protected]:1521/orcl';
allocate channel c2 type disk connect 'sys/[email protected]:1521/orcl';
crosscheck backup;
crosscheck archivelog all;
delete noprompt archivelog all;
release channel c1;
release channel c2;
}
exit
# 如果在开归档的时候,各个节点生成一个放在本地dbs下的归档
# 则要分配两个通道,分别连到两个节点上做归档的删除操作

# 备份测试
rman target /
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
set limit channel c1 readrate=10240;
set limit channel c1 kbytes=4096000;
set limit channel c2 readrate=10240;
set limit channel c2 kbytes=4096000;
backup as compressed backupset filesperset 3 database format '/backup/backupset/db_%d_%T_%s_%p';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as compressed backupset archivelog all format '/backup/backupset/arch_%d_%T_%s_%p';
backup as compressed backupset current controlfile format '/backup/backupset/ctl_%d_%T_%s_%p';
backup as compressed backupset spfile format '/backup/backupset/spfile_%d_%T_%s_%p';
release channel c1;
release channel c2;
}
exit
# 在挂载备份用共享盘的节点上做备份即可,和单机备份脚本一致
# 分配两个通道到各个节点的备份情况,一般都是带库,两个节点都做了相应配置的那种

3° 备份脚本:

#!/bin/bash
. ~/.bash_profile
export NLS_LANG=American_America.UTF8
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
TIME=$(date "+%Y_%m_%d_%H_%M_%S")

echo ''>>/backup/rman/script/rman_run.log
echo '###########################################################'>>/backup/rman/script/rman_run.log
echo '#######' $(date '+%F %R:%S') Check and Delete Backup '#######' >>/backup/rman/script/rman_run.log
echo '###########################################################'>>/backup/rman/script/rman_run.log
echo ''>>/backup/rman/script/rman_run.log

rman target / log /backup/rman/script/rman_run.log append<<EOF
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
crosscheck backup;
crosscheck archivelog all;
delete noprompt archivelog until time 'sysdate-15';
delete noprompt obsolete;
delete noprompt expired backup;
release channel c1;
release channel c2;
}
EOF

echo ''>>/backup/rman/script/rman_run.log
echo '##########################################################'>>/backup/rman/script/rman_run.log
echo '#######' $(date '+%F %R:%S') Start Rman Full Backup  '#######' >>/backup/rman/script/rman_run.log
echo '##########################################################'>>/backup/rman/script/rman_run.log
echo ''>>/backup/rman/script/rman_run.log

rman target / nocatalog log /backup/rman/script/rman_run.log append<<EOF
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
set limit channel c1 readrate=10240;
set limit channel c1 kbytes=4096000;
set limit channel c2 readrate=10240;
set limit channel c2 kbytes=4096000;
backup as compressed backupset filesperset 3 database format '/backup/backupset/db_%d_%T_%s_%p';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up 2 times format '/backup/backupset/arch_%d_%T_%s_%p';
backup as compressed backupset current controlfile format '/backup/backupset/ctl_%d_%T_%s_%p';
backup as compressed backupset spfile format '/backup/backupset/spfile_%d_%T_%s_%p';
release channel c1;
release channel c2;
}
EOF
# 脚本使用了 compressed 参数、not backed up 2 times 配置、sysdate-15 时间限制以及 set limit 限制
# 根据需求修改测试

4° 增量备份脚本:

vi /backup/rman/script/rman_inc0.sh
#!/bin/bash
. ~/.bash_profile
export NLS_LANG=American_America.UTF8
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
TIME=$(date "+%Y_%m_%d_%H_%M_%S")

echo ''>>/backup/rman/script/rman_run.log_"$TIME"
echo '###########################################################'>>/backup/rman/script/rman_run.log_"$TIME"
echo '#######' $(date '+%F %R:%S') Check and Delete Backup '#######' >>/backup/rman/script/rman_run.log_"$TIME"
echo '###########################################################'>>/backup/rman/script/rman_run.log_"$TIME"
echo ''>>/backup/rman/script/rman_run.log_"$TIME"

rman target / log /backup/rman/script/rman_run.log_"$TIME" append<<EOF
allocate channel for maintenance type disk;
crosscheck backup;
crosscheck archivelog all;
delete noprompt archivelog until time 'sysdate-15';
delete noprompt obsolete;
delete noprompt expired backup;
EOF

echo ''>>/backup/rman/script/rman_run.log_"$TIME"
echo '##########################################################'>>/backup/rman/script/rman_run.log_"$TIME"
echo '#######' $(date '+%F %R:%S') Start Rman Inc0 Backup  '#######' >>/backup/rman/script/rman_run.log_"$TIME"
echo '##########################################################'>>/backup/rman/script/rman_run.log_"$TIME"
echo ''>>/backup/rman/script/rman_run.log_"$TIME"

rman target / nocatalog log /backup/rman/script/rman_run.log_"$TIME" append<<EOF
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
set limit channel c1 readrate=10240;
set limit channel c1 kbytes=4096000;
set limit channel c2 readrate=10240;
set limit channel c2 kbytes=4096000;
backup as compressed backupset filesperset 3 incremental level 0 database format '/backup/backupset/inc0_%d_%T_%s_%p' tag=inc0_$TIME;
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up 2 times tag=arc0_$TIME format '/backup/backupset/arc0_%d_%T_%s_%p';
backup as compressed backupset current controlfile tag=ctl0_$TIME format '/backup/backupset/ctl0_%d_%T_%s_%p';
backup as compressed backupset spfile tag=spf0_$TIME format '/backup/backupset/spf0_%d_%T_%s_%p';
release channel c1;
release channel c2;
}
EOF
# 脚本使用了 compressed 参数、not backed up 2 times 配置、sysdate-15 时间限制以及 set limit 限制
# 根据需求修改测试

chmod +x /backup/rman/script/rman_inc0.sh
# crontab:
# 0 0 * * * /bin/bash /backup/rman/script/rman_inc0.sh >/dev/null 2>&1

[TOC]

猜你喜欢

转载自blog.csdn.net/zwjzqqb/article/details/80367324
今日推荐