11G hugepage的use_large_pages參數

11G 增加參數use_large_pages,可以靈活使用hugepages.

如果參數爲True(默認值),那麼當系統的HugePage被使用盡,只有small pages的情況下,SGA也會繼續運行。此時,Oracle實例就運行在內存使用混合模式(Mixed Mode)下。

如果參數爲是Only,從含義上,表示Oracle實例只會使用HugePage作爲內存使用。如果系統在AMM模式或者HugePage用盡的時候,數據庫就不能啓動或者報錯。

還有一個參數設置use_large_pages=auto.

下面就三個參數進行測試一下區別:

1.use_large_pages=TRUE

SQL> show parameter use_large_pages

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
use_large_pages                      string      TRUE

vm.nr_hugepages = 20,將hugepages設爲很小的值,測試數據庫能否正常開啓。虛擬機的數據庫的sga也很小,只有300M.

[oracle@qht131 ~]$  grep Huge /proc/meminfo
AnonHugePages:     14336 kB
HugePages_Total:      20
HugePages_Free:       20
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
[oracle@qht131 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Apr 6 09:24:31 2020

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             192938264 bytes
Database Buffers          113246208 bytes
Redo Buffers                4747264 bytes
Database mounted.
Database opened.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@qht131 ~]$  grep Huge /proc/meminfo
AnonHugePages:     18432 kB
HugePages_Total:      20
HugePages_Free:        8
HugePages_Rsvd:        8
HugePages_Surp:        0
Hugepagesize:       2048 kB

不過log提示如下,建議將largepagesize設置爲131(262M)。

****************** Large Pages Information *****************

Total Shared Global Region in Large Pages = 40 MB (13%)

Large Pages used by this instance: 20 (40 MB)
Large Pages unused system wide = 0 (0 KB) (alloc incr 4096 KB)
Large Pages configured system wide = 20 (40 MB)
Large Page size = 2048 KB

RECOMMENDATION:
  Total Shared Global Region size is 302 MB. For optimal performance,
  prior to the next instance restart increase the number
  of unused Large Pages by atleast 131 2048 KB Large Pages (262 MB)
  system wide to get 100% of the Shared
  Global Region allocated with Large pages
***********************************************************

2.use_large_pages=ONLY

SQL> alter system set use_large_pages=only;
alter system set use_large_pages=only
                 *
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified


SQL> alter system set use_large_pages=only scope=spfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-27137: unable to allocate large pages to create a shared memory segment
Linux-x86_64 Error: 12: Cannot allocate memory

use_large_pages參數必須要重啓才能生效,改成only以後,數據庫Open失敗。

做這個測試的時候忘記先備份spfile了,不得不從alert_orcl.log中恢復參數,手動重建pfile。

SQL> startup nomount pfile='/u01/app/oracle/product/11203/dbs/initorcl.ora';
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             104857880 bytes
Database Buffers          201326592 bytes
Redo Buffers                4747264 bytes

SQL> create spfile from  pfile='/u01/app/oracle/product/11203/dbs/initorcl.ora';

File created.

3.測試use_large_pages=AUTO,預期是系統如果nr_hugepages設置過小,數據需要增大的hugepagesize時會自動擴大Hugepage的值。

當前值還是20: vm.nr_hugepages=20

[oracle@qht131 dbs]$  cat /proc/meminfo | grep -i  page
AnonPages:        149620 kB
PageTables:        24472 kB
AnonHugePages:     36864 kB
HugePages_Total:      20
HugePages_Free:        5
HugePages_Rsvd:        5
HugePages_Surp:        0
Hugepagesize:       2048 kB

重啓數據庫看是否能啓動

SQL>  alter system set use_large_pages=auto scope=spfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             125829400 bytes
Database Buffers          180355072 bytes
Redo Buffers                4747264 bytes
Database mounted.
Database opened.

SQL> show parameter use_large_pages

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
use_large_pages                      string      AUTO

日誌文件如下:

Starting ORACLE instance (normal)
WARNING: -------------------------------
WARNING: oradism did not start up correctly.
----------------------------------------
oradism creation failed for unknown reasons 0 8 500
Oradism Spawned failed for largepages allocation
****************** Large Pages Information *****************
Parameter use_large_pages = AUTO

Total Shared Global Region in Large Pages = 40 MB (13%)

Large Pages used by this instance: 20 (40 MB)
Large Pages unused system wide = 0 (0 KB) (alloc incr 4096 KB)
Large Pages configured system wide = 20 (40 MB)
Large Page size = 2048 KB
Time taken to allocate Large Pages = 0.000000 sec

RECOMMENDATION:
  Total Shared Global Region size is 302 MB. For optimal performance,
  prior to the next instance restart increase the number
  of unused Large Pages by atleast 131 2048 KB Large Pages (262 MB)
  system wide to get 100% of the Shared
  Global Region allocated with Large pages
***********************************************************

日誌有一個Warning,oradism didn't startup correctly.數據庫雖然啓動成功了,但是沒有達到預期的效果,當前的hugepages_total還是20。由於上面的warning,oradism進程啓動失改,導致沒有自動的擴大hugepages的尺寸。

[oracle@qht131 trace]$ cat /proc/meminfo | grep -i  page
AnonPages:        149396 kB
PageTables:        24300 kB
AnonHugePages:     34816 kB
HugePages_Total:      20
HugePages_Free:        8
HugePages_Rsvd:        8
HugePages_Surp:        0
Hugepagesize:       2048 kB

DISM是Solaris的組件,我的系統是rehdhat,估計是要手動安裝些組件。

 DISM stands for Dynamic Intimate Shared Memory and it is the Solaris component that allows Automatic memory management on Linux and Solaris.DISM is turned on by default for Oracle Database 11.2.0.1 on Oracle Solaris, which makes it important for Database Administrators (DBAs) to understand its capabilities and behavior. as it relates to the memory_target parameters.

關於dism的官方文檔:

https://www.oracle.com/technetwork/articles/systems-hardware-architecture/using-dynamic-intimate-memory-sparc-168402.pdf

所以在Linuxt系統將參數 use_large_pages設爲TURE和AUTO效果是一樣的,默認還是用TRUE吧。

 

http://blog.itpub.net/267265/viewspace-2101170/

http://blog.itpub.net/267265/viewspace-2145480/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章