关于一个冷备恢复的案例


关于一个冷备恢复的案例,
1)
冷备
2)
建一张表T1
3)
切两次日志,三组REDO日志状态为两个ACTIVE一个CURRENT
4)
Shutdown abort
5)
删除所有dbf文件
6)
恢复
7)
验证表T1是否存在


1.数据库冷备
SQL> shutdownimmediate
ORACLE instanceshut down.

SQL>host cp/u01/data/prod /u01/data/prod2


2.打开数据库新建一张表T1并切换日志为两个active一个current

SQL> startup
ORACLE instance started.

Total System Global Area
285212672 bytes
Fixed Size
1218968 bytes
Variable Size
79693416 bytes
Database Buffers
197132288 bytes
Redo Buffers
7168000 bytes
Database mounted.
Database opened.
SQL> select group#,status from v$log;


GROUP# STATUS
---------- --------------------------------

1 INACTIVE

2 CURRENT

3 INACTIVE

SQL> create table t1 as select * fromDBA_objects;

Table created.

SQL> select group#,status from v$log;


GROUP# STATUS
---------- --------------------------------

1 INACTIVE

2 CURRENT

3 INACTIVE

SQL> alter system switch logfile;

System altered.

SQL> select group#,status from v$log;


GROUP# STATUS
---------- --------------------------------

1 INACTIVE

2 ACTIVE

3 CURRENT

SQL> alter system switch logfile;

System altered.

SQL> select group#,status from v$log;


GROUP# STATUS
---------- --------------------------------

1 CURRENT

2 ACTIVE

3 ACTIVE

SQL> shutdown abort
ORACLE instance shut down.


3.删除数据库所有dbf文件,模拟数据文件丢失故障
SQL>host rm –rf /u01/data/prod/*.dbf

4.数据恢复
SQL>host cp –rf /u01/data/prod2/*.dbf/u01/data/prod/
SQL> startup
ORACLE instance started.

Total System Global Area
285212672 bytes
Fixed Size
1218968 bytes
Variable Size
79693416 bytes
Database Buffers
197132288 bytes
Redo Buffers
7168000 bytes
Database mounted.
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1:'/u01/data/prod/system01.dbf'


SQL> recover database;
Media recovery complete.
SQL> alter database open;

Database altered.


SQL> select count(*) from t1;


COUNT(*)
----------

50315

数据库得到完全恢复
标签: 暂无标签
liyugen

写了  篇文章,拥有财富 ,被  人关注

转播转播 分享分享 分享淘帖
回复

使用道具

P3 | 发表于 2012-9-22 23:36:28
谢谢LZ,最好多分享一些
回复

使用道具

P4 | 发表于 2012-9-27 09:36:06
生产环境中冷备很少用吧,不过感谢分享
回复

使用道具

您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

意见
反馈