查看数据库是否处于非归档模式
oracle 11g 手工冷备_第1张图片
关闭数据库
shutdown immediate
备份控制文件和数据文件(没有备份日志文件,建议一起备份)

[oracle@enmoedu1 PROD]$ ll
total 2014624
-rw-r----- 1 oracle oinstall   9748480 Jan 24 21:49 control01.ctl
-rw-r----- 1 oracle oinstall   9748480 Jan 24 21:49 control02.ctl
-rw-r----- 1 oracle oinstall 363077632 Jan 24 21:49 example01.dbf
-rw-r----- 1 oracle oinstall  52429312 Jan 24 21:48 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Jan 24 21:49 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Jan 24 21:48 redo03.log
-rw-r----- 1 oracle oinstall 576724992 Jan 24 21:49 sysaux01.dbf
-rw-r----- 1 oracle oinstall 807411712 Jan 24 21:49 system01.dbf
-rw-r----- 1 oracle oinstall  30416896 Jan 24 21:48 temp01.dbf
-rw-r----- 1 oracle oinstall 110108672 Jan 24 21:49 undotbs01.dbf
-rw-r----- 1 oracle oinstall  26222592 Jan 24 21:49 users01.dbf
[oracle@enmoedu1 PROD]$ cp *.dbf /home/oracle/bak/
[oracle@enmoedu1 PROD]$ cp *.ctl /home/oracle/bak/
[oracle@enmoedu1 PROD]$ 

启动数据库,并创建一个表,插入数据提交

startup  ——启动数据库
SYS@PROD> create table t4(id number);
Table created.
SYS@PROD> insert into t4 values(1);
1 row created.
SYS@PROD> commit;
Commit complete.
SYS@PROD> select * from t4;
    ID
----------
     1
SYS@PROD> 

关闭数据库,删除数据文件和控制文件

[oracle@enmoedu1 PROD]$ rm -rf *.dbf
[oracle@enmoedu1 PROD]$ rm -rf *.ctl
[oracle@enmoedu1 PROD]$ ll
total 153612
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:57 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo03.log
[oracle@enmoedu1 PROD]$ 

启动数据库到nomount,说明参数文件没问题,到mount,找不到控制文件,使用操作系统命令拷贝控制文件再mount

SYS@PROD> startup nomount;
ORACLE instance started.
Total System Global Area  835104768 bytes
Fixed Size          2257840 bytes
Variable Size         536874064 bytes
Database Buffers      289406976 bytes
Redo Buffers            6565888 bytes
SYS@PROD> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info
SYS@PROD> host
[oracle@enmoedu1 PROD]$ cp /home/oracle/bak/*.ctl ./
[oracle@enmoedu1 PROD]$ ll
total 172652
-rw-r----- 1 oracle oinstall  9748480 Jan 24 22:01 control01.ctl
-rw-r----- 1 oracle oinstall  9748480 Jan 24 22:01 control02.ctl
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:57 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo03.log
[oracle@enmoedu1 PROD]$ exit
SYS@PROD> alter database mount;——可以到mount了,控制文件没问题了
Database altered.
SYS@PROD> 
SYS@PROD> alter database open;——找不到数据文件,
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/system01.dbf'
SYS@PROD> 

拷贝回数据文件

[oracle@enmoedu1 PROD]$ cp /home/oracle/bak/*.dbf ./
[oracle@enmoedu1 PROD]$ ll
total 2014848
-rw-r----- 1 oracle oinstall   9748480 Jan 24 22:05 control01.ctl
-rw-r----- 1 oracle oinstall   9748480 Jan 24 22:05 control02.ctl
-rw-r----- 1 oracle oinstall 363077632 Jan 24 22:03 example01.dbf
-rw-r----- 1 oracle oinstall  52429312 Jan 24 21:56 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Jan 24 21:57 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Jan 24 21:56 redo03.log
-rw-r----- 1 oracle oinstall 576724992 Jan 24 22:04 sysaux01.dbf
-rw-r----- 1 oracle oinstall 807411712 Jan 24 22:05 system01.dbf
-rw-r----- 1 oracle oinstall  30416896 Jan 24 22:05 temp01.dbf
-rw-r----- 1 oracle oinstall 110108672 Jan 24 22:05 undotbs01.dbf
-rw-r----- 1 oracle oinstall  26222592 Jan 24 22:05 users01.dbf
[oracle@enmoedu1 PROD]$ exit
SYS@PROD> alter database open;
alter database open
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 2951
Session ID: 125 Serial number: 3

发现报错了,因为我备份了控制文件和数据文件,然后开库新建了一个表,导致数据库的日志文件和控制文件的scn不一致了,查看alter日志
oracle 11g 手工冷备_第2张图片
进入startup mount执行
recover database until cancel;
alter database open resetlogs;

startup mount ——进入到mount
SYS@PROD> recover database until cancel;——不完全恢复
Media recovery complete.
SYS@PROD> alter database open resetlogs;——重置日志
Database altered.
SYS@PROD> select open_mode from v$database;——数据库已经打开
OPEN_MODE
--------------------
READ WRITE
SYS@PROD> select * from t4;——查询t4表,没有数据
select * from t4
              *
ERROR at line 1:
ORA-00942: table or view does not exist
SYS@PROD>