自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

恢復(fù)控制文件后如何避免resetlogs打開數(shù)據(jù)庫?

數(shù)據(jù)庫 Oracle
恢復(fù)控制文件后,數(shù)據(jù)庫使用resetlogs方式打開,在線日志的序列被重置。如果恢復(fù)完控制文件,不使用resetlogs是打不開數(shù)據(jù)庫的。

[[194050]]

恢復(fù)控制文件后,數(shù)據(jù)庫使用resetlogs方式打開,在線日志的序列被重置。

  1. SYS@practice >select group#,sequence#,archived,status,first_change#,next_change# from v$log; 
  2.  
  3.    GROUP#  SEQUENCE# ARC STATUS           FIRST_CHANGE# NEXT_CHANGE# 
  4. ---------- ---------- --- ---------------- ------------- ------------ 
  5.         1          1 NO  CURRENT                1014415   2.8147E+14 
  6.         2          0 YES UNUSED                       0            0 
  7.         3          0 YES UNUSED                       0            0 

 如果沒有被resetlog截斷的話當(dāng)前日志的序列號應(yīng)該是7,8,9

  1. SYS@practice >select recid,sequence#,first_change#,next_change# from v$log_history; 
  2.  
  3.     RECID  SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# 
  4. ---------- ---------- ------------- ------------ 
  5.         1          1        925702       955284 
  6.         2          2        955284       955847 
  7.         3          3        955847       971151 
  8.         4          4        971151       987800 
  9.         5          5        987800       997957 
  10.         6          6        997957      1010981 
  11.         7          1       1010981      1013463 
  12.         8          2       1013463      1013471 
  13.         9          3       1013471      1014415 

如果恢復(fù)完控制文件,不使用resetlogs是打不開數(shù)據(jù)庫的。

我們可以采取手工創(chuàng)建控制文件的方法打開數(shù)據(jù)庫,保持聯(lián)機(jī)日志的sequence#連續(xù)。下面的實驗來演示具體操作過程。

在實驗之前先手工切換3次日志,使得在線日志的序列號產(chǎn)生變化。在恢復(fù)結(jié)束后作為參考。

  1. SYS@practice >alter system archive log current
  2.  
  3. SYS@practice >alter system archive log current
  4.  
  5. SYS@practice >alter system archive log current

