RMAN设置和配置
- FRA 管理
[oracle@XAG128 ~]$ sql / as sysdba
SQL> show parameter recovery;
NAME TYPE VALUE
-------------------------- ----------- ----------------------------------------
db_recovery_file_dest string /u01/app/oracle/fast_recovery_area/MPCDB
db_recovery_file_dest_size big integer 12780M
recovery_parallelism integer 0
remote_recovery_file_dest string
#查看归档模式
SQL> archive log list;
Database log mode Archive log Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 9
Next log sequence to archive 11
Current log sequence 11
#设置新fra目录
[root@XAG128 ~]# mkdir -p /u03/fra/
[root@XAG128 ~]# chown -R oracle:oinstall /u03/fra/
[root@XAG128 ~]# chmod -R 775 /u03/fra/
SQL> alter system set db_recovery_file_dest_size=15G scope=both;
SQL> alter system set db_recovery_file_dest='/u03/fra' scope=both;
SQL> show parameter recovery;
NAME TYPE VALUE
-------------------------- ----------- --------
db_recovery_file_dest string /u03/fra
db_recovery_file_dest_size big integer 15G
recovery_parallelism integer 0
remote_recovery_file_dest string
[oracle@XAG128 fra]$ ls
SQL> alter system switch logfile;
[oracle@XAG128 fra]$ ls
MPCDB
[oracle@XAG128 fra]$ cd MPCDB
[oracle@XAG128 MPCDB]$ ls
archivelog
[oracle@XAG128 MPCDB]$ cd archivelog/
[oracle@XAG128 archivelog]$ ls
2018_11_28
[oracle@XAG128 archivelog]$ cd 2018_11_28/
[oracle@XAG128 2018_11_28]$ ls
o1_mf_1_11_fzv2d1lj_.arc
#空间相关问题的警告
SQL> select * from dba_outstanding_alerts;
no rows selected
#数据库中fra概述
SQL> select * from v$recovery_file_dest;
NAME
-----------------------------------------------------------------------------------------------------------------------------------
SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES CON_ID
----------- ---------- ----------------- --------------- ----------
/u03/fra
1.6106E+10 4270562304 1142795776 18 0
#占用fra空间的文件类型的详细信息
SQL> select * from v$recovery_area_usage;
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES CON_ID
----------------------- ------------------ ------------------------- --------------- ----------
CONTROL FILE 0 0 0 0
REDO LOG 0 0 0 0
ARCHIVED LOG 2.2 0 3 0
BACKUP PIECE 24.32 7.1 15 0
IMAGE COPY 0 0 0 0
FLASHBACK LOG 0 0 0 0
FOREIGN ARCHIVED LOG 0 0 0 0
AUXILIARY DATAFILE COPY 0 0 0 0
- 创建目标数据库rman备份账户
SQL> create user c##backup_admin identified by "xag123";
User C##BACKUP_ADMIN created.
SQL> grant sysbackup to c##backup_admin;
Grant succeeded.
#测试rman登录
[oracle@XAG128 ~]$ rman target c##backup_admin/xag123;
- 配置默认值
# 备份到磁盘,并行通道数=2,备份到备份集且压缩
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters are successfully stored
#限制所有信道单个备份集片的大小
##这个命令设置了信道的备份片最大1g,最多可以打开8个文件,读取速度限制在100MB以内的吞吐量。
RMAN> configure channel device type disk maxpiecesize 1G maxopenfiles 8 rate 100m;
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 1 G MAXOPENFILES 8 RATE 100 M;
new RMAN configuration parameters are successfully stored
##这个命令设置了信道2的备份片最大2g,最多可以打开16个文件,读取速度限制在200MB以内的吞吐量。
RMAN> configure channel 1 device type disk maxpiecesize 2G maxopenfiles 16 rate 200m;
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK MAXPIECESIZE 2 G MAXOPENFILES 16 RATE 200 M;
new RMAN configuration parameters are successfully stored
#限制 及 取消 备份集整体大小
RMAN> configure maxsetsize to 10G;
old RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO UNLIMITED;
new RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO 10 G;
new RMAN configuration parameters are successfully stored
RMAN> configure maxsetsize clear;
old RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO 10 G;
RMAN configuration parameters are successfully reset to default value
or
RMAN> CONFIGURE MAXSETSIZE TO UNLIMITED;
old RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO 10 G;
new RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO UNLIMITED;
new RMAN configuration parameters are successfully stored
#配置控制文件自动备份
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
#配置默认保留策略
##保留最近3个备份,其他自动被删除
RMAN> configure retention policy to redundancy 3;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
new RMAN configuration parameters are successfully stored
#配置归档日志删除策略
##默认情况下oracle 将配置的备份保留策略应用于归档重做日志
###配置归档日志删除策略:归档日志备份超过 2 次,归档日志将会被删除。
RMAN> configure archivelog deletion policy to backed up 2 times to device type disk;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DISK;
new RMAN configuration parameters are successfully stored
AGD环境归档删除策略参考 ORACLE 12C ADG 之十五(ADG环境自动删除归档)
- 控制文件中存储备份记录的保留天数(大于FRA配置保留策略)
SQL> show parameter control_file_record_keep_time;
NAME TYPE VALUE
----------------------------- ------- ----------------------------
control_file_record_keep_time integer 7