Oracle11g調整redo日誌大小、組數和每組成員數

煙花丶易冷發表於2017-07-26

調整redo日誌大小和組數


  1. [oracle@scdb1 ~]$ export ORACLE_SID=cams
  2. [oracle@scdb1 ~]$ sqlplus / as sysdba

  3. SQL*Plus: Release 11.2.0.4.0 Production on Thu Jul 13 12:35:42 2017

  4. Copyright (c) 1982, 2013, Oracle. All rights reserved.


  5. Connected to:
  6. Oracle Database 11g Release 11.2.0.4.0 - 64bit Production

  7. SQL> alter database add logfile group 4 '/data/cams/redo04.log' size 1g;

  8. Database altered.

  9. SQL> alter database add logfile group 5'/data/cams/redo05.log' size 1g;

  10. Database altered.

  11. SQL> alter database add logfile group 6'/data/cams/redo06.log' size 1g;

  12. Database altered.

  13. SQL> set linesize 300;
  14. SQL> col member for a30;
  15. SQL> select * from v$logfile;

  16.     GROUP# STATUS TYPE MEMBER             IS_
  17. ---------- ------- ------- ------------------------------ ---
  18.      3     ONLINE /data/cams/redo03.log     NO
  19.      2     ONLINE /data/cams/redo02.log     NO
  20.      1     ONLINE /data/cams/redo01.log     NO
  21.      4     ONLINE /data/cams/redo04.log     NO
  22.      5     ONLINE /data/cams/redo05.log     NO
  23.      6     ONLINE /data/cams/redo06.log     NO

  24. 6 rows selected.
  25. SQL> select GROUP#,BYTES,MEMBERS,STATUS from v$log;

  26.     GROUP#    BYTES     MEMBERS STATUS
  27. ---------- ---------- ---------- ----------------
  28.      1 52428800     1 INACTIVE
  29.      2 52428800     1 INACTIVE
  30.      3 52428800     1 CURRENT
  31.      4 1073741824     1 UNUSED
  32.      5 1073741824     1 UNUSED
  33.      6 1073741824     1 UNUSED

  34. 6 rows selected.

  35. SQL> alter system switch logfile;

  36. System altered.

  37. SQL> select GROUP#,BYTES,MEMBERS,STATUS from v$log;

  38.     GROUP#    BYTES     MEMBERS STATUS
  39. ---------- ---------- ---------- ----------------
  40.      1 52428800     1 INACTIVE
  41.      2 52428800     1 INACTIVE
  42.      3 52428800     1 ACTIVE
  43.      4 1073741824     1 CURRENT
  44.      5 1073741824     1 UNUSED
  45.      6 1073741824     1 UNUSED

  46. 6 rows selected.

  47. SQL> alter system checkpoint;

  48. System altered.

  49. SQL> select GROUP#,BYTES,MEMBERS,STATUS from v$log;

  50.     GROUP#    BYTES     MEMBERS STATUS
  51. ---------- ---------- ---------- ----------------
  52.      1 52428800     1 INACTIVE
  53.      2 52428800     1 INACTIVE
  54.      3 52428800     1 INACTIVE
  55.      4 1073741824     1 CURRENT
  56.      5 1073741824     1 UNUSED
  57.      6 1073741824     1 UNUSED

  58. 6 rows selected.

  59. SQL> alter database drop logfile GROUP 1;

  60. Database altered.

  61. SQL> alter database drop logfile GROUP 2;

  62. Database altered.

  63. SQL> alter database drop logfile GROUP 3;

  64. Database altered.

  65. SQL> select GROUP#,BYTES,MEMBERS,STATUS from v$log;

  66.     GROUP#    BYTES     MEMBERS STATUS
  67. ---------- ---------- ---------- ----------------
  68.      4 1073741824     1 CURRENT
  69.      5 1073741824     1 UNUSED
  70.      6 1073741824     1 UNUSED

  71. SQL> !mv /data/cams/redo01.log /data/cams/redo01.log_bak20160811

  72. SQL> !mv /data/cams/redo02.log /data/cams/redo02.log_bak20160811

  73. SQL> !mv /data/cams/redo03.log /data/cams/redo03.log_bak20160811

  74. SQL> alter database add logfile GROUP 1 ('/data/cams/redo01.log') size 1g;

  75. Database altered.

  76. SQL> alter database add logfile GROUP 2 ('/data/cams/redo02.log') size 1g;

  77. Database altered.

  78. SQL> alter database add logfile GROUP 3 ('/data/cams/redo03.log') size 1g;

  79. Database altered.

  80. SQL> select GROUP#,BYTES,MEMBERS,STATUS from v$log;

  81.     GROUP#    BYTES     MEMBERS STATUS
  82. ---------- ---------- ---------- ----------------
  83.      1 1073741824     1 UNUSED
  84.      2 1073741824     1 UNUSED
  85.      3 1073741824     1 UNUSED
  86.      4 1073741824     1 CURRENT
  87.      5 1073741824     1 UNUSED
  88.      6 1073741824     1 UNUSED

  89. 6 rows selected.
  90. SQL> alter system switch logfile;

  91. System altered.

  92. SQL> alter system switch logfile;

  93. System altered.

  94. SQL> alter system switch logfile;

  95. System altered.

  96. SQL> alter system switch logfile;

  97. System altered.

  98. SQL> alter system switch logfile;

  99. System altered.

  100. SQL> select GROUP#,BYTES,MEMBERS,STATUS from v$log;

  101.     GROUP#    BYTES     MEMBERS STATUS
  102. ---------- ---------- ---------- ----------------
  103.      1 1073741824     1 ACTIVE
  104.      2 1073741824     1 ACTIVE
  105.      3 1073741824     1 ACTIVE
  106.      4 1073741824     1 ACTIVE
  107.      5 1073741824     1 ACTIVE
  108.      6 1073741824     1 CURRENT

  109. 6 rows selected.

  110. SQL> alter system switch logfile;

  111. System altered.

  112. SQL> select GROUP#,BYTES,MEMBERS,STATUS from v$log;

  113.     GROUP#    BYTES     MEMBERS STATUS
  114. ---------- ---------- ---------- ----------------
  115.      1 1073741824     1 INACTIVE
  116.      2 1073741824     1 INACTIVE
  117.      3 1073741824     1 INACTIVE
  118.      4 1073741824     1 CURRENT
  119.      5 1073741824     1 INACTIVE
  120.      6 1073741824     1 INACTIVE

  121. SQL> exit
  122. Disconnected from Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
