1,查看已经备份的控制文件
RMAN> list backup of controlfile;
specification does not match any backup in the repository
2,启动控制文件自动备份
RMAN> configure controlfile autobackup on;
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN>
3,查看是否修改成功
RMAN> show CONTROLFILE AUTOBACKUP;
RMAN configuration parameters for database with db_unique_name POWERDES are:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN>
4,修改控制文件的备份文件的存放位置,这里注意一下其中的“%F”不可或缺,如果已经有了旧的存放路径,这里则会显示旧的路径。
configure controlfile autobackup format for device type disk to '/data2/backup/data/controlfiles/%F';
RMAN> configure controlfile autobackup format for device type disk to '/data2/backup/data/controlfiles/%F';
using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backupdisk/backup/data/controlfiles/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/data2/backup/data/controlfiles/%F';
new RMAN configuration parameters are successfully stored
RMAN>
5,查看控制文件路径是否修改成功
执行命令:show controlfile autobackup format;
RMAN> show controlfile autobackup format;
RMAN configuration parameters for database with db_unique_name POWERDES are:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/data2/backup/data/controlfiles/%F';
RMAN>
只要执行backup database;命令,都会自动备份控制文件到新的目录/data2/backup/data/controlfiles/下面。
6,也可以自己手动执行备份控制文件backup current controlfile,默认备份到闪回目录下,然后也会再次备份到新目录,也就是备份了2回,如下所示:
RMAN> backup current controlfile;
Starting backup at 21-MAR-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=100 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 21-MAR-17
channel ORA_DISK_1: finished piece 1 at 21-MAR-17
piece handle=/oracle/app/oracle/flash_recovery_area/POWERDES/backupset/2017_03_21/o1_mf_ncnnf_TAG20170321T154409_df1pgd5s_.bkp tag=TAG20170321T154409 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-MAR-17
Starting Control File and SPFILE Autobackup at 21-MAR-17
piece handle=/data2/backup/data/controlfiles/c-3391761643-20170321-02 comment=NONE
Finished Control File and SPFILE Autobackup at 21-MAR-17
RMAN>
7,如何查看已经备份过的控制文件信息
RMAN> list backup of controlfile;
List of Backup Sets
BS Key Type LV Size Device Type Elapsed Time Completion Time
7523 Full 24.14M DISK 00:00:03 21-MAR-17
BP Key: 7527 Status: AVAILABLE Compressed: NO Tag: TAG20170321T154409
Piece Name: /oracle/app/oracle/flash_recovery_area/POWERDES/backupset/2017_03_21/o1_mf_ncnnf_TAG20170321T154409_df1pgd5s_.bkp
Control File Included: Ckp SCN: 14039839741 Ckp time: 21-MAR-17
BS Key Type LV Size Device Type Elapsed Time Completion Time
7524 Full 24.17M DISK 00:00:01 21-MAR-17
BP Key: 7528 Status: AVAILABLE Compressed: NO Tag: TAG20170321T154413
Piece Name: /data2/backup/data/controlfiles/c-3391761643-20170321-02
Control File Included: Ckp SCN: 14039839907 Ckp time: 21-MAR-17
RMAN>
8,在rman中还可以使用copy命令,将控制文件复制到你熟悉的目录,比如copy到/home/oracle根目录下面
执行命令:copy current controlfile to '/home/oracle/rman_controlfile_20179321.ctl';
RMAN> copy current controlfile to '/home/oracle/rman_controlfile_20179321.ctl';
Starting backup at 21-MAR-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/home/oracle/rman_controlfile_20179321.ctl tag=TAG20170321T155406 RECID=6 STAMP=939225248
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 21-MAR-17
Starting Control File and SPFILE Autobackup at 21-MAR-17
piece handle=/data2/backup/data/controlfiles/c-3391761643-20170321-03 comment=NONE
Finished Control File and SPFILE Autobackup at 21-MAR-17
RMAN>