關閉時:
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
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;
關閉
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;
cd /opt/oracle/arclog for ((n=24;n<=43;n++));do mv win_23${n}_1_827060640.arc bak_tmp/; done sqlplus / as sysdba // validate all archvelogs in your disk. If some are missing, it will treat it as expired. RMAN> crosscheck archivelog all; // it ill delete expired archivelog and updates your controlfile. RMAN> delete expired archivelog all;
rman target / nocatalog RMAN > backup archivelog all delete input format '/opt/oracle/oradata/orabak/win/backup_arc'; RMAN > delete archivelog all;