切換后當(dāng)前連接日志狀態(tài)如下

  1. SYS@practice >select group#,sequence#,archived,status,first_change#,next_change# from v$log; 
  2.  
  3.    GROUP#  SEQUENCE# ARC STATUS           FIRST_CHANGE# NEXT_CHANGE# 
  4. ---------- ---------- --- ---------------- ------------- ------------ 
  5.         1          4 NO  CURRENT                1030130   2.8147E+14 
  6.         2          2 YES INACTIVE               1030109      1030117 
  7.         3          3 YES ACTIVE                 1030117      1030130 

 1、恢復(fù)控制文件

  1. RMAN> startup force nomount; 
  2.  
  3. Oracle instance started 
  4.  
  5. Total System Global Area     580395008 bytes 
  6.  
  7. Fixed Size                     2255392 bytes 
  8. Variable Size                402654688 bytes 
  9. Database Buffers             171966464 bytes 
  10. Redo Buffers                   3518464 bytes 
  11.  
  12. RMAN> restore controlfile from autobackup; 
  13.  
  14. Starting restore at 06-OCT-14 
  15. using target database control file instead of recovery catalog 
  16. allocated channel: ORA_DISK_1 
  17. channel ORA_DISK_1: SID=19 device type=DISK 
  18.  
  19. recovery area destination: /u01/fast_recovery_area 
  20. database name (or database unique name) used for search: PRACTICE 
  21. channel ORA_DISK_1: AUTOBACKUP /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860251717_b35s05gm_.bkp found in the recovery area 
  22. channel ORA_DISK_1: looking for AUTOBACKUP on day: 20141006 
  23. channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860251717_b35s05gm_.bkp 
  24. channel ORA_DISK_1: control file restore from AUTOBACKUP complete 
  25. output file name=/u01/oradata/practice/control01.ctl 
  26. output file name=/u01/fast_recovery_area/practice/control02.ctl 
  27. Finished restore at 06-OCT-14 

 2、啟動數(shù)據(jù)庫到mount狀態(tài)

  1. RMAN> mount database
  2.  
  3. database mounted 
  4. released channel: ORA_DISK_1 

 3、恢復(fù)數(shù)據(jù)庫

  1. RMAN> recover database
  2.  
  3. Starting recover at 06-OCT-14 
  4. Starting implicit crosscheck backup at 06-OCT-14 
  5. allocated channel: ORA_DISK_1 
  6. channel ORA_DISK_1: SID=20 device type=DISK 
  7. Crosschecked 6 objects 
  8. Finished implicit crosscheck backup at 06-OCT-14 
  9.  
  10. Starting implicit crosscheck copy at 06-OCT-14 
  11. using channel ORA_DISK_1 
  12. Finished implicit crosscheck copy at 06-OCT-14 
  13.  
  14. searching for all files in the recovery area 
  15. cataloging files... 
  16. cataloging done 
  17.  
  18. List of Cataloged Files 
  19. ======================= 
  20. File Name: /u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_1_b362kndr_.arc 
  21. File Name: /u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_3_b362lc83_.arc 
  22. File Name: /u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_2_b362l34q_.arc 
  23. File Name: /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860251717_b35s05gm_.bkp 
  24. File Name: /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860251162_b35rgt84_.bkp 
  25. File Name: /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860251158_b35rgpms_.bkp 
  26. File Name: /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860246909_b35n9x55_.bkp 
  27.  
  28. using channel ORA_DISK_1 
  29.  
  30. starting media recovery 
  31.  
  32. archived log for thread 1 with sequence 1 is already on disk as file /u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_1_b362kndr_.arc 
  33. archived log for thread 1 with sequence 2 is already on disk as file /u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_2_b362l34q_.arc 
  34. archived log for thread 1 with sequence 3 is already on disk as file /u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_3_b362lc83_.arc 
  35. archived log for thread 1 with sequence 4 is already on disk as file /u01/oradata/practice/redo01.log 
  36. archived log file name=/u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_1_b362kndr_.arc thread=1 sequence=1 
  37. archived log file name=/u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_2_b362l34q_.arc thread=1 sequence=2 
  38. archived log file name=/u01/fast_recovery_area/PRACTICE/archivelog/2014_10_06/o1_mf_1_3_b362lc83_.arc thread=1 sequence=3 
  39. archived log file name=/u01/oradata/practice/redo01.log thread=1 sequence=4 
  40. media recovery complete, elapsed time: 00:00:00 
  41. Finished recover at 06-OCT-14 

 4,備份控制文件到trace

  1. SYS@practice >select open_mode from v$database
  2.  
  3. OPEN_MODE 
  4. -------------------- 
  5. MOUNTED 
  6.  
  7. SYS@practice >alter database backup controlfile to trace; 
  8.  
  9.  
  10. SYS@practice >select value from v$diag_info where name='Default Trace File'
  11.  
  12. VALUE 
  13. -------------------------------------------------------------------------------- 
  14. /u01/diag/rdbms/practice/practice/trace/practice_ora_1185.trc 

 5、重啟實例到nomount狀態(tài)

  1. RMAN> startup force nomount; 
  2.  
  3. Oracle instance started 
  4.  
  5. Total System Global Area     580395008 bytes 
  6.  
  7. Fixed Size                     2255392 bytes 
  8. Variable Size                402654688 bytes 
  9. Database Buffers             171966464 bytes 
  10. Redo Buffers                   3518464 bytes 

 6、執(zhí)行重建控制文件命令進(jìn)入到mount狀態(tài)

  1. vi /home/oracle/create_controlfile.sql 
  2.  
  3. STARTUP NOMOUNT 
  4. CREATE CONTROLFILE REUSE DATABASE "PRACTICE" NORESETLOGS  ARCHIVELOG 
  5.    MAXLOGFILES 16 
  6.    MAXLOGMEMBERS 3 
  7.    MAXDATAFILES 100 
  8.    MAXINSTANCES 8 
  9.    MAXLOGHISTORY 292 
  10. LOGFILE 
  11.  GROUP 1 '/u01/oradata/practice/redo01.log'  SIZE 50M BLOCKSIZE 512, 
  12.  GROUP 2 '/u01/oradata/practice/redo02.log'  SIZE 50M BLOCKSIZE 512, 
  13.  GROUP 3 '/u01/oradata/practice/redo03.log'  SIZE 50M BLOCKSIZE 512 
  14. DATAFILE 
  15.  '/u01/oradata/practice/system01.dbf'
  16.  '/u01/oradata/practice/sysaux01.dbf'
  17.  '/u01/oradata/practice/undotbs01.dbf'
  18.  '/u01/oradata/practice/users01.dbf'
  19.  '/u01/oradata/practice/example01.dbf' 
  20. CHARACTER SET AL32UTF8 
  21. VARIABLE RECNO NUMBER; 
  22. EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON'); 
  23. RECOVER DATABASE 
  24. ALTER SYSTEM ARCHIVE LOG ALL
  25. ALTER DATABASE OPEN
  26. ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/oradata/practice/temp01.dbf' REUSE; 

 在sqlplus下執(zhí)行創(chuàng)建控制文件腳本,數(shù)據(jù)庫會啟動到open狀態(tài)并添加臨時表空間文件。

  1. SYS@practice >@create_controlfile.sql 
  2.  
  3. Control file created. 
  4.  
  5. PL/SQL procedure successfully completed. 
  6.  
  7. Media recovery complete. 
  8.  
  9. System altered. 
  10.  
  11. Database altered. 
  12.  
  13. Tablespace altered. 

 此時數(shù)據(jù)庫已經(jīng)處于read write狀態(tài)也就是open狀態(tài)了

  1. SYS@practice >select open_mode from v$database
  2.  
  3. OPEN_MODE 
  4. -------------------- 
  5. READ WRITE 

 查看當(dāng)前日志的序列號,沒有被重置。

  1. SYS@practice >select group#,sequence#,archived,status,first_change#,next_change# from v$log; 
  2.  
  3.    GROUP#  SEQUENCE# ARC STATUS           FIRST_CHANGE# NEXT_CHANGE# 
  4. ---------- ---------- --- ---------------- ------------- ------------ 
  5.         1          4 YES INACTIVE               1030130      1050296 
  6.         2          5 NO  CURRENT                1050296   2.8147E+14 
  7.         3          3 YES INACTIVE               1030117      1030130 

 查看臨時表數(shù)據(jù)文件也被創(chuàng)建出來了。

  1. SYS@practice >select name from v$tempfile; 
  2.  
  3. NAME 
  4. -------------------------------------------------------------------------------- 
  5. /u01/oradata/practice/temp01.dbf 

 7,重新識別控制文件的備份信息和配置信息

