1. 程式人生 > >【ORACLE】oracle 日誌檔案管理

【ORACLE】oracle 日誌檔案管理

修改Oracle重做日誌檔案大小

 

建立新的日誌組1

刪除舊的日誌組0(舊的日誌組狀態需要是INACTIVE)

建立新的日誌組2,組名為舊的日誌組0的組名

刪除日誌組1

  

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

具體操作步驟:

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

 

1. 建立3個新的日誌組

ALTER DATABASE ADD LOGFILE GROUP 4 ('/u01/app/oracle/oradata/orcl/redo06.log') SIZE 500M;

ALTER DATABASE ADD LOGFILE GROUP 5 ('/u01/app/oracle/oradata/orcl/redo05.log') SIZE 500M;

ALTER DATABASE ADD LOGFILE GROUP 6 ('/u01/app/oracle/oradata/orcl/redo06.log') SIZE 500M; 

  

檢視日誌組

select * from v$logfile;

  

2.切換當前日誌到新的日誌組

alter system switch logfile;

alter system switch logfile;

alter system switch logfile; 

  

切到要刪除為INCACTIVE才行 

select group#,sequence#,bytes,members,status from v$log;

  

GROUP#  SEQUENCE#    BYTES    MEMBERS STATUS


---------- ---------- ---------- ---------- ----------------
  1  139 52428800  1 INACTIVE
  2  137 52428800  1 INACTIVE
  3  138 52428800  1 INACTIVE
  4  140  524288000  1 ACTIVE
  5  141  524288000  1 CURRENT
  6  136  524288000  1 INACTIVE

 

3. 刪除舊的日誌組

alter database drop logfile group 1;

  

Database altered.

 

4. 檢視是否刪除了日誌組

select group#,sequence#,bytes,members,status from v$log;

  

GROUP#  SEQUENCE#    BYTES    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
  4  140  524288000  1 INACTIVE
  5  141  524288000  1 CURRENT
  6  136  524288000  1 INACTIVE

 

5. 作業系統刪除原日誌組1、2、3中的檔案 

[[email protected] log]$ cd /u01/app/oracle/oradata/orcl
[[email protected] orcl]$ pwd
/u01/app/oracle/oradata/orcl
[[email protected] orcl]$ ls
control01.ctl  example01.dbf  redo01.log  redo02.log  redo03.log  redo04.log  redo05.log  redo06.log  sysaux01.dbf  system01.dbf  temp01.dbf  undotbs01.dbf  users01.dbf
[[email protected] orcl]$ rm -rf redo01.log 
[[email protected] orcl]$ rm -rf redo02.log 
[[email protected] orcl]$ rm -rf redo03.log 

  

 

6. 重建日誌組 1、2、3

ALTER DATABASE ADD LOGFILE GROUP 1 ('/u01/app/oracle/oradata/orcl/redo01.log') SIZE 500M;

ALTER DATABASE ADD LOGFILE GROUP 2 ('/u01/app/oracle/oradata/orcl/redo02.log') SIZE 500M;

ALTER DATABASE ADD LOGFILE GROUP 3 ('/u01/app/oracle/oradata/orcl/redo03.log') SIZE 500M; 

  

7.  刪除中間過渡用的日誌組4、5、6 ,在刪除時查詢select group#,sequence#,bytes,members,status from v$log; 刪除組是否為INACTIVE,如果不是INACTIVE 就要執行alter system switch logfile;

查詢看一下

select group#,sequence#,bytes,members,status from v$log;

  

GROUP#  SEQUENCE#    BYTES    MEMBERS STATUS

---------- ---------- ---------- ---------- ----------------
  1  148  524288000  1 CURRENT
  2  143  524288000  1 INACTIVE
  3  144  524288000  1 INACTIVE
  4  146  524288000  1 INACTIVE
  5  147  524288000  1 INACTIVE
  6  145  524288000  1 INACTIVE 

 

SQL> alter database drop logfile group 4;

Database altered.

SQL> alter database drop logfile group 5;

Database altered.

SQL> alter database drop logfile group 6;

Database altered.

  

8. 到作業系統刪除組4、5、6

[[email protected] orcl]$ rm -rf redo04.log 
[[email protected] orcl]$ rm -rf redo05.log 
[[email protected] orcl]$ rm -rf redo06.log 

  

9. 備份當前最新的控制檔案

alter database backup controlfile to trace resetlogs  ;