2013年12月5日木曜日

続・HugePages_1


今日は、JPOUG Advent Calendar 2013の5日目のエントリです。
1nmくらい役に立つプレゼントになればと思ってエントリします。


以前書いたHugepagesに関するエントリが検索すると上位に来るようで、
その地位を盤石なものにするべく、今回追加でHugepagesネタを書こうと思います。


前回のエントリ日付は2011年11月10日で以下の環境でした。
前回から二年。皆さんが導入するOracleバージョンも変わってきていると思うので、
今回はそのバージョンの違いについて調べてみます。


============
前回の環境
CPU: Intel(R) Xeon(R) CPU E5630 @ 2.53GHz×4
メモリ:24GB
OS:Red Hat Enterprise Linux Server release 5.4 (Tikanga)
カーネル:2.6.18-164.el5 x86_64
Oracle:11.2.0.2.0
============

今回の検証環境は以下となります。
カーネルとDBのバージョンが異なります。
============
今回の環境
CPU: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz×2
メモリ:10GB
Oracle Linux Server release 6.4 x86_64
カーネル:2.6.39-400.17.1.el6uek.x86_64 #1
Oracle:11.2.0.4.0
SGA_TARGET:5GB
============

一言で言うと、Oracle Release 11.2.0.3.0から、
alert.logへの出力メッセージと初期化パラメータ「USE_LARGE_PAGES」の
設定値の動作と種類が少なからず変更になりました。

1.デフォルト値である「TRUE」の動作変更

動作の変更として、デフォルト値である「TRUE」の動きが変更になっています。
Oracle Database 11gリリース2 (11.2.0.2)では、
Hugepageに関する設定に失敗するとHugepage用領域が一切使用されず、
残りの物理メモリからSGAが割り当てられます。
これにより意図しない物理メモリ不足が発生し、エラーの発生やSWAPによる
パフォーマンス低下が発生する場合があります。

Oracle Database 11gリリース2 (11.2.0.3)では、
Oracleによって可能なかぎり多くのSGAがHugepage用領域に割り当てられ、
不足した場合は不足分を物理メモリの残りである通常サイズのページを使用して
割り当てられます。


★11.2.0.2のalert.log出力メッセージ★

■Hugpagesの設定がされていない場合
特にメッセージなし

■正常に取得できた場合
(vm.nr_hugepages=2561,memlock=5244928)

Starting ORACLE instance (normal)
****************** Huge Pages Information *****************
Huge Pages memory pool detected (total: 2561 free: 2561)
DFLT Huge Pages allocation successful (allocated: 2561)
***********************************************************

■SGAに対してHugpages用領域が不足している場合
(vm.nr_hugepages=2560,memlock=5244928)

****************** Huge Pages Information *****************
Huge Pages memory pool detected (total: 2560 free: 2560)
Huge Pages allocation failed (free: 2560 required: 2561)
Allocation will continue with default/smaller page size
**********************************************************

■Hugpages用領域に対してmemlockの設定が小さい場合
(vm.nr_hugepages=2561,memlock=5242880)

Starting ORACLE instance (normal)
****************** Huge Pages Information *****************
Huge Pages memory pool detected (total: 2561 free: 2561)
Memlock limit too small: 5368709120 to accommodate segment size: 5370806272
Huge Pages allocation failed (free: 2561 required: 2561)
Allocation will continue with default/smaller page size
**********************************************************


★11.2.0.3以降のalert.log出力メッセージ★

■Hugpagesの設定がされていない場合
(vm.nr_hugepages= ,memlock=5244928)

Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Per process system memlock (soft) limit = 5120 MB

Total Shared Global Region in Large Pages = 0 KB (0%)

