測試丟失全部控制文件恢復[20180517]
rman target /
show all;
configure channel 1 device type disk format '/u01/backup/rman_backup_%U.bak';
backup current controlfile;
鏈接到RMAN
[oracle@t-xi-oracle01 archive]$ rman target /
爲磁盤備份設定路徑和命名規則
RMAN> configure channel 1 device type disk format '/u01/backup/rman_backup_%U.bak';
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/u01/backup/rman_backup_%U.bak';
new RMAN configuration parameters are successfully stored
查看當前全部的配置
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name XIOCPT0 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
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 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 LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_xiocpt0.f'; # default
備份當前控制文件
RMAN> backup current controlfile;
Starting backup at 17-MAY-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 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 17-MAY-18
channel ORA_DISK_1: finished piece 1 at 17-MAY-18
piece handle=/u01/backup/rman_backup_01t34led_1_1.bak tag=TAG20180517T155453 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 17-MAY-18
查看備份
RMAN> list backup; 或 list backup of controlfile;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 9.64M DISK 00:00:01 17-MAY-18
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20180517T155453
Piece Name: /u01/backup/rman_backup_01t34led_1_1.bak
Control File Included: Ckp SCN: 990446 Ckp time: 17-MAY-18
select * from v$controfile;
手動刪除控制文件
SQL> !rm -rf /u01/app/oracle/oradata/xiocpt0/control01.ctl /u01/app/oracle/fast_recovery_area/xiocpt0/control02.ctl
Errors in file /u01/app/oracle/diag/rdbms/xiocpt0/xiocpt0/trace/xiocpt0_m001_1649.trc:
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/xiocpt0/control01.ctl'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
數據庫關閉
shutdown abort
啓動到nomount狀態,從備份檔中恢復控制文件,注意此時控制文件不是最新的
[oracle@t-xi-oracle01 archive]$ rman target /數據庫
RMAN>restore controlfile from '/u01/backup/rman_backup_01t34led_1_1.bak';oracle
Starting restore at 17-MAY-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISKapp
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/xiocpt0/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/xiocpt0/control02.ctl
Finished restore at 17-MAY-18測試
數據庫啓動MOUNT狀態
alter database mount;
建立控制文件到trace文件中
alter database backup controlfile to trace as '/u01/backup_controlfile.ctl';
再次關閉數據庫,手動恢復控制文件,數據庫完整恢復。
shutdown immedaite
注意使用NORESETLOGS
STARTUP NOMOUNT
CREATE CONTROLFILE
REUSE DATABASE "XIOCPT0" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/xiocpt0/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/xiocpt0/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/oradata/xiocpt0/redo03.log' SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/xiocpt0/system01.dbf',
'/u01/app/oracle/oradata/xiocpt0/sysaux01.dbf',
'/u01/app/oracle/oradata/xiocpt0/undotbs01.dbf',
'/u01/app/oracle/oradata/xiocpt0/users01.dbf'
CHARACTER SET AL32UTF8
;
RECOVER DATABASE
ALTER SYSTEM ARCHIVE LOG ALL;
ALTER DATABASE OPEN;
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/xiocpt0/temp01.dbf' REUSE;