oracle 在线修改online redo logfiles size 大小

 
 在线修改online redo logfiles size 大小

oracle redolog size 过小有时候会导致性能问题,现在我们在线修改redolog,一般在业务量比较小的时候进行此操作

1. 首先查看当前的日志组大小,路径名           
               
[oracle@tora10 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Feb 23 17:08:33 2013

SQL> select group#, bytes, status from v$log; 

    GROUP#      BYTES STATUS
---------- ---------- ----------------
         1  524288000 INACTIVE
         2  524288000 CURRENT
         3  524288000 INACTIVE
         
    当前的日志组大小是 512MB 文件系统,每个组成员只有1个member                              
                                  
   SQL> select group#, member from v$logfile;                                    
                                                       
    GROUP# MEMBER
---------- ----------------------------------------
         1 /opt/oracle/oradata/test/redo01.log
         2 /opt/oracle/oradata/test/redo02.log
         3 /opt/oracle/oradata/test/redo03.log                                 
                                                               
                                                                
2. 现在创建新的redolog group 4, 5, and 6 每个log大小为1024MB                          
                            
   SQL> alter database add logfile group 4                              
           '/opt/oracle/oradata/test/redo04.log ' size 1024M;                                 
                                 
   SQL> alter database add logfile group 5                                  
           '/opt/oracle/oradata/test/redo05.log ' size 1024M;     
        
   SQL> alter database add logfile group 6          
           '/opt/oracle/oradata/test/redo06.log ' size 1024M;   
        

3. 创建完新的日志组后,查询所有日志组状态:                                   
                                                                         
   SQL> select group#, status from v$log;                                       

      GROUP# STATUS
   --------- ----------------
           1 INACTIVE
           2 CURRENT
           3 INACTIVE            
           4 UNUSED
           5 UNUSED
           6 UNUSED         
                       
   当前使用的是group 2 日志组,现在通过“多次”切日志换命令将group 1,2,3状态变为INACTIVE,
让oracle使用新建的group4,5,6,然后将小的日志组group 1,2,3删除            
                              
    
   SQL> alter system switch logfile;          
                                      
   SQL> alter system checkpoint;                                                      
                                                                                                                       
4.切换完成后,再次查询当前的日志组状态,当前使用的日志组是group 5
                                                               
   SQL> select group#, status from v$log;                                       
                                                                         
           
      GROUP# STATUS
     -------- ------
         1 INACTIVE
         2 INACTIVE
         3 INACTIVE
         4 INACTIVE
         5 CURRENT
         6 INACTIVE
    当redolog group 1,2,3状态为active时,意味着不能删除当前redo,直至用"alter system switch log file" ,"alter system checkpoint" 
命令将其切换为“inactive”状态才能将其删除
                       
                                                  
5.删除group 1,2,3日志组    

   SQL> alter database drop logfile group 1;  
        Database altered.                                  
   SQL> alter database drop logfile group 2;  
        Database altered.                                  
   SQL> alter database drop logfile group 3;  
        Database altered.                                  
                                   

   SQL> select group#, bytes, status from v$log;

      GROUP#     BYTES STATUS
   --------- --------- ----------------
           4  10485760 CURRENT
           5  10485760 UNUSED
           6  10485760 UNUSED            


   
6.  整个操作完成后,最好做一个backup

7.在操作系统层面删除原来的redolog
    
[oracle@tora10 ~]$ cd /opt/oracle/oradata/test/
[oracle@tora10 test]$ ll -al redo*
-rw-r----- 1 oracle oinstall  524288512 Feb 23 17:15 redo01.log
-rw-r----- 1 oracle oinstall  524288512 Feb 23 17:15 redo02.log
-rw-r----- 1 oracle oinstall  524288512 Feb 23 17:15 redo03.log
-rw-r----- 1 oracle oinstall 1073742336 Feb 23 17:16 redo04.log 
-rw-r----- 1 oracle oinstall 1073742336 Feb 23 17:16 redo05.log 
-rw-r----- 1 oracle oinstall 1073742336 Feb 23 17:17 redo06.log 

删除小的redolog

[oracle@tora10 test]$ rm -rf redo01.log 
[oracle@tora10 test]$ rm -rf redo02.log 
[oracle@tora10 test]$ rm -rf redo03.log                                            
                                                  

值得注意的是,加完新的redolog group 后,要监控下alert log 查看新的redolog的切换频率与原来情况相比较

你可能感兴趣的:(oracle 在线修改online redo logfiles size 大小)