改變歸檔模式,顯示歸檔資訊

楊奇龍發表於2010-05-06

一些關於歸檔日誌的常用DDL語句的用法及作用。

 

一 顯示日誌的操作模式。

SQL> select log_mode from v$database;

LOG_MODE          
------------                 
ARCHIVELOG
                                                                     

SQL> archive log list
資料庫日誌模式            存檔模式
自動存檔             啟用
存檔終點            USE_DB_RECOVERY_FILE_DEST
最早的聯機日誌序列     46
下一個存檔日誌序列   48
當前日誌序列           48

二 顯示歸檔日誌的位置。當執行介質恢復時需要使用歸檔日誌檔案,使用動態效能檢視v$archive_dest可以顯示歸檔日誌的位置。

SQL> select dest_name,destination ,status from v$archive_dest;

DEST_NAME            DESTINATION          STATUS                               
-------------------- -------------------- ---------                            
LOG_ARCHIVE_DEST_1   F:\app\yang\product\ VALID                                
                     11.1.0\db_1\RDBMS                                         
                                                                               
LOG_ARCHIVE_DEST_2                        INACTIVE      
LOG_ARCHIVE_DEST_3                        INACTIVE      
LOG_ARCHIVE_DEST_4                        INACTIVE      
LOG_ARCHIVE_DEST_5                        INACTIVE      
LOG_ARCHIVE_DEST_6                        INACTIVE      
LOG_ARCHIVE_DEST_7                        INACTIVE      
LOG_ARCHIVE_DEST_8                        INACTIVE      
LOG_ARCHIVE_DEST_9                        INACTIVE      

DEST_NAME            DESTINATION          STATUS        

-------------------- -------------------- ---------                            
LOG_ARCHIVE_DEST_10 USE_DB_RECOVERY_FILE _DEST
     VALID                                                 
已選擇10行。

三 更改歸檔日誌的歸檔終點。
SQL> alter system set
  2  log_archive_dest_1='location=f:\app\yang\archive1 ';

系統已更改。

SQL> alter system set
  2  log_archive_dest_2='location=f:\app\yang\archive2';

系統已更改。

再次檢視歸檔日誌的位置

SQL> select dest_name,destination ,status from v$archive_dest;

DEST_NAME            DESTINATION          STATUS                               
-------------------- -------------------- ---------                            
LOG_ARCHIVE_DEST_1   f:\app\yang\archive1 VALID                                
LOG_ARCHIVE_DEST_2   f:\app\yang\archive2 VALID
                                
LOG_ARCHIVE_DEST_3                        INACTIVE                             
LOG_ARCHIVE_DEST_4                        INACTIVE                             
LOG_ARCHIVE_DEST_5                        INACTIVE                             
LOG_ARCHIVE_DEST_6                        INACTIVE                             
LOG_ARCHIVE_DEST_7                        INACTIVE                             
LOG_ARCHIVE_DEST_8                        INACTIVE                             
LOG_ARCHIVE_DEST_9                        INACTIVE                             
LOG_ARCHIVE_DEST_10                       INACTIVE                             

已選擇10行。

使存檔地址LOG_ARCHIVE_DEST_1  不可用

SQL> alter system set log_archive_dest_state_1=defer;

系統已更改。

使存檔地址LOG_ARCHIVE_DEST_1  可用

SQL> alter system set log_archive_dest_state_1=enable;

系統已更改。

四  設定歸檔程式的數量。
SQL> alter system set log_archive_max_processes=5;

系統已更改。

設定本地歸檔的最小成功個數,

SQL> alter system set log_archive_min_succeed_dest=2;

系統已更改。執行了此語句後,如果在本地生成的歸檔日誌少於兩份,那麼重做日誌將不能被覆蓋。

SQL> archive log list
資料庫日誌模式            存檔模式
自動存檔             啟用
存檔終點            f:\app\yang\archive2
最早的聯機日誌序列     46
下一個存檔日誌序列   48
當前日誌序列           48
SL> select dest_name,destination ,status from v$archive_dest;DEST_NAME            DESTINATION          STATUS                               
-------------------- -------------------- ---------                            
LOG_ARCHIVE_DEST_1   f:\app\yang\archive1 VALID                                
LOG_ARCHIVE_DEST_2   f:\app\yang\archive2 VALID                                
LOG_ARCHIVE_DEST_3                        INACTIVE                             
LOG_ARCHIVE_DEST_4                        INACTIVE                             
LOG_ARCHIVE_DEST_5                        INACTIVE                             
LOG_ARCHIVE_DEST_6                        INACTIVE                             
LOG_ARCHIVE_DEST_7                        INACTIVE                             
LOG_ARCHIVE_DEST_8                        INACTIVE                             
LOG_ARCHIVE_DEST_9                        INACTIVE                             
LOG_ARCHIVE_DEST_10                       INACTIVE                             

