小e随笔:今天小e的博客正式开通,欢迎同学们莅临指导
blog:http://blog.csdn.net/elvis_dataguru
案例2:非归档模式下部分脱机备份(tablespace offline)
与前面完全脱机备份案列2类同,就不在重复演示,在多说一句,我们虽然模拟了很多不完全恢复,但真正工作中,一定要尽量避免这种不完全恢复的情况,就算数据库能打开了,也给数据库带来了很多未知的bug,一般经过了不完全恢复后,都建议重建个库,把数据全部都导入到新建的库中。
总结:以前小e一直认为表空间在未归档的时候不能offline,在此强调经过测试,在非归档模式下也可以offline,当然有几个表空间无论处于归档还是非归档都不能offline,前面小e说过,就不在重复了,如果忘了的同学或者刚看小e笔记的同学,请往前看。
4 部分联机备份
案例:归档模式下一个或多个数据文件损坏
备份方案:OS联机备份
l 备份文件
SQL> select * from test;
no rows selected
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 55
Next log sequence to archive 57
Current log sequence 57
SQL> alter tablespace test begin backup;
Tablespace altered.
[oracle@elvis elvis]$ cp test01.dbf bak/
这个时候正往里插入数据
l 模拟数据
SQL> insert into test values(1,dbms_flashback.get_system_change_number);
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
循环插入,数据如下:
SQL> select * from test;
ID SCN
---------- ----------
1 561783
2 561798
3 561807
记住这3条数据是在表空间开始备份模式下,插入的数据,现在结束这种状态
SQL> alter tablespace test end backup;
Tablespace altered.
结束状态后插入的数据
SQL> insert into test values(4,dbms_flashback.get_system_change_number);
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> insert into test values(5,dbms_flashback.get_system_change_number);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test;
ID SCN
---------- ----------
1 561783
2 561798
3 561807
4 562414
5 562428 --未归档
l 模拟数据文件损坏
[oracle@elvis elvis]$ rm -f test01.dbf
[oracle@elvis elvis]$ ll
total 1747280
drwxr-xr-x 2 oracle oinstall 4096 Oct 7 14:52 bak
-rw-r----- 1 oracle oinstall 9748480 Oct 7 15:08 control01.ctl
-rw-r----- 1 oracle oinstall 52429312 Oct 7 15:08 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Oct 7 14:59 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Oct 7 15:05 redo03.log
-rw-r----- 1 oracle oinstall 629153792 Oct 7 15:06 sysaux01.dbf
-rw-r----- 1 oracle oinstall 734011392 Oct 7 15:06 system01.dbf
-rw-r----- 1 oracle oinstall 71311360 Oct 7 14:52 temp01.dbf
-rw-r----- 1 oracle oinstall 235937792 Oct 7 15:06 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Oct 7 15:05 users01.dbf
SQL> shutdown abort;
ORACLE instance shut down
SQL> startup
ORACLE instance started.
Total System Global Area 598437888 bytes
Fixed Size 1338140 bytes
Variable Size 394265828 bytes
Database Buffers 197132288 bytes
Redo Buffers 5701632 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/u01/oracle/oradata/elvis/test01.dbf'
l 数据恢复
[oracle@elvis bak]$ cp test01.dbf .. –类似于restore过程
SQL> select file#,checkpoint_change# from v$datafile;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
1 561814
2 561814
3 561814
4 561814
5 561814
SQL> select file#,checkpoint_change# from v$datafile_header;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
1 561814
2 561814
3 561814
4 561814
5 560762
SQL> recover database;
ORA-00279: change 560762 generated at 10/07/2012 14:51:50 needed for thread 1
ORA-00289: suggestion :
/u01/oracle/flash_recovery_area/ELVIS/archivelog/2012_10_07/o1_mf_1_57_872b169o_
.arc
ORA-00280: change 560762 for thread 1 is in sequence #57
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 561793 generated at 10/07/2012 14:58:46 needed for thread 1
ORA-00289: suggestion :
/u01/oracle/flash_recovery_area/ELVIS/archivelog/2012_10_07/o1_mf_1_58_872b1xrq_
.arc
ORA-00280: change 561793 for thread 1 is in sequence #58
Log applied.
Media recovery complete.
SQL> alter database open;
Database altered.
SQL> select * from test;
ID SCN
---------- ----------
1 561783
2 561798
3 561807
4 562414
5 562428
总结:
这种恢复方式有一个好处就是可以在不影响业务和数据库运行包括备份的这个表空间的情况下,得以备份。
非归档模式下就不演示了。
elvis
2012.10.8
知识共享~共同进步
转载请注明:
http://blog.csdn.net/elvis_dataguru/article/details/8054659