实验环境:
OS:Centos Linux 7.3
DB:Oracle11g(11.2.0.4)
注意:冷备时需一致性关闭数据库后再备份,否则会出现无法恢复的情况。
第一步:查看数据、日志、控制文件目录,并安全一致性关库;
centos@SYS> select name from v$controlfile; NAME --------------------------------------------- /u01/app/oracle/oradata/centos/control01.ctl /u01/app/oracle/oradata/centos/control02.ctl centos@SYS> select * from v$dbfile; NAME ------------------------------------------------ 4 /u01/app/oracle/oradata/centos/users01.dbf 3 /u01/app/oracle/oradata/centos/undotbs01.dbf 2 /u01/app/oracle/oradata/centos/sysaux01.dbf 1 /u01/app/oracle/oradata/centos/system01.dbf 5 /u01/app/oracle/oradata/centos/example01.dbf 6 /u01/app/oracle/oradata/centos/t1.dbf 7 /u01/app/oracle/oradata/centos/t2.dbf 7 rows selected. centos@SYS> select member from v$logfile; MEMBER ------------------------------------------- /u01/app/oracle/oradata/centos/redo03.log /u01/app/oracle/oradata/centos/redo02.log /u01/app/oracle/oradata/centos/redo01.log centos@SYS> centos@SYS> alter system checkpoint; System altered. centos@SYS> alter system archive log current; System altered. centos@SYS> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. centos@SYS>
第二步:创建冷备所需目录,并备份数据、日志、控制文件;
[oracle@centos ~]$ mkdir -p itkaifang_bak [oracle@centos ~]$ ls afiedt.buf cold_bak Desktop Documents Downloads itkaifang_bak Music Pictures Public Templates Videos [oracle@centos ~]$ cd /u01/app/oracle/oradata/centos/ [oracle@centos centos]$ ls control01.ctl example01.dbf redo02.log sysaux01.dbf t1.dbf temp01.dbf users01.dbf control02.ctl redo01.log redo03.log system01.dbf t2.dbf undotbs01.dbf [oracle@centos centos]$ cp * /home/oracle/itkaifang_bak [oracle@centos centos]$ cd [oracle@centos ~]$ ls afiedt.buf cold_bak Desktop Documents Downloads itkaifang_bak Music Pictures Public Templates Videos [oracle@centos ~]$ cd itkaifang_bak/ [oracle@centos itkaifang_bak]$ ls control01.ctl example01.dbf redo02.log sysaux01.dbf t1.dbf temp01.dbf users01.dbf control02.ctl redo01.log redo03.log system01.dbf t2.dbf undotbs01.dbf [oracle@centos itkaifang_bak]$ du -sh 2.0G . [oracle@centos itkaifang_bak]$
第三步:启动数据库,模拟故障人为删除控制、数据、日志文件,然后关闭数据库;
centos@SYS> startup ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 536874104 bytes Database Buffers 289406976 bytes Redo Buffers 2392064 bytes Database mounted. Database opened. centos@SYS> !cd /u01/app/oracle/oradata/centos centos@SYS> !ls control01.ctl redo01.log sysaux01.dbf t2.dbf users01.dbf control02.ctl redo02.log system01.dbf temp01.dbf example01.dbf redo03.log t1.dbf undotbs01.dbf centos@SYS> !rm * centos@SYS> !ls centos@SYS> shutdown immediate Database closed. ORA-00210: cannot open the specified control file ORA-00202: control file: '/u01/app/oracle/oradata/centos/control01.ctl' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 centos@SYS> shutdown abort ORACLE instance shut down. centos@SYS>
第四步:启动数据库到nomount状态,再到mount状态,然后到open状态;到mount时报错,开始从冷备目录恢复文件到原位置,启动数据库至open状态;
centos@SYS> startup nomount; ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 536874104 bytes Database Buffers 289406976 bytes Redo Buffers 2392064 bytes centos@SYS> alter database mount; alter database mount * ERROR at line 1: ORA-00205: error in identifying control file, check alert log for more info centos@SYS>
[oracle@centos ~]$ ls afiedt.buf cold_bak Desktop Documents Downloads itkaifang_bak Music Pictures Public Templates Videos [oracle@centos ~]$ cd itkaifang_bak/ [oracle@centos itkaifang_bak]$ ls control01.ctl example01.dbf redo02.log sysaux01.dbf t1.dbf temp01.dbf users01.dbf control02.ctl redo01.log redo03.log system01.dbf t2.dbf undotbs01.dbf [oracle@centos itkaifang_bak]$ cp * /u01/app/oracle/oradata/centos/ [oracle@centos itkaifang_bak]$ cd /u01/app/oracle/oradata/centos/ [oracle@centos centos]$ ls control01.ctl example01.dbf redo02.log sysaux01.dbf t1.dbf temp01.dbf users01.dbf control02.ctl redo01.log redo03.log system01.dbf t2.dbf undotbs01.dbf [oracle@centos centos]$
启动数据库至mount状态;
centos@SYS> alter database mount; Database altered. centos@SYS>
启动至open状态;
centos@SYS> alter database open; Database altered. centos@SYS>