Large Pages used by this instance: 0 (0 KB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 0 (0 KB)
Large Page size = 2048 KB

RECOMMENDATION:
  Total System Global Area size is 5122 MB. For optimal performance,
  prior to the next instance restart:
  1. Increase the number of unused large pages by
 at least 2561 (page size 2048 KB, total size 5122 MB) system wide to
  get 100% of the System Global Area allocated with large pages
  2. Large pages are automatically locked into physical memory.
 Increase the per process memlock (soft) limit to at least 5130 MB to lock
 100% System Global Area's large pages into physical memory
********************************************************************

■正常に取得できた場合
(vm.nr_hugepages=2561,memlock=5244928)

Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Per process system memlock (soft) limit = 5122 MB

Total Shared Global Region in Large Pages = 5122 MB (100%)

Large Pages used by this instance: 2561 (5122 MB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 2561 (5122 MB)
Large Page size = 2048 KB
********************************************************************

■SGAに対してHugpages用領域が不足している場合
(vm.nr_hugepages=2560,memlock=5244928)

Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Per process system memlock (soft) limit = 5122 MB

Total Shared Global Region in Large Pages = 5120 MB (99%)

Large Pages used by this instance: 2560 (5120 MB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 2560 (5120 MB)
Large Page size = 2048 KB

RECOMMENDATION:
  Total System Global Area size is 5122 MB. For optimal performance,
  prior to the next instance restart:
  1. Increase the number of unused large pages by
 at least 1 (page size 2048 KB, total size 2048 KB) system wide to
  get 100% of the System Global Area allocated with large pages
  2. Large pages are automatically locked into physical memory.
 Increase the per process memlock (soft) limit to at least 5130 MB to lock
 100% System Global Area's large pages into physical memory
********************************************************************


■Hugpages用領域に対してmemlockの設定が小さい場合
(vm.nr_hugepages=2561,memloc=5242880)

Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Per process system memlock (soft) limit = 5120 MB

Total Shared Global Region in Large Pages = 5120 MB (99%)

Large Pages used by this instance: 2560 (5120 MB)
Large Pages unused system wide = 1 (2048 KB)
Large Pages configured system wide = 2561 (5122 MB)
Large Page size = 2048 KB

RECOMMENDATION:
  Total System Global Area size is 5122 MB. For optimal performance,
  prior to the next instance restart:
  1. Large pages are automatically locked into physical memory.
 Increase the per process memlock (soft) limit to at least 5130 MB to lock
 100% System Global Area's large pages into physical memory
********************************************************************


2.設定値「AUTO」動作変更(有効)
種類の変更としては「AUTO」の場合の動きが変更(有効)になっています。
AUTOが設定されている場合、Hugepages用領域にSGAが取得できる場合には
同領域を使用します。
SGAに対してHugepages用領域が不足している場合には、
oradismプロセスを起動しHugepages用領域を動的に拡張(追加割り当て)します。※1.2
※1.memlockの設定値が低い場合にはTRUEの場合と同様の動きとなります。
※2.Hugepages用領域割り当てられた領域は、インスタンスを停止しても、
 物理メモリ上の通常ページには戻されません。(Hugepage用として獲得されっぱなし)


■vm.nr_hugepages未設定(または0)、DB起動前
[root@s112040 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         10020        955       9065          0        104        515
-/+ buffers/cache:        335       9685
Swap:        16383          0      16383
 →物理メモリは10GB弱空いています。

[root@s112040 ~]# grep Huge /proc/meminfo
AnonHugePages:      2048 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
 →HugePages用領域は0ページ。


■SGA_TRAGETを5GB、「AUTO」を設定してDBを起動した場合
(vm.nr_hugepages=0,memloc=5244928)

(alert.log)
Starting ORACLE instance (normal)
DISM started, OS id=4294 ←←←←←←oradismプロセスの起動
************************ Large Pages Information *******************
Parameter use_large_pages = AUTO
Per process system memlock (soft) limit = 5122 MB

Total Shared Global Region in Large Pages = 5122 MB (100%)

Large Pages used by this instance: 2561 (5122 MB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 2561 (5122 MB)
Large Page size = 2048 KB
Time taken to allocate Large Pages = 0.100901 sec
********************************************************************

[oracle@s112040 ~]$ free -m
             total       used       free     shared    buffers     cached
Mem:         10020       6157       3862          0        104        526
-/+ buffers/cache:       5527       4493
Swap:        16383          0      16383
 →物理メモリが5GB程度使用されています。


[oracle@s112040 ~]$ grep Huge /proc/meminfo
AnonHugePages:      38912 kB
HugePages_Total:    2561
HugePages_Free:        5
HugePages_Rsvd:        5
HugePages_Surp:        0
Hugepagesize:       2048 kB
 →HugePages用領域は2561ページ獲得されている


[oracle@s112040 trace]$ ps -edf|grep dism
root      4294     1  0 02:51 ?        00:00:00 ora_dism_s11204
 →プロセスがrootで起動されている。


~・~・~・~・~・~・~・~・~・~・~・~・~・~・~・~・~

というところで長くなってきたのでココらへんで終わりますが、
どちらの変更も使う側が意識しないで使用するとトラブルの元になりますね。
動作状況について、OSコマンドやログからしっかり把握しておくことが大事ですね。

そういえば、AnonHugePagesって前のエントリにいましたっけ?
要注意なヤツなのですが、それはまた別のお話・・


JPOUG Advent Calendar 2013、
明日の扉は tyuma さんです。よろしくお願いします。



o<(o'∀')ノ☆*:;;;:*☆Merry Christmas☆*:;;;:*☆ヽ('∀'o)>o



続・HugePages_2につづく


1 件のコメント:

  1. どひっ。最後に名前が出てくるとビックリしますね(汗)。おつかれさまでした〜。

    返信削除