Archive Log Mode

    版本為 00:13, 27 Dec 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    檢查 Archive Log Mode 狀態

    關閉時:

    SQL> archive log list
    Database log mode              No Archive Mode
    Automatic archival             Disabled
    Archive destination            USE_DB_RECOVERY_FILE_DEST
    Oldest online log sequence     2178
    Current log sequence           2180
    
    SQL> select log_mode, open_mode, name from v$database;
    
    LOG_MODE     OPEN_MODE  NAME
    ------------ ---------- ---------
    NOARCHIVELOG READ WRITE WIN 
    

    開啟時:

    SQL> archive log list
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            /opt/oracle/arclog
    Oldest online log sequence     2178
    Next log sequence to archive   2180
    Current log sequence           2180
    

    第一次啟用 Archive Log

    NOTE: 要啟用 Archive Log 時,必須重啟一次 DB,為了縮短 downtime,可以在停機前先設定參數 log_archive_dest_1。

    設定 Archive Log 的儲存路徑

    sqlplus / as sysdba
    
    SQL> show parameters recovery_file_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_recovery_file_dest                string      /opt/oracle/flash_recovery_area
    db_recovery_file_dest_size           big integer 2G 
    
    SQL> alter system set log_archive_dest_1='LOCATION=/opt/oracle/arclog' scope=spfile;
    SQL> alter system set log_archive_format='mydb_%s_%t_%r.arc' scope=spfile;
    SQL> show parameters log_archive; 
    SQL> shutdown immediate
    
    SQL> startup mount
    SQL> show parameters log_archive
    SQL> alter database archivelog;
    SQL> alter databse open;
    SQL> archive log list 
    
    SQL> shutdown immediate
    SQL> startup 
    

    驗證

    SQL> alter system switch logfile;
    
    或
    
    SQL> alter system archive log current; 
    

    關閉 Archive Log

    關閉

    SQL> shutdown immediate
    SQL> startup mount
    SQL> alter database noarchivelog;
    SQL> alter database open; 
    

    開啟

    SQL> shutdown immediate
    SQL> startup mount
    SQL> alter database archivelog;
    SQL> alter database open; 
    Powered by MindTouch Core