新接手了几个客户的数据库,数据库真是一团糟糕,什么分区,索引,表空间都十分的乱,最重要的是归档都没有开,竟然还是生产库,更别说什么备份脚本了,最近一直在做备份恢复的整理工作,该归档的停机归档,该建立脚本的建立备份脚本,以前库少,现在库多了,管理多个库不能那么空闲了,现在的库之前做了CRONTAB+RMAN的备份,做了些修改,记录如下:
2011-06-21
修改RMAN参数以及备份脚本,实现7天后自动删除失效备份集,同时添加定时任务的执行结果到监控邮件。
1:修改RMAN参数
修改RMAN失效日期为7天,同时修改自动备份控制脚本参数为开启状态。[Oracle@localhost ~]$ rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Tue Jun 21 13:59:31 2011Copyright (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; # defaultCONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK; # defaultCONFIGURE CONTROLFILE AUTOBACKUP OFF;# defaultCONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO "%F"; # defaultCONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE MAXSETSIZE TO UNLIMITED; # defaultCONFIGURE ENCRYPTION FOR DATABASE OFF; # defaultCONFIGURE ENCRYPTION ALGORITHM "AES128"; # defaultCONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # defaultCONFIGURE SNAPSHOT CONTROLFILE NAME TO "/usr/app/db-server/ora_home/dbs/snapcf_gis.f"; # defaultRMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;new RMAN configuration parameters:CONFIGURE CONTROLFILE AUTOBACKUP ON;new RMAN configuration parameters are successfully storedRMAN> 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 storedRMAN> show all;RMAN configuration parameters are:CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;CONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK; # defaultCONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO "%F"; # defaultCONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE MAXSETSIZE TO UNLIMITED; # defaultCONFIGURE ENCRYPTION FOR DATABASE OFF; # defaultCONFIGURE ENCRYPTION ALGORITHM "AES128"; # defaultCONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # defaultCONFIGURE SNAPSHOT CONTROLFILE NAME TO "/usr/app/db-server/ora_home/dbs/snapcf_gis.f"; # default
2:查看过期备份www.linuxidc.com
RMAN> report obsolete;RMAN retention policy will be applied to the commandRMAN retention policy is set to redundancy 1Report of obsolete backups and copiesType 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_1Backup 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 commandRMAN retention policy is set to redundancy 1allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=94 devtype=DISKallocated channel: ORA_DISK_2channel ORA_DISK_2: sid=137 devtype=DISKallocated channel: ORA_DISK_3channel ORA_DISK_3: sid=91 devtype=DISKDeleting 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_1Backup 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 envsource ~/.bash_profileexport BACK_DATE=`date +%Y%m%d`export BACKUP_PATH=/sdb/opt/rmanecho `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;exitEOF# end
5:修改数据备份脚本
[oracle@localhost rman]$ vi fullback.sh # user envsource ~/.bash_profileexport BACK_DATE=`date +%Y%m%d`export BACKUP_PATH=/sdb/opt/rmanecho `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;exitEOF
6:修改Crontab任务
修改如下,增加定时任务失败日志:[oracle@localhost monitor_client]$ crontab -l30 01 * * 0 "/usr/app/rman/fullback.sh" >/home/oracle/monitor_client/logs/full_cron.log 2>/home/oracle/monitor_client/logs/full_cron_error.log00 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.log30 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:邮件监控脚本修改
增加传送定时任务错误脚本功能,服务器端接收到数据后解析邮件通知Oracle联机日志出现错误ORA-16038 ORA-19809 ORA-00312 解决RMAN自动备份和磁带机备份SHELL脚本相关资讯 Oracle教程
- Oracle中纯数字的varchar2类型和 (07/29/2015 07:20:43)
- Oracle教程:Oracle中查看DBLink密 (07/29/2015 07:16:55)
- [Oracle] SQL*Loader 详细使用教程 (08/11/2013 21:30:36)
| - Oracle教程:Oracle中kill死锁进程 (07/29/2015 07:18:28)
- Oracle教程:ORA-25153 临时表空间 (07/29/2015 07:13:37)
- Oracle教程之管理安全和资源 (04/08/2013 11:39:32)
|
本文评论 查看全部评论 (0)