Oracle資料庫例項在AIX 平臺下使用大頁記憶體(Large Page Memory)

路途中的人2012發表於2016-11-01
        不管是AIX平臺還是在Linux平臺使用大頁記憶體(Large Page Memory)都是依賴於作業系統的特性。Linux平臺和AIX平臺預設的頁面大小都是4K,Linux平臺的HugePage特性通常每個頁面可以調整為2M;AIX平臺的Large Page Memory使得單個頁面最大可以調整為16M;下面詳細討論在AIX平臺下,Oracle資料庫例項使用64K和16M兩種規格的記憶體頁面,主要討論的是16M的記憶體頁面

1.使用64K記憶體頁面
在oracle使用者的PROFILE檔案中加入以下環境變數的設定:
export  

在使以上環境變數生效的情況下重啟Oracle資料庫例項。

使用前:
halpar1:[/home/oracle]$ps -efZ | grep ora
oracle 340174 1 0 22:27:07 - 0:00 4K 4K 4K 4K ora_mmnl_ordb
oracle 405740 1 0 22:27:27 - 0:00 4K 4K 4K 4K ora_q001_ordb
oracle 409848 1 1 22:27:07 - 0:00 4K 4K 4K 4K ora_ckpt_ordb
oracle 463038 1 0 22:27:06 - 0:00 4K 4K 4K 4K ora_lgwr_ordb
oracle 499916 704560 0 22:26:57 pts/0 0:00 4K 4K 4K 4K -ksh
oracle 508116 1 0 22:27:06 - 0:00 4K 4K 4K 4K ora_dbw0_ordb
oracle 524472 1 0 22:27:06 - 0:00 4K 4K 4K 4K ora_mman_ordb
oracle 549010 1 0 22:27:06 - 0:00 4K 4K 4K 4K ora_psp0_ordb
oracle 577616 1 0 22:27:06 - 0:00 4K 4K 4K 4K ora_pmon_ordb
oracle 589946 1 0 22:27:07 - 0:00 4K 4K 4K 4K ora_smon_ordb

使用後:
halpar1:[/]#ps -efZ | grep ora
oracle 340180 1 0 22:43:02 - 0:00 64K 64K 64K 4K ora_psp0_ordb
oracle 405742 1 0 22:43:22 - 0:00 64K 64K 64K 4K ora_q000_ordb
oracle 409850 1 0 22:43:03 - 0:00 64K 64K 64K 4K ora_d000_ordb
oracle 463040 1 0 22:43:03 - 0:00 64K 64K 64K 4K ora_mmnl_ordb
oracle 499916 704560 0 22:26:57 pts/0 0:00 4K 4K 4K 4K -ksh
oracle 508118 1 0 22:43:03 - 0:00 64K 64K 64K 4K ora_mmon_ordb
oracle 524474 1 15 22:43:03 - 0:00 64K 64K 64K 4K ora_cjq0_ordb
oracle 549012 1 0 22:43:02 - 0:00 64K 64K 64K 4K ora_reco_ordb
oracle 577618 1 0 22:43:02 - 0:00 64K 64K 64K 4K ora_smon_ordb
oracle 589948 1 0 22:43:02 - 0:00 64K 64K 64K 4K ora_ckpt_ordb

2.使用16M記憶體頁面

1).在作業系統執行如下命令:
#vmo -po v_pinshm=1
#vmo -po maxpin%=80(根據實際需要來設定)
#chuser capabilities=CAP_BYPASS_RAC_VMM,CAP_PROPAGATE oracle(使用lsuser -a capabilities oracle命令可以檢視oracle使用者設定的此屬性)
#vmo -po lgpg_size=16777216 -o lgpg_regions=64(16777216=16M*64=1024M記憶體,lgpg_size根據實際的記憶體和資料庫例項SGA的大小來設定)
Setting lgpg_size to 16777216 in nextboot file
Setting lgpg_regions to 64 in nextboot file
Warning :although the change concerns a dynamic ...
optimally restore these settings at reboot(建議做bosboot,並且重新啟動作業系統)
Setting lgpg_size to 16777216
Setting lgpg_regions to 64
#bosboot -a

