備份與恢復:用user模式基於日誌序列的不完全恢復

paulyibinyi發表於2008-04-21

sql>shutdown immediate;

冷備資料庫所有資料檔案

SQL> startup
ORACLE instance started.

Total System Global Area  101785252 bytes
Fixed Size                   454308 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SQL> select * from test;

         A
----------
         1
         2
         3
         4

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            D:\oracle\ora92\RDBMS
Oldest online log sequence     0
Next log sequence to archive   1
Current log sequence           1
SQL> alter system switch logfile;

System altered.

SQL> insert into test values(5);

1 row created.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            D:\oracle\ora92\RDBMS
Oldest online log sequence     1
Next log sequence to archive   3
Current log sequence           3
SQL> insert into test values(6);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from test;

         A
----------
         1
         2
         3
         4
         5
         6

6 rows selected.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            D:\oracle\ora92\RDBMS
Oldest online log sequence     2
Next log sequence to archive   4
Current log sequence           4
SQL> select * from test;

         A
----------
         1
         2
         3
         4
         5
         6

6 rows selected.

SQL> insert into test values(7);      --7這個值用到的日誌序列為4

1 row created.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            D:\oracle\ora92\RDBMS
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5
SQL> insert into test values(8);   --8這個值用到的日誌序列為5

1 row created.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;     

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

恢復所有冷備的資料檔案
SQL> startup mount;
ORACLE instance started.

Total System Global Area  101785252 bytes
Fixed Size                   454308 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.

做不完全恢復到日誌序列為4
SQL> recover database until cancel;
ORA-00279: change 270609 generated at 04/21/2008 10:22:02 needed for thread 1
ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00001.001
ORA-00280: change 270609 for thread 1 is in sequence #1


Specify log: {=suggested | filename | AUTO | CANCEL}
D:\oracle\ora92\rdbms\ARC00001.001
ORA-00279: change 270822 generated at 04/21/2008 10:28:29 needed for thread 1
ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00002.001
ORA-00280: change 270822 for thread 1 is in sequence #2
ORA-00278: log file 'D:\oracle\ora92\rdbms\ARC00001.001' no longer needed for
this recovery


Specify log: {=suggested | filename | AUTO | CANCEL}
D:\oracle\ora92\rdbms\ARC00002.001
ORA-00279: change 270856 generated at 04/21/2008 10:30:06 needed for thread 1
ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00003.001
ORA-00280: change 270856 for thread 1 is in sequence #3
ORA-00278: log file 'D:\oracle\ora92\rdbms\ARC00002.001' no longer needed for
this recovery


Specify log: {=suggested | filename | AUTO | CANCEL}
D:\oracle\ora92\rdbms\ARC00003.001
ORA-00279: change 270869 generated at 04/21/2008 10:30:37 needed for thread 1
ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00004.001
ORA-00280: change 270869 for thread 1 is in sequence #4
ORA-00278: log file 'D:\oracle\ora92\rdbms\ARC00003.001' no longer needed for
this recovery


Specify log: {=suggested | filename | AUTO | CANCEL}
D:\oracle\ora92\rdbms\ARC00004.001
ORA-00279: change 270918 generated at 04/21/2008 10:33:01 needed for thread 1
ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00005.001
ORA-00280: change 270918 for thread 1 is in sequence #5
ORA-00278: log file 'D:\oracle\ora92\rdbms\ARC00004.001' no longer needed for
this recovery


Specify log: {=suggested | filename | AUTO | CANCEL}
cancel                                  --ARC00005.001 這個撤消不恢復了
Media recovery cancelled.
SQL> alter database open resetlogs;

Database altered.

SQL> select * from test;

         A
----------
         1
         2
         3
         4
         5
         6
         7

7 rows selected. 

SQL>

看結果只恢復到日誌序列4對應的test表資料為7

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-246145/,如需轉載,請註明出處,否則將追究法律責任。

相關文章