作者:Hydhuyfh________ | 来源:互联网 | 2017-05-12 15:07
在RMAN 备份的脚本里,我们添加了删除归档日志的选项,但是某些情况下还是需要部署删除归档日志的脚本。 比如在Data Guard 环境中
一. RMAN 的一些理论知识
RMAN Catalog 和 Nocatalog 的区别
RMAN 系列(一)---- RMAN 体系结构概述
RMAN 系列(二) ---- RMAN 设置和配置
RMAN 系列(三) ---- 介质管理问题
RMAN 系列(四) ---- RMAN 备份
RMAN 系列(五) ---- RMAN 还原 与 恢复
RMAN 系列(六) ---- RMAN 高级恢复
RMAN 系列(七) ---- RMAN 维护
RMAN 系列(八) ---- RMAN List和report 命令
RMAN 系列(九) ---- 调整RMAN备份与恢复操作的性能
Linux 平台下 RMAN 全备 和 增量备份 shell 脚本
二. RMAN 环境一些注意的配置
2.1 修改控制文件自动备份
可以用如下命令查看RMAN 的默认参数配置:
RMAN> show all;
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
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 CHANNEL 1 DEVICE TYPE DISK FORMAT 'F:/backup/orcl_%U.bak';
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 LOA
D TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:/APP/ADMINISTRATOR/PRODUCT/11.2.0/DBHO
ME_1/DATABASE/SNCFORCL.ORA'; # default
RMAN> configure controlfile autobackup on;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
已成功存储新的 RMAN 配置参数
改成自动以后,在数据文件有变化,或者备份数据库的时候,都会自动的备份控制文件和spfile文件。
修改parallelism参数为2. 该参数默认值为1.
如:CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
官网对这个参数的解释:
Configures the number of automatic channels of the specified device type allocated for RMAN jobs. By default, PARALLELISM is set to 1.
Suppose you set PARALLELISM for disk backups to 2 (see ). If you set the default device type as disk, then RMAN allocates two disk channels when you run BACKUP DATABASE at the RMAN prompt. RMAN always allocates the number of channels set by PARALLELISM, although it may use only a subset of these channels.
Note: If you configure n manually numbered channels, then the PARALLELISM setting can be greater than or less than n. For example, you can manually number 10 automatic channels and configure PARALLELISM to 2 or 12.
To change the parallelism for a device type to n, run a new CONFIGURE DEVICE TYPE ... PARALLELISM n command. For example, you can change configure PARALLELISM to 3 for sbt and then change it to 2 as follows:
.com/docs/cd/E11882_01/backup.112/e10643/rcmsynta010.htm#RCMRF113
2.2 修改控制文件保存的时间
否则就可能在备份介质上有数据库备份,但是控制文件不存在与备份相关的备份记录,,在这种情况下,将无法恢复这些较早的文件。
SQL> select name,value from v$parameter where name='control_file_record_keep_time';
NAME VALUE
------------------------------ -------------------------------------------------
control_file_record_keep_time 7
SQL> alter system set control_file_record_keep_time=20;
系统已更改。
SQL> show parameter control_file_record_keep_time
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 20
2.3 配置备份默认的保存策略
备份策略影响影响恢复,如果备份集少,那么恢复能力也受到限制,如果备份集留的比较多,那么也会占用大量的空间。 所以要设置一个合适的周期,这个要根据磁盘空间大小和恢复需要来设置,一般有2种方法:
2.3.1 通过recovery window
如:configure retention policy to recovery window of 7 days;
2.3.2 通过redundancy
如:configure retention policy to redundancy 5;
它的默认值是1份。
report obsolete;
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
configure retention policy clear;
2.3.4 不应用任何保存策略。
CONFIGURE RETENTION POLICY TO NONE;
2.4 部署备份脚本
参考blog:
2.5 删除归档日志的脚本
小结,对于DBA来说,完整有效的备份是非常重要的,它能在关键时刻恢复我们的数据,或者减少数据丢失,所以对于生产库,一定要做好备份策略。 备份重于一切!