此時的控制文件中沒有之前備份過控制文件的信息

  1. RMAN> list backup of controlfile; 
  2.  
  3. using target database control file instead of recovery catalog 
  4. specification does not match any backup in the repository 

 從閃回恢復(fù)區(qū)重新注冊備份信息

  1. RMAN> catalog db_recovery_file_dest; 

從執(zhí)行過數(shù)據(jù)庫全備份的地址注冊備份信息 

  1. RMAN> catalog start with '/home/oracle/'

再次列出備份過的控制文件,可以看到已經(jīng)全部注冊成功 

  1. RMAN> list backup of controlfile; 
  2.  
  3. List of Backup Sets 
  4. =================== 
  5.  
  6. BS Key  Type LV Size       Device Type Elapsed Time Completion Time 
  7. ------- ---- -- ---------- ----------- ------------ --------------- 
  8. 1       Full    9.67M      DISK        00:00:00     06-OCT-14 
  9.        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20141006T175610 
  10.        Piece Name: /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860262970_b363zt2x_.bkp 
  11.  Control File Included: Ckp SCN: 1051644      Ckp time: 06-OCT-14 
  12.  
  13. BS Key  Type LV Size       Device Type Elapsed Time Completion Time 
  14. ------- ---- -- ---------- ----------- ------------ --------------- 
  15. 3       Full    9.33M      DISK        00:00:00     06-OCT-14 
  16.        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20141006T132827 
  17.        Piece Name: /u01/fast_recovery_area/PRACTICE/backupset/2014_10_06/o1_mf_ncnnf_TAG20141006T132827_b35n9w39_.bkp 
  18.  Control File Included: Ckp SCN: 1005439      Ckp time: 06-OCT-14 
  19.  
  20. BS Key  Type LV Size       Device Type Elapsed Time Completion Time 
  21. ------- ---- -- ---------- ----------- ------------ --------------- 
  22. 7       Full    9.33M      DISK        00:00:00     06-OCT-14 
  23.        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20141006T143909 
  24.        Piece Name: /home/oracle/full_PRACTICE_9_20141006_1.bak 
  25.  Control File Included: Ckp SCN: 1013438      Ckp time: 06-OCT-14 

 

責(zé)任編輯:龐桂玉 來源: Oracle疑點通
相關(guān)推薦

2010-06-09 15:40:59

MySQL數(shù)據(jù)庫文件

2011-03-23 09:31:26

歸檔日志文件數(shù)據(jù)庫恢復(fù)

2018-04-28 15:28:44

數(shù)據(jù)庫MySQL誤刪除

2011-05-13 13:26:52

master數(shù)據(jù)庫恢復(fù)

2019-08-20 14:02:07

MongoDB數(shù)據(jù)庫恢復(fù)數(shù)據(jù)

2011-03-24 11:14:46

2011-05-17 11:33:43

oracle數(shù)據(jù)庫

2011-08-01 14:26:01

數(shù)據(jù)庫SUSPECT

2011-03-30 14:08:27

MySQL數(shù)據(jù)庫刪除恢復(fù)

2011-08-02 08:59:52

Oracle控制文件

2011-08-29 16:41:14

OracleRMAN恢復(fù)數(shù)據(jù)文件的恢復(fù)

2011-03-22 15:55:26

數(shù)據(jù)庫內(nèi)容恢復(fù)

2011-05-24 10:26:12

Oracle數(shù)據(jù)庫日志文件

2010-11-15 15:34:30

ORACLE數(shù)據(jù)庫恢復(fù)

2010-06-01 15:40:07

數(shù)據(jù)庫網(wǎng)絡(luò)部署

2011-05-26 15:27:08

Oracle數(shù)據(jù)庫

2009-03-17 16:00:47

Oracle數(shù)據(jù)庫備份

2011-05-20 09:35:24

Oracle數(shù)據(jù)庫恢復(fù)備份

2011-04-02 11:02:54

SQL Server數(shù)文件恢復(fù)

2011-08-03 13:28:08

Oracle數(shù)據(jù)庫數(shù)據(jù)庫控制文件
點贊
收藏

51CTO技術(shù)棧公眾號