完成調整redo日誌大小、組數的操作,並將redo日誌從預設的3組,每個日誌大小為50M調整為6組,每個redo日誌大小為1g。

增加redo日誌組成員數


  1. SQL> col member for a30;
  2. SQL> /

  3.     GROUP# STATUS TYPE MEMBER             IS_
  4. ---------- ------- ------- ------------------------------ ---
  5.      1     ONLINE /data/cams/redo01.log     NO
  6.      2     ONLINE /data/cams/redo02.log     NO
  7.      3     ONLINE /data/cams/redo03.log     NO
  8.      4     ONLINE /data/cams/redo04.log     NO
  9.      5     ONLINE /data/cams/redo05.log     NO
  10.      6     ONLINE /data/cams/redo06.log     NO
  11. 修改儲存許可權
  12. chown -R oracle:oinstall /file
  13. chown -R oracle:oinstall /backup

  14. 新增組成員
  15. SQL> !mkdir -p /file/cams/redo
  16. SQL> !mkdir -p /backup/cams/redo
  17. SQL> alter database add logfile member '/file/cams/redo/redo01.log' to group 1;
  18. SQL> alter database add logfile member '/backup/cams/redo/redo01.log' to group 1;
  19. SQL> alter database add logfile member '/file/cams/redo/redo02.log' to group 2;
  20. SQL> alter database add logfile member '/backup/cams/redo/redo02.log' to group 2;
  21. SQL> alter database add logfile member '/file/cams/redo/redo03.log' to group 3;
  22. SQL> alter database add logfile member '/backup/cams/redo/redo03.log' to group 3;
  23. SQL> alter database add logfile member '/file/cams/redo/redo04.log' to group 4;
  24. SQL> alter database add logfile member '/backup/cams/redo/redo04.log' to group 4;
  25. SQL> alter database add logfile member '/file/cams/redo/redo05.log' to group 5;
  26. SQL> alter database add logfile member '/backup/cams/redo/redo05.log' to group 5;
  27. SQL> alter database add logfile member '/file/cams/redo/redo06.log' to group 6;
  28. SQL> alter database add logfile member '/backup/cams/redo/redo06.log' to group 6;

  29. SQL> select * from v$logfile;

  30.     GROUP# STATUS TYPE MEMBER             IS_
  31. ---------- ------- ------- ------------------------------ ---
  32.      1     ONLINE /data/cams/redo01.log     NO
  33.      2     ONLINE /data/cams/redo02.log     NO
  34.      3     ONLINE /data/cams/redo03.log     NO
  35.      4     ONLINE /data/cams/redo04.log     NO
  36.      5     ONLINE /data/cams/redo05.log     NO
  37.      6     ONLINE /data/cams/redo06.log     NO
  38.      1 INVALID ONLINE /file/cams/redo/redo01.log     NO
  39.      1 INVALID ONLINE /backup/cams/redo/redo01.log NO
  40.      2 INVALID ONLINE /file/cams/redo/redo02.log     NO
  41.      2 INVALID ONLINE /backup/cams/redo/redo02.log NO
  42.      3 INVALID ONLINE /file/cams/redo/redo03.log     NO

  43.     GROUP# STATUS TYPE MEMBER             IS_
  44. ---------- ------- ------- ------------------------------ ---
  45.      3 INVALID ONLINE /backup/cams/redo/redo03.log NO
  46.      4 INVALID ONLINE /file/cams/redo/redo04.log     NO
  47.      4 INVALID ONLINE /backup/cams/redo/redo04.log NO
  48.      5 INVALID ONLINE /file/cams/redo/redo05.log     NO
  49.      5 INVALID ONLINE /backup/cams/redo/redo05.log NO
  50.      6 INVALID ONLINE /file/cams/redo/redo06.log     NO
  51.      6 INVALID ONLINE /backup/cams/redo/redo06.log NO

  52. 18 rows selected.
  53. 剛加入到redolog group的日誌檔案在被使用之前也是INVALID狀態
  54. SQL> alter system switch logfile;

  55. System altered.

  56. SQL> select * from v$logfile;

  57.     GROUP# STATUS TYPE MEMBER             IS_
  58. ---------- ------- ------- ------------------------------ ---
  59.      1     ONLINE /data/cams/redo01.log     NO
  60.      2     ONLINE /data/cams/redo02.log     NO
  61.      3     ONLINE /data/cams/redo03.log     NO
  62.      4     ONLINE /data/cams/redo04.log     NO
  63.      5     ONLINE /data/cams/redo05.log     NO
  64.      6     ONLINE /data/cams/redo06.log     NO
  65.      1 INVALID ONLINE /file/cams/redo/redo01.log     NO
  66.      1 INVALID ONLINE /backup/cams/redo/redo01.log NO
  67.      2 INVALID ONLINE /file/cams/redo/redo02.log     NO
  68.      2 INVALID ONLINE /backup/cams/redo/redo02.log NO
  69.      3     ONLINE /file/cams/redo/redo03.log     NO

  70.     GROUP# STATUS TYPE MEMBER             IS_
  71. ---------- ------- ------- ------------------------------ ---
  72.      3     ONLINE /backup/cams/redo/redo03.log NO
  73.      4 INVALID ONLINE /file/cams/redo/redo04.log     NO
  74.      4 INVALID ONLINE /backup/cams/redo/redo04.log NO
  75.      5 INVALID ONLINE /file/cams/redo/redo05.log     NO
  76.      5 INVALID ONLINE /backup/cams/redo/redo05.log NO
  77.      6 INVALID ONLINE /file/cams/redo/redo06.log     NO
  78.      6 INVALID ONLINE /backup/cams/redo/redo06.log NO

  79. 18 rows selected.
完成redo日誌每組成員數調整,由預設的每組一個成員調整為每組3個成員
如果覺得每組成員太多,可能會影響效率,可以刪除一組冗餘,提高效率:

  1. SQL> alter database drop logfile member '/backup/cams/redo/redo01.log';
  2. SQL> alter database drop logfile member '/backup/cams/redo/redo02.log';
  3. SQL> alter database drop logfile member '/backup/cams/redo/redo03.log';
  4. SQL> alter database drop logfile member '/backup/cams/redo/redo04.log';
  5. SQL> alter database drop logfile member '/backup/cams/redo/redo05.log';
  6. SQL> alter database drop logfile member '/backup/cams/redo/redo06.log';
執行刪除之後,調整為每組2個成員。

這裡建議將redo日誌的其他成員存放在不同的磁碟中,以避免磁碟故障造成資料損失。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29618264/viewspace-2142612/,如需轉載,請註明出處,否則將追究法律責任。

相關文章