新接手了几个客户的数据库,数据库真是一团糟糕,什么分区,索引,表空间都十分的乱,最重要的是归档都没有开,竟然还是生产库,更别说什么备份脚本了,最近一直在做备份恢复的整理工作,该归档的停机归档,该建立脚本的建立备份脚本,以前库少,现在库多了,管理多个库不能那么空闲了,现在的库之前做了CRONTAB+RMAN的备份,做了些修改,记录如下:
修改RMAN失效日期为7天,同时修改自动备份控制脚本参数为开启状态。
[Oracle@localhost ~]$
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>
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>
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN>
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
RMAN>
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>
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>
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:修改归档脚本修改脚本,添加按日期产生文件夹,
[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 /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:邮件监控脚本修改增加传送定时任务错误脚本功能,服务器端接收到数据后解析邮件通知