線上修改REDO LOG的大小及增加新的日誌組
我管理的資料庫最近的alert日誌中有發現如下錯誤:
並且切換非常頻繁。檢視了REDO日誌組之後,發現這個資料庫原本是3組日誌,每組大小僅100M。在出現Checkpoint not complete時資料庫會短暫的hung,因此打算將原來的日誌調整為1024MB大小,並增加3組新的日誌。
相關的知識普及:
1、 Redo log File存放了Redo log資訊,最少有兩組日誌檔案,供Oracle迴圈使用。
2、 Redo log File每組最少一個,建議兩個,防止損壞而導致的資料丟失。
3、 每組中的檔案大小必須一致,因為他們是同時修改的,不同組的檔案大小可以不一致。
4、 每組中的檔案個數必須一致。
由於ORACLE並沒有提供類似RESIZE的引數來重新調整REDO LOG FILE的大小,因此只能先把這個檔案刪除了,然後再重建。又由於ORACLE要求最少有兩組日誌檔案在用,所以不能直接刪除,必須要建立中間過渡的REDO LOG日誌組。因此,如果只是修改REDO LOG FILE的大小,建議的操作步驟應該如下:
1) 先建立兩組新的日誌組5、6
2) SWITCH LOGFILE到新建立的日誌組5、6
3) 刪除舊的日誌組1、2、3
4) 重建舊的日誌組1、2、3
5) SWITCH LOGFILE到日誌組1、2、3
6) 刪除過渡的日誌組5、6
但本次操作,我既要修改原有日誌組的大小,又要增加新的日誌組,所以省去了中間過渡日誌組的操作,我的操作過程如下:
1) 檢視當前日誌組的狀態,GROUP編號,日誌檔案所在的位置。
> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ------------------------------------------------
1 2 100 CURRENT
2 2 100 INACTIVE
3 2 100 INACTIVE
> SELECT group#,member FROM v$logfile;
GROUP# MEMBER
---------- --------------------
3 /dev/rlv_ora_redo13
3 /dev/rlv_ora_redo14
2 /dev/rlv_ora_redo22
2 /dev/rlv_ora_redo21
1 /dev/rlv_ora_redo11
1 /dev/rlv_ora_redo12
6 rows selected.
2) 增加新的日誌組
2.1 檢視新增日誌組的裸裝置情況,大小,等基本資訊
nm_ora@/dev$ lsvg -l vg_ora_sys4
vg_ora_sys4:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
lv_ora_redo30 raw 18 18 3 closed/syncd N/A
lv_ora_redo31 raw 18 18 3 closed/syncd N/A
lv_ora_redo32 raw 18 18 3 closed/syncd N/A
lv_ora_redo33 raw 18 18 3 closed/syncd N/A
lv_ora_redo34 raw 18 18 3 closed/syncd N/A
lv_ora_redo35 raw 18 18 3 closed/syncd N/A
nm_ora@/dev$ lsvg vg_ora_sys4
VOLUME GROUP: vg_ora_sys4 VG IDENTIFIER: 00c52b5b00004c000000011e219c275f
VG STATE: active PP SIZE: 128 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 2397 (306816 megabytes)
MAX LVs: 256 FREE PPs: 2289 (292992 megabytes)
LVs: 6 USED PPs: 108 (13824 megabytes)
OPEN LVs: 0 QUORUM: 2 (Enabled)
TOTAL PVs: 3 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 3 AUTO ON: no
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 1024 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
由上,每一個LV的大小為18PPS,每一個PPS大小為128MB,因此大小為128*18=2304MB,滿足要求的1024大小的要求。
2.2 增加新的日誌組
> ALTER DATABASE ADD LOGFILE GROUP 4 ('/dev/rlv_ora_redo30','/dev/rlv_ora_redo31') SIZE 1024M;
Database altered.
> ALTER DATABASE ADD LOGFILE GROUP 5 ('/dev/rlv_ora_redo32','/dev/rlv_ora_redo33') SIZE 1024M;
Database altered.
> ALTER DATABASE ADD LOGFILE GROUP 6 ('/dev/rlv_ora_redo34','/dev/rlv_ora_redo35') SIZE 1024M;
Database altered.
2.3 檢視新增日誌組的狀態
> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ------------------------------------------------
1 2 100 CURRENT
2 2 100 INACTIVE
3 2 100 INACTIVE
4 2 1024 UNUSED
5 2 1024 UNUSED
6 2 1024 UNUSED
6 rows selected.
可以看到,新增的三組日誌GROUP4、5、6,狀態為UNUSED。
3) 切換當前的redo log
> ALTER SYSTEM SWITCH LOGFILE;
System altered.
4) 檢視切換後的狀態
> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ------------------------------------------------
1 2 100 ACTIVE
2 2 100 INACTIVE
3 2 100 INACTIVE
4 2 1024 CURRENT
5 2 1024 UNUSED
6 2 1024 UNUSED
6 rows selected.
可以看見,現在切換到新增的第4組日誌上使用。
5) 改變檢查點
> ALTER SYSTEM CHECKPOINT;
System altered.
6) 檢視切換後的狀態
> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ------------------------------------------------
1 2 100 INACTIVE
2 2 100 INACTIVE
3 2 100 INACTIVE
4 2 1024 CURRENT
5 2 1024 UNUSED
6 2 1024 UNUSED
6 rows selected.
可以看見,GROUP1、2、3三組日誌狀態變成了INACTIVE了,這時候可以刪除它們。
7) 刪除狀態為inactive的日誌
> ALTER DATABASE DROP LOGFILE GROUP 1;
Database altered.
> ALTER DATABASE DROP LOGFILE GROUP 2;
Database altered.
> ALTER DATABASE DROP LOGFILE GROUP 3;
Database altered.
8) 重建新的GROUP 1、2、3三組日誌
8.1 檢查舊的日誌組的LV大小是否符合要求
nm_ora@/dev$ lsvg -l vg_ora_sys
vg_ora_sys:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
lv_ora_sys raw 128 128 1 open/syncd N/A
lv_ora_redo11 raw 64 64 1 open/syncd N/A
lv_ora_redo12 raw 64 64 1 open/syncd N/A
lv_ora_redo13 raw 64 64 1 open/syncd N/A
lv_ora_redo14 raw 64 64 1 open/syncd N/A
lv_ora_redo15 raw 64 64 1 closed/syncd N/A
lv_ora_ctl1 raw 32 32 1 open/syncd N/A
lv_ora_ctl2 raw 32 32 1 open/syncd N/A
lv_ora_ctl3 raw 32 32 1 open/syncd N/A
lv_ora_spf raw 1 1 1 closed/syncd N/A
lv_ora_temp raw 640 640 1 open/syncd N/A
lv_ora_undo1 raw 640 640 1 open/syncd N/A
lv_ora_undo2 raw 640 640 1 open/syncd N/A
lv_ora_redo21 raw 8 8 1 open/syncd N/A
lv_ora_redo22 raw 8 8 1 open/syncd N/A
lv_ora_redo23 raw 8 8 1 closed/syncd N/A
nm_ora@/dev$ lsvg vg_ora_sys
VOLUME GROUP: vg_ora_sys VG IDENTIFIER: 00c528eb00004c000000010b0d653929
VG STATE: active PP SIZE: 16 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 6399 (102384 megabytes)
MAX LVs: 512 FREE PPs: 3910 (62560 megabytes)
LVs: 16 USED PPs: 2489 (39824 megabytes)
OPEN LVs: 13 QUORUM: 2 (Enabled)
TOTAL PVs: 1 VG DESCRIPTORS: 2
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 1 AUTO ON: no
MAX PPs per VG: 128016
MAX PPs per PV: 7112 MAX PVs: 18
LTG size (Dynamic): 1024 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
--其中lv_ora_redo11、lv_ora_redo12、lv_ora_redo13、lv_ora_redo14的大小為64*16=1024MB,正好滿足要求。而lv_ora_redo21、lv_ora_redo22大小隻有8*16=128MB,不滿足1024的要求,因此這兩個LV將被廢棄。
--啟用了/dev/rlv_ora_redo15和/dev/rlv2gaioxdat010來替換GROUP 2中原有的LV
8.2 重建
> ALTER DATABASE ADD LOGFILE GROUP 1 ('/dev/rlv_ora_redo11','/dev/rlv_ora_redo12') SIZE 1024M;
ALTER DATABASE ADD LOGFILE GROUP 1 ('/dev/rlv_ora_redo11','/dev/rlv_ora_redo12') SIZE 1024M
*
ERROR at line 1:
ORA-00301: error in adding log file '/dev/rlv_ora_redo11' - file cannot be created
ORA-27042: not enough space on raw partition to fullfill request
IBM AIX RISC System/6000 Error: 6: No such device or address
Additional information: 1
Additional information: 1
Additional information: -1
>
> ALTER DATABASE ADD LOGFILE GROUP 2 ('/dev/rlv_ora_redo15','/dev/rlv2gaioxdat010') SIZE 1024M;
ALTER DATABASE ADD LOGFILE GROUP 2 ('/dev/rlv_ora_redo15','/dev/rlv2gaioxdat010') SIZE 1024M
*
ERROR at line 1:
ORA-00301: error in adding log file '/dev/rlv_ora_redo15' - file cannot be created
ORA-27042: not enough space on raw partition to fullfill request
IBM AIX RISC System/6000 Error: 6: No such device or address
Additional information: 1
Additional information: 1
Additional information: -1
> ALTER DATABASE ADD LOGFILE GROUP 3 ('/dev/rlv_ora_redo13','/dev/rlv_ora_redo14') SIZE 1024M;
ALTER DATABASE ADD LOGFILE GROUP 3 ('/dev/rlv_ora_redo13','/dev/rlv_ora_redo14') SIZE 1024M
*
ERROR at line 1:
ORA-00301: error in adding log file '/dev/rlv_ora_redo13' - file cannot be created
ORA-27042: not enough space on raw partition to fullfill request
IBM AIX RISC System/6000 Error: 6: No such device or address
Additional information: 1
Additional information: 1
Additional information: -1
0.0 重建的時候出現了錯誤,根據錯誤資訊no enough space,猜測可能是由於LV大小剛好1024M,導致沒有空間寫檔案頭,於是我嘗試將他們縮小到1000MB。
> ALTER DATABASE ADD LOGFILE GROUP 1 ('/dev/rlv_ora_redo11','/dev/rlv_ora_redo12') SIZE 1000M;
Database altered.
> ALTER DATABASE ADD LOGFILE GROUP 2 ('/dev/rlv_ora_redo15','/dev/rlv2gaioxdat010') SIZE 1000M;
Database altered.
> ALTER DATABASE ADD LOGFILE GROUP 3 ('/dev/rlv_ora_redo13','/dev/rlv_ora_redo14') SIZE 1000M;
Database altered.
這時候建立成功了!
9) 切換測試
> ALTER SYSTEM SWITCH LOGFILE;
System altered.
10) 檢查切換後的狀態
> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ------------------------------------------------
1 2 1000 CURRENT
2 2 1000 UNUSED
3 2 1000 UNUSED
4 2 1024 ACTIVE
5 2 1024 UNUSED
6 2 1024 UNUSED
6 rows selected.
11) 多切換幾次,讓他每組日誌都使用一遍。
> ALTER SYSTEM SWITCH LOGFILE;
System altered.
> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ------------------------------------------------
1 2 1000 ACTIVE
2 2 1000 CURRENT
3 2 1000 UNUSED
4 2 1024 ACTIVE
5 2 1024 UNUSED
6 2 1024 UNUSED
6 rows selected.
> ALTER SYSTEM SWITCH LOGFILE;
System altered.
> ALTER SYSTEM SWITCH LOGFILE;
System altered.
> ALTER SYSTEM SWITCH LOGFILE;
System altered.
> ALTER SYSTEM SWITCH LOGFILE;
System altered.
> ALTER SYSTEM SWITCH LOGFILE;
System altered.
> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ------------------------------------------------
1 2 1000 CURRENT
2 2 1000 INACTIVE
3 2 1000 INACTIVE
4 2 1024 INACTIVE
5 2 1024 INACTIVE
6 2 1024 INACTIVE
6 rows selected.
日誌切換沒有發生錯誤,每組日誌都能正常使用和切換。順利結束!
整個過程用了12分鐘。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25462274/viewspace-2122816/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 5.6修改REDO日誌的大小和個數MySql
- MySQL重做日誌(redo log)MySql
- 【Mysql】三大日誌 redo log、bin log、undo logMySql
- MySQL 日誌系統 redo log、binlogMySql
- Oracle11g redo log 建立、新增、刪除(重做日誌組,重做日誌檔案)Oracle
- mysql日誌:redo log、binlog、undo log 區別與作用MySql
- 日誌追蹤:log增加traceId
- 必須瞭解的mysql三大日誌-binlog、redo log和undo logMySql
- oracle丟失的是所有的redo日誌組Oracle
- 檢視oracle的redo日誌組切換頻率Oracle
- 【TUNE_ORACLE】Oracle檢查點(四)檢查點對redo日誌的影響和redo日誌大小設定建議Oracle
- 12C關於CDB、PDB 日誌檔案redo log的總結
- MySQL更新資料時,日誌(redo log、binlog)執行流程MySql
- MySQL如何計算統計redo log大小MySql
- 【REDO】Oracle 日誌挖掘,分析歸檔日誌線上日誌主要步驟Oracle
- MySQL 修改InnoDB重做日誌檔案的數量或大小MySql
- MySQL的Redo log 以及Bin logMySql
- Log日誌
- 4.2.1.6 選擇資料庫並設定 Redo Log 塊的大小資料庫
- MySQL中的redo log和undo logMySql
- Yii2 log 模組,訊息日誌
- Postgres使用pg_resetwal命令修改wal日誌檔案大小的方法
- Python 日誌(Log)Python
- log 日誌原理
- django開發-log日誌的配置Django
- MySQL redo與undo日誌解析MySql
- MySQL之事務和redo日誌MySql
- undo log和redo log
- 檢視Oracle的redo日誌切換頻率Oracle
- MySQL中的redo log和checkpointMySql
- Linux C日誌logLinux
- Log 工具列印日誌
- 開啟PHP的錯誤log日誌PHP
- Android的log日誌知識點剖析Android
- 調整innodb redo log files數目和大小的具體方法和步驟
- Oracle redo日誌內容探索(一)Oracle Redo
- 限制 Apache日誌檔案大小的方法Apache
- iOS輕量分組日誌工具 Log4OCiOS
- 日誌-log4j2基於AsyncLogger的非同步日誌列印非同步