oracle 11g 手工冷备

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

[[email protected] 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
[[email protected] PROD]$ cp *.dbf /home/oracle/bak/
[[email protected] PROD]$ cp *.ctl /home/oracle/bak/
[[email protected] PROD]$ 

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

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

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

[[email protected] PROD]$ rm -rf *.dbf
[[email protected] PROD]$ rm -rf *.ctl
[[email protected] 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
[[email protected] PROD]$ 

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

[email protected]> 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
[email protected]> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info
[email protected]> host
[[email protected] PROD]$ cp /home/oracle/bak/*.ctl ./
[[email protected] 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
[[email protected] PROD]$ exit
[email protected]> alter database mount;——可以到mount了,控制文件没问题了
Database altered.
[email protected]> 
[email protected]> 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'
[email protected]> 

拷贝回数据文件

[[email protected] PROD]$ cp /home/oracle/bak/*.dbf ./
[[email protected] 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
[[email protected] PROD]$ exit
[email protected]> 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 手工冷备
进入startup mount执行
recover database until cancel;
alter database open resetlogs;

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









本文转自 rm_rf_db 51CTO博客,原文链接:http://blog.51cto.com/12185273/2064826,如需转载请自行联系原作者