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,rman备份控制文件
也可以自己手动执行备份控制文件backup current controlfile,默认备份到闪回目录下,然后也会再次备份到新目录,也就是备份了2回,如下所示:
RMAN> backup current controlfile;
Starting backup at @H_403_152@21-MAR-@H_403_152@17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=@H_403_152@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 @H_403_152@1 at @H_403_152@21-MAR-@H_403_152@17
channel ORA_DISK_1: finished piece @H_403_152@1 at @H_403_152@21-MAR-@H_403_152@17
piece handle=/oracle/app/oracle/flash_recovery_area/POWERDES/backupset/@H_403_152@2017_03_21/o1_mf_ncnnf_TAG20170321T154409_df1pgd5s_.bkp tag=TAG20170321T154409 comment=NONE
channel ORA_DISK_1: backup set complete,elapsed time: @H_403_152@00:@H_403_152@00:@H_403_152@01
Finished backup at @H_403_152@21-MAR-@H_403_152@17
Starting Control File and SPFILE Autobackup at @H_403_152@21-MAR-@H_403_152@17
piece handle=/data2/backup/data/controlfiles/c-@H_403_152@3391761643-@H_403_152@20170321-@H_403_152@02 comment=NONE
Finished Control File and SPFILE Autobackup at @H_403_152@21-MAR-@H_403_152@17
RMAN>
7,如何查看已经备份过的控制文件信息
RMAN> list backup of controlfile;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
@H_403_152@7523 Full @H_403_152@24.14M DISK @H_403_152@00:@H_403_152@00:@H_403_152@03 @H_403_152@21-MAR-@H_403_152@17
BP Key: @H_403_152@7527 Status: AVAILABLE Compressed: NO Tag: TAG20170321T154409
Piece Name: /oracle/app/oracle/flash_recovery_area/POWERDES/backupset/@H_403_152@2017_03_21/o1_mf_ncnnf_TAG20170321T154409_df1pgd5s_.bkp
Control File Included: Ckp SCN: @H_403_152@14039839741 Ckp time: @H_403_152@21-MAR-@H_403_152@17
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
@H_403_152@7524 Full @H_403_152@24.17M DISK @H_403_152@00:@H_403_152@00:@H_403_152@01 @H_403_152@21-MAR-@H_403_152@17
BP Key: @H_403_152@7528 Status: AVAILABLE Compressed: NO Tag: TAG20170321T154413
Piece Name: /data2/backup/data/controlfiles/c-@H_403_152@3391761643-@H_403_152@20170321-@H_403_152@02
Control File Included: Ckp SCN: @H_403_152@14039839907 Ckp time: @H_403_152@21-MAR-@H_403_152@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 @H_403_152@21-MAR-@H_403_152@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=@H_403_152@6 STAMP=@H_403_152@939225248
channel ORA_DISK_1: datafile copy complete,elapsed time: @H_403_152@00:@H_403_152@00:@H_403_152@03
Finished backup at @H_403_152@21-MAR-@H_403_152@17
Starting Control File and SPFILE Autobackup at @H_403_152@21-MAR-@H_403_152@17
piece handle=/data2/backup/data/controlfiles/c-@H_403_152@3391761643-@H_403_152@20170321-@H_403_152@03 comment=NONE
Finished Control File and SPFILE Autobackup at @H_403_152@21-MAR-@H_403_152@17
RMAN>