注意:Oracle Database 10.2.0.4及其以上的版本必須完成chuser capabilities=CAP_BYPASS_RAC_VMM,CAP_PROPAGATE oracle命令對oracle作業系統使用者屬性的設定,如果不設定可能導致出現如下文章中的問題:http://space.itpub.net/23135684/viewspace-631065

執行下面的命令可以去除16M的頁面設定:
#vmo -po lgpg_size=0 -o lgpg_regions=0

2).需要修改oracle使用者的profile檔案
#export ORACLE_SGA_PGSZ=16M

Oracle 10.2.0.4,需要設定這個引數,參見metalink DOC ID:NOTE:728444.1

3).需要修改資料庫引數
執行以下的SQL語句,主要設定LOCK_SGA為true:
SQL> alter system set pre_page_sga=true scope=spfile;
SQL> alter system set lock_sga=true scope=spfile;
        將LOCK_SGA設定為TRUE會觸發Oracle資料庫例項使用Large Page Memory,設定之後重啟資料庫例項。

使用16M記憶體頁面之前:
halpar1:[/]#svmon
size inuse free pin virtual
memory 1048576 637640 447815 445323 288587
pg space 262144 2841
work pers clnt other
pin 109892 0 2849 70438
in use 288587 0 86909
PageSize PoolSize inuse pgsp pin virtual
s 4 KB - 245336 2841 102907 158427
m 64 KB - 8135 0 5017 8135
L 16 MB 64 0 0 64 0(值為0)

使用16M記憶體頁面之後:
halpar1:[/]#svmon
size inuse free pin virtual
memory 1048576 691573 393883 446308 473636
pg space 262144 3088
work pers clnt other
pin 241949 0 2849 70438
in use 473636 0 86865
PageSize PoolSize inuse pgsp pin virtual
s 4 KB - 247605 3088 102916 160740
m 64 KB - 11364 0 5078 11364
L 16 MB 64 32 0 64 32(值為非0)

        如果資料庫被升級到了10.2.0.4或者10.2.0.5,經過以上配置預設可能也不會使用到大頁,請參考文章:《AIX: Upgraded To 10.2.0.4 (or 10.2.0.5) And Large Page Memory Is No Longer Used [ID 728444.1] 》 http://space.itpub.net/?uid-23135684-action-viewspace-itemid-742754 

         有關在AIX平臺使用Large Page Memory的詳細內容參考文章:《How to enable Large Page Feature on AIX-Based Systems [ID 372157.1]》http://space.itpub.net/?uid-23135684-action-viewspace-itemid-742753

結合METALINK的文章,AIX平臺下的16M Large Page Memory配置如下:
# oslevel -s
6100-07-05-1228
# vmo -L v_pinshm
NAME                      CUR    DEF    BOOT   MIN    MAX    UNIT           TYPE
     DEPENDENCIES
--------------------------------------------------------------------------------
v_pinshm                  0      0      0      0      1      boolean           D
--------------------------------------------------------------------------------
# vmo -po v_pinshm=1
Setting v_pinshm to 1 in nextboot file
Setting v_pinshm to 1
# vmo -L v_pinshm
NAME                      CUR    DEF    BOOT   MIN    MAX    UNIT           TYPE
     DEPENDENCIES
--------------------------------------------------------------------------------
v_pinshm                  1      0      1      0      1      boolean           D
--------------------------------------------------------------------------------
# vmo -L maxpin%
NAME                      CUR    DEF    BOOT   MIN    MAX    UNIT           TYPE
     DEPENDENCIES
--------------------------------------------------------------------------------
maxpin%                   80     80     80     1      100    % memory          D
     pinnable_frames
     memory_frames
