Oracle丢失归档日志做不完全恢复


环境:
OS:Red Hat Linux As 5
DB:Oracle 10.2.0.4
 
下面我们模拟归档日志丢失后的不完全恢复.
1.备份数据库
run{
  allocate channel c1 device type disk;
  allocate channel c2 device type disk;
  allocate channel c3 device type disk;
  allocate channel c4 device type disk;
  backup database format '/u02/rman_bak/full_%u_%T.bak';
  release channel c1;
  release channel c2;
  release channel c3;
  release channel c4;
}
 
2.执行不完全恢复,目的是使日志复位,这里的时间点是备份集生成后的时间点.
run{
set until time "to_date('2012-07-06 21:52:00','YYYY-MM-DD HH24:MI:SS')";
restore database;
recover database;
}
使日志复位
RMAN> alter database open resetlogs;
database opened
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     0
Next log sequence to archive   1
Current log sequence           1
 
3.再次备份数据,用来模拟日志丢失后的恢复
run{
  allocate channel c1 device type disk;
  allocate channel c2 device type disk;
  allocate channel c3 device type disk;
  allocate channel c4 device type disk;
  backup database format '/u02/rman_bak/full_%u_%T.bak';
  release channel c1;
  release channel c2;
  release channel c3;
  release channel c4;
}
 
4.模拟数据
SQL>connect scott/scott
SQL> create table tb_test
(
  id number,
  remark varchar2(30),
  create_time date default sysdate
);
Table created.
SQL>connect / as sysdba
写入第一条记录,并生成归档日志1
SQL>insert into scott.tb_test values(1,'第一次切换',sysdate);
SQL>commit;
SQL>alter system switch logfile;
这个时候会生成归档日志1
[oracle@hxl 2012_07_06]$ ls
o1_mf_1_1_7zfx44j4_.arc
写入第二条记录,并生成归档日志2
SQL>insert into scott.tb_test values(2,'第二次切换',sysdate);
SQL>commit;
SQL>alter system switch logfile;
这个时候会生成归档日志2
[oracle@hxl 2012_07_06]$ ls -1
o1_mf_1_1_7zfx44j4_.arc
o1_mf_1_2_7zfxmbq9_.arc
写入第三条记录,并生成归档日志3
SQL>insert into scott.tb_test values(3,'第三次切换',sysdate);
SQL>commit;
SQL>alter system switch logfile;
这个时候会生成归档日志3
[oracle@hxl 2012_07_06]$ ls -1
o1_mf_1_1_7zfx44j4_.arc
o1_mf_1_2_7zfxmbq9_.arc
o1_mf_1_3_7zfy5jnz_.arc
写入第四条记录,并生成归档日志4
SQL>insert into scott.tb_test values(4,'第四次切换',sysdate);
SQL>commit;
SQL>alter system switch logfile;
这个时候会生成归档日志4
[oracle@hxl 2012_07_06]$ ls -1
o1_mf_1_1_7zfx44j4_.arc
o1_mf_1_2_7zfxmbq9_.arc
o1_mf_1_3_7zfy5jnz_.arc
o1_mf_1_4_7zfyth7x_.arc
 
5.我们使用不完全恢复恢复生成归档日志的时间点,记录该时间点'2012-07-06 22:50:00'
[oracle@hxl 2012_07_06]$ ls -al
total 14264
drwxr-x---  2 oracle oinstall    4096 Jul  6 22:50 .
drwxr-x--- 11 oracle oinstall    4096 Jul  6 21:52 ..
-rw-r-----  1 oracle oinstall 9038848 Jul  6 22:21 o1_mf_1_1_7zfx44j4_.arc
-rw-r-----  1 oracle oinstall 5408256 Jul  6 22:30 o1_mf_1_2_7zfxmbq9_.arc
-rw-r-----  1 oracle oinstall   41984 Jul  6 22:39 o1_mf_1_3_7zfy5jnz_.arc
-rw-r-----  1 oracle oinstall   45568 Jul  6 22:50 o1_mf_1_4_7zfyth7x_.arc

  • 1
  • 2
  • 下一页

相关内容