Oracle歸檔日誌總結

來源:互聯網
上載者:User

Oracle歸檔日誌總結

1.開啟歸檔日誌

sqlplus / as  sysdba
sql> shutdown immediate;   
sql> startup mount;    #開啟控制檔案,不開啟資料檔案 
sql> alter database archivelog; #將資料庫切換為歸檔模式 
sql> alter database open;  #將資料檔案開啟 
sql> archive log list;  #查看此時是否處于歸檔模式

查看記錄模式

SQL> select log_mode from v$database; 

查看歸檔是否啟動

SQL> select archiver from v$instance;

2.禁用歸檔日誌

sql> archive log list;  #查看是否是歸檔方式 
sql> alter system set log_archive_start=false scope=spfile;   
sql> shutdown immediate;   
sql> startup mount;    #開啟控制檔案,不開啟資料檔案 
sql> alter database noarchivelog; #將資料庫切換為非歸檔模式 
sql> alter database open;  #將資料檔案開啟 
sql> archive log list;  #查看此時便處於非歸檔模式

3.查看是不是歸檔方式及歸檔的路徑

sql> archive log list;  #查看是不是歸檔方式 

Database log mode              Archive Mode

Automatic archival            Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence    98

Next log sequence to archive  100

Current log sequence          100

根據上面的USE_DB_RECOVERY_FILE_DEST,來尋找DB_RECOVERY_FILE_DEST

sys@ora10g> show parameter DB_RECOVERY_FILE_DEST

NAME                  TYPE        VALUE

--------------------- ----------- --------------------------------------

db_recovery_file_dest string      /Oracle/app/oracle/flash_recovery_area

 

4.修改歸檔日誌的路徑

sql> archive log list;  #查看是不是歸檔方式 
sql> alter system set log_archive_start=true scope=spfile; #啟用主動歸檔 
sql> alter system set log_archive_dest=''location=/oracle/ora9/oradata/arch'' scope=spfile;#設定歸檔路徑 
sql> alter system set log_archive_dest_1=''location=/oracle/ora9/oradata/arch1'' scope=spfile; 
sql> alter system set log_archive_dest_2=''location=/oracle/ora9/oradata/arch2'' scope=spfile; 
#如果歸檔到兩個位置,則可以通過上邊方法實現 
sql> alter system set log_archive_format=''arch_%d_%t_%r_%s.log''  #設定歸檔日記款式 
 
日誌切換 
sql> alter system switch logfile; 
這次日誌切換將歸檔寫到兩個目標地, 
即上邊的/oracle/ora9/oradata/arch1和/oracle/ora9/oradata/arch1,

 

5.查看現在歸檔日誌的大小

select sum(a.BLOCK_SIZE*a.BLOCKS)/1024/1024 from v$archived_log a where a.DELETED='NO';

6.查看歸檔日誌最大大小

show parameter db_recovery_file_dest_size;

7.設定歸檔日誌最大值,處理歸檔日誌滿,無法啟動

startup nomount;
alter system set db_recovery_file_dest_size = 4G;
alter database mount;
alter database on;

8.查看歸檔日誌的使用率

select PERCENT_SPACE_USED from V$FLASH_RECOVERY_AREA_USAGE where file_type LIKE 'ARCHIVED LOG';

9.擷取閃回區的使用率

select sum(PERCENT_SPACE_USED )  from V$RECOVERY_AREA_USAGE;

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.