--------------------------------------------------------------------------------
# lsuser -a capabilities oracle 
oracle capabilities=CAP_BYPASS_RAC_VMM,CAP_PROPAGATE,CAP_NUMA_ATTACH
# lsuser -a capabilities grid
grid capabilities=CAP_BYPASS_RAC_VMM,CAP_PROPAGATE,CAP_NUMA_ATTACH
# lsattr -El mem0
ent_mem_cap          I/O memory entitlement in Kbytes           False
goodsize       31488 Amount of usable physical memory in Mbytes False
mem_exp_factor       Memory expansion factor                    False
size           31488 Total amount of physical memory in Mbytes  False
var_mem_weight       Variable memory capacity weight            False
# vmo -p -o lgpg_regions=1024 -o lgpg_size=16777216
Setting lgpg_size to 16777216 in nextboot file
Setting lgpg_regions to 1024 in nextboot file
Warning: although the change concerns a dynamic tunable, bosboot should be run to optimally restore these settings at reboot
Setting lgpg_size to 16777216
Setting lgpg_regions to 1024
# vmo -o lru_file_repage=0
Setting lru_file_repage to 0
Warning: a restricted tunable has been modified
# bosboot -a
bosboot: Boot image is 51228 512 byte blocks.
# vmstat -l

System configuration: lcpu=16 mem=31488MB

kthr    memory              page              faults        cpu     large-page 
----- ----------- ------------------------ ------------ ----------- -----------
 r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa   alp   flp
 1  1 899643  7522   0   0   0  47   63   0  21 2107 579  0  0 99  0     0  1024
# svmon
               size       inuse        free         pin     virtual   mmode
memory      8060928     8042431       18497     4724020      902447     Ded
pg space    2621440        3418

               work        pers        clnt       other
pin          292772           0           0      236944
in use       902447           0     2945680

PageSize   PoolSize       inuse        pgsp         pin     virtual
s    4 KB         -     3372319        3418      310180      426639
m   64 KB         -       29738           0       13721       29738
L   16 MB      1024           0           0        1024           0

下面是調整Oracle資料庫例項引數後使用Large Page Memory的過程:
$ sql

SQL*Plus: Release 11.2.0.3.0 Production on Thu Sep 6 15:00:51 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter system set sga_max_size=16g scope=spfile;

System altered.

SQL> alter system set sga_target=16g scope=spfile;

System altered.

SQL> alter system set pre_page_sga=true scope=spfile;

System altered.

SQL> alter system set lock_sga=true scope=spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORA-27102: out of memory
IBM AIX RISC System/6000 Error: 12: Not enough space

   
伺服器總共有32G的記憶體,Large Page Memory設定的是16G,Oracle資料庫例項SGA設定的也是16G,但資料庫例項啟動的時候由於粒度的原因佔用的空間可能稍微大於16G,那麼Large Page Memory空間是不夠用的(這段空間自動分配之後就被佔據,不被任何程式使用,Oracle例項無法使用,空間即被浪費),剩餘的空間也是不夠的,所以報記憶體不足。解決辦法是將lgpg_regions增加1即可:
# vmo -p -o lgpg_regions=1025 -o lgpg_size=16777216
Setting lgpg_size to 16777216 in nextboot file
Setting lgpg_regions to 1025 in nextboot file
Warning: although the change concerns a dynamic tunable, bosboot should be run to optimally restore these settings at reboot
Setting lgpg_size to 16777216
Setting lgpg_regions to 1025

SQL> startup
ORACLE instance started.

Total System Global Area 1.7103E+10 bytes
Fixed Size                  2238616 bytes
Variable Size             771753832 bytes
Database Buffers         1.6307E+10 bytes
Redo Buffers               21716992 bytes
Database mounted.
Database opened.

# svmon
               size       inuse        free         pin     virtual   mmode
memory      8060928     5732976     2327952     4683897     5139434     Ded
pg space    2621440        3736

               work        pers        clnt       other
pin         4446953           0           0      236944
in use      5139434           0      593542

PageSize   PoolSize       inuse        pgsp         pin     virtual
s    4 KB         -     1096480        3736      309289      502938
m   64 KB         -       27381           0       11013       27381
L   16 MB      1025        1025           0        1025        1025
# vmstat -l

System configuration: lcpu=16 mem=31488MB

kthr    memory              page              faults        cpu     large-page 
----- ----------- ------------------------ ------------ ----------- -----------
 r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa   alp   flp
 1  1 5139300 2328085   0   0   0   0    0   0  18 1853 568  0  0 99  0  1025     0
    從上面的命令可以看出1025個Large Page Memory都被使用了。

--end--

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

相關文章