环境:
OS:Centos Linux7.3
DB:oracle11.2.0.4
在ARCHIVELOG模式下恢复system表空间数据文件实验
1.确认数据库当前为归档模式;
centos@SYS> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /home/oracle/arch Oldest online log sequence 2 Next log sequence to archive 4 Current log sequence 4 centos@SYS>
2.使用RMAN备份system表空间;
RMAN> backup tablespace system; Starting backup at 07-APR-17 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/centos/system01.dbf channel ORA_DISK_1: starting piece 1 at 07-APR-17 channel ORA_DISK_1: finished piece 1 at 07-APR-17 piece handle=/u01/app/oracle/flash/centos_db12s13qqg_1_1.rman tag=TAG20170407T170728 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 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 including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 07-APR-17 channel ORA_DISK_1: finished piece 1 at 07-APR-17 piece handle=/u01/app/oracle/flash/centos_db13s13qqn_1_1.rman tag=TAG20170407T170728 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 07-APR-17 RMAN>
3.模拟故障删除system表空间;
centos@SYS> select file_name from dba_data_files where tablespace_name='SYSTEM'; FILE_NAME -------------------------------------------------- /u01/app/oracle/oradata/centos/system01.dbf centos@SYS> !ls /u01/app/oracle/oradata/centos/system01.dbf /u01/app/oracle/oradata/centos/system01.dbf centos@SYS> !rm /u01/app/oracle/oradata/centos/system01.dbf centos@SYS> !ls /u01/app/oracle/oradata/centos/system01.dbf ls: cannot access /u01/app/oracle/oradata/centos/system01.dbf: No such file or directory centos@SYS>
4.重启数据库报错,通过RMAN恢复system表空间;
Database dismounted. ORACLE instance shut down. centos@SYS> startup ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 587205752 bytes Database Buffers 239075328 bytes Redo Buffers 2392064 bytes Database mounted. ORA-01157: cannot identify/lock data file 1 - see DBWR trace file ORA-01110: data file 1: '/u01/app/oracle/oradata/centos/system01.dbf' centos@SYS>
RMAN> restore tablespace system; Starting restore at 07-APR-17 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=20 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/centos/system01.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash/centos_db12s13qqg_1_1.rman channel ORA_DISK_1: piece handle=/u01/app/oracle/flash/centos_db12s13qqg_1_1.rman tag=TAG20170407T170728 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 07-APR-17 RMAN> recover tablespace system; Starting recover at 07-APR-17 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 07-APR-17 RMAN> alter database open; database opened RMAN>
5.查看恢复状态;
centos@SYS> select status from v$instance; STATUS ------------ OPEN centos@SYS> select file_name from dba_data_files where tablespace_name='SYSTEM'; FILE_NAME -------------------------------------------------- /u01/app/oracle/oradata/centos/system01.dbf centos@SYS> !ls /u01/app/oracle/oradata/centos/system01.dbf /u01/app/oracle/oradata/centos/system01.dbf centos@SYS>
至此恢复结束,备份很重要!!!
---END---Good Luck---