新接手了幾個客戶的數(shù)據(jù)庫,數(shù)據(jù)庫真是一團(tuán)糟糕,什么分區(qū),索引,表空間都十分的亂,最重要的是歸檔都沒有開,竟然還是生產(chǎn)庫,更別說什么備份腳本了,最近一直在做備份恢復(fù)的整理工作,該歸檔的停機(jī)歸檔,該建立腳本的建立備份腳本,以前庫少,現(xiàn)在庫多了,管理多個庫不能那么空閑了,現(xiàn)在的庫之前做了CRONTAB+RMAN的備份,做了些修改,記錄如下:
2011-06-21修改RMAN參數(shù)以及備份腳本,實(shí)現(xiàn)7天后自動刪除失效備份集,同時添加定時任務(wù)的執(zhí)行結(jié)果到監(jiān)控郵件。
1:修改RMAN參數(shù)修改RMAN失效日期為7天,同時修改自動備份控制腳本參數(shù)為開啟狀態(tài)。
[Oracle@localhost ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Jun 21 13:59:31 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: GIS (DBID=3650399296)
RMAN> show all;
RMAN configuration parameters 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 3 BACKUP TYPE TO BACKUPSET;
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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/usr/app/db-server/ora_home/dbs/snapcf_gis.f'; # default
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/usr/app/db-server/ora_home/dbs/snapcf_gis.f'; # default
2:查看過期備份www.linuxidc.comRMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 2624 19-JUN-11
Backup Piece 2624 19-JUN-11 /sdb/opt/rman/rman/arch_level_0_GIS_20110619_2635_ibmf959t_1_1
Backup Set 2623 19-JUN-11
Backup Piece 2623 19-JUN-11 /sdb/opt/rman/rman/arch_level_0_GIS_20110619_2636_icmf959t_1_1
3:刪除過期備份集RMAN> delete noprompt obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=94 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=137 devtype=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: sid=91 devtype=DISK
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 2624 19-JUN-11
Backup Piece 2624 19-JUN-11 /sdb/opt/rman/rman/arch_level_0_GIS_20110619_2635_ibmf959t_1_1
Backup Set 2623 19-JUN-11
Backup Piece 2623 19-JUN-11 /sdb/opt/rman/rman/arch_level_0_GIS_20110619_2636_icmf959t_1_1
4:修改歸檔腳本修改腳本,添加按日期產(chǎn)生文件夾,
[Oracle@localhost rman]$ vi archback.sh
# user env
source ~/.bash_profile
export BACK_DATE=`date +%Y%m%d`
export BACKUP_PATH=/sdb/opt/rman
echo `mkdir -p ${BACKUP_PATH}/archivelog/${BACK_DATE}`
rman target / nocatalog msglog=$BACKUP_PATH/archivelog/${BACK_DATE}/arch_0_$BACK_DATE.log << EOF
# need a user and tablespace to create catalog
#connect catalog rman/rman@$Oracle_SID;
# resync catalog with target
#resync catalog;
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
sql 'alter system archive log current';
backup filesperset 3 format '$BACKUP_PATH/archivelog/${BACK_DATE}/arch_level_0_%d_%T_%s_%U' archivelog all delete input;
release channel c1;
release channel c2;
release channel c3;
}
crosscheck backup;
delete noprompt expired backup;
crosscheck archivelog all;
delete noprompt archivelog until time 'sysdate - 1' all ;
report obsolete;
delete noprompt obsolete;
exit
EOF
# end
5:修改數(shù)據(jù)備份腳本[Oracle@localhost rman]$ vi fullback.sh
# user env
source ~/.bash_profile
export BACK_DATE=`date +%Y%m%d`
export BACKUP_PATH=/sdb/opt/rman
echo `mkdir -p ${BACKUP_PATH}/rman/${BACK_DATE}`
rman target / nocatalog msglog=$BACKUP_PATH/rman/${BACK_DATE}/bak_0_$BACK_DATE.log << EOF
# need a user and tablespace to create catalog
#connect catalog rman/rman@$Oracle_SID;
# resync catalog with target
#resync catalog;
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup full database include current controlfile tag 'dbk_level_0' format '$BACKUP_PATH/rman/${BACK_DATE}/df_level_0_%d_%T_%s_%U';
sql 'alter system archive log current';
backup filesperset 3 format '$BACKUP_PATH/rman/${BACK_DATE}/arch_level_0_%d_%T_%s_%U' archivelog all delete input;
release channel c1;
release channel c2;
release channel c3;
}
crosscheck backup;
delete noprompt expired backup;
crosscheck archivelog all;
delete noprompt archivelog until time 'sysdate' all ;
report obsolete;
delete noprompt obsolete;
exit
EOF
6:修改Crontab任務(wù)修改如下,增加定時任務(wù)失敗日志:
[Oracle@localhost monitor_client]$ crontab -l
30 01 * * 0 "/usr/app/rman/fullback.sh" >/home/Oracle/monitor_client/logs/full_cron.log 2>/home/oracle/monitor_client/logs/full_cron_error.log
00 00 * * 6,1,2,3,4,5 "/usr/app/rman/archback.sh" >/home/Oracle/monitor_client/logs/arch_cron.log 2>/home/oracle/monitor_client/logs/arch_cron_error.log
30 7,15 * * * "/home/Oracle/monitor_client/client_cron.sh" >/home/oracle/monitor_client/client_cron.log 2>/home/oracle/monitor_client/client_cron_error.log
7:郵件監(jiān)控腳本修改增加傳送定時任務(wù)錯誤腳本功能,服務(wù)器端接收到數(shù)據(jù)后解析郵件通知
本文出自:億恩科技【mszdt.com】
服務(wù)器租用/服務(wù)器托管中國五強(qiáng)!虛擬主機(jī)域名注冊頂級提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|