已選擇10行。

 


SQL> select name ,sequence#,first_change# from v$archived_log;

NAME                                      SEQUENCE# FIRST_CHANGE#              
---------------------------------------- ---------- -------------              
F:\APP\YANG\PRODUCT\11.1.0\DB_1\RDBMS\AR         46       2130728              
C00046_0715961434.001                                                          
                                                                               
F:\APP\YANG\FLASH_RECOVERY_AREA\ORACL\AR         46       2130728              
CHIVELOG\2010_05_05\O1_MF_1_46_5Y1XKFQX_                                       
.ARC                                                                           
                                                                               
F:\APP\YANG\PRODUCT\11.1.0\DB_1\RDBMS\AR         47       2160100              
C00047_0715961434.001                                                          
                                                                               
F:\APP\YANG\FLASH_RECOVERY_AREA\ORACL\AR         47       2160100              

NAME                                      SEQUENCE# FIRST_CHANGE#              
---------------------------------------- ---------- -------------              
CHIVELOG\2010_05_06\O1_MF_1_47_5Y5MR2SW_                                       
.ARC                                                                           
                                                                               

SQL> select * from v$loghist;

   THREAD#  SEQUENCE# FIRST_CHANGE# FIRST_TIME     SWITCH_CHANGE#              
---------- ---------- ------------- -------------- --------------              
         1          1        886308 10-4月 -10             921479              
         1          2        921479 10-4月 -10             930110              
         1          3        930110 10-4月 -10             946970              
         1          4        946970 10-4月 -10             968547              
         1          5        968547 10-4月 -10             993761              
         1          6        993761 10-4月 -10            1017725              
         1          7       1017725 11-4月 -10            1062704              
         1          8       1062704 11-4月 -10            1082710              
         1          9       1082710 12-4月 -10            1104114              
         1         10       1104114 12-4月 -10            1134790              
         1         11       1134790 13-4月 -10            1172577              

   THREAD#  SEQUENCE# FIRST_CHANGE# FIRST_TIME     SWITCH_CHANGE#              
---------- ---------- ------------- -------------- --------------              
         1         12       1172577 14-4月 -10            1207219              
         1         13       1207219 15-4月 -10            1227501              
         1         14       1227501 16-4月 -10            1258361              
         1         15       1258361 16-4月 -10            1298465              
         1         16       1298465 17-4月 -10            1342110              
         1         17       1342110 18-4月 -10            1370677              
         1         18       1370677 18-4月 -10            1404213              
         1         19       1404213 19-4月 -10            1424947              
         1         20       1424947 19-4月 -10            1452037              
         1         21       1452037 21-4月 -10            1474004              
         1         22       1474004 22-4月 -10            1494843              

 七 顯示歸檔程式資訊。透過檢視 v$archive_processes可以檢視所有程式的資訊。   

SQL> select * from v$archive_processes;

   PROCESS STATUS     LOG_SEQUENCE STAT                                        
---------- ---------- ------------ ----                                        
         0 ACTIVE                0 IDLE                                        
         1 ACTIVE                0 IDLE                                        
         2 ACTIVE                0 IDLE                                        
         3 ACTIVE                0 IDLE                                        
         4 ACTIVE                0 IDLE                                        
         5 STOPPED               0 IDLE                                        
         6 STOPPED               0 IDLE                                        
         7 STOPPED               0 IDLE                                        
         8 STOPPED               0 IDLE                                        
         9 STOPPED               0 IDLE                                        
        10 STOPPED               0 IDLE                                        

   PROCESS STATUS     LOG_SEQUENCE STAT                                        
---------- ---------- ------------ ----                                        
        11 STOPPED               0 IDLE                                        
        12 STOPPED               0 IDLE                                        
        13 STOPPED               0 IDLE                                        
        14 STOPPED               0 IDLE                                        
        15 STOPPED               0 IDLE                                        
        16 STOPPED               0 IDLE                                        
        17 STOPPED               0 IDLE                                        
        18 STOPPED               0 IDLE                                        
        19 STOPPED               0 IDLE                                        
        20 STOPPED               0 IDLE                                        
        21 STOPPED               0 IDLE                                        

   PROCESS STATUS     LOG_SEQUENCE STAT                                        
---------- ---------- ------------ ----                                        
        22 STOPPED               0 IDLE                                        
        23 STOPPED               0 IDLE                                        
        24 STOPPED               0 IDLE                                        
        25 STOPPED               0 IDLE                                        
        26 STOPPED               0 IDLE                                        
        27 STOPPED               0 IDLE                                        
        28 STOPPED               0 IDLE                                        
        29 STOPPED               0 IDLE
                                        

已選擇30行。

八 手動切換日誌。
SQL> alter system switch logfile;

系統已更改。


 

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

相關文章