ITPub博客

首页 > 数据库 > Oracle > [20260420]再论参数use_large_pages(补充use_large_pages=true).txt

[20260420]再论参数use_large_pages(补充use_large_pages=true).txt

原创 Oracle 作者:lfree 时间:2026-04-28 20:08:59 0 删除 编辑

[20260420]再论参数use_large_pages(补充use_large_pages=true).txt

--//前面测试use_large_pages=ONLY,AUTO,AUTO_ONLY等3种情况。还是完善测试补充use_large_pages=true的情况.

1.环境:
SYS@book> @ ver2
==============================
PORT_STRING                   : x86_64/Linux 2.4.xx
VERSION                       : 21.0.0.0.0
BANNER                        : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
BANNER_FULL                   : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
BANNER_LEGACY                 : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
CON_ID                        : 0
PL/SQL procedure successfully completed.

SYS@book> @ hidez ^sga_target|^sga_max_size
 NUM N_HEX CON_ID NAME         DESCRIPTION         DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE ISSES ISSYS_MOD
---- ----- ------ ------------ ------------------- ------------- ------------- ------------ ----- ---------
 173    AD      0 sga_max_size max total SGA size  TRUE          1107296256    1107296256   FALSE FALSE
1797   705      0 sga_target   Target size of SGA  FALSE         1107296256    1107296256   FALSE IMMEDIATE
--//1107296256/1024/1024 = 1056
--//换成hugepages等于1056/2 = 528,实际上需要的hugepages=530.

SYS@book> @ pvalid use_large
Display valid values for multioption parameters matching "use_large"...
  PAR# PARAMETER        ORD VALUE        DEFAULT
------ ---------------- --- ------------ -------
   180 use_large_pages    1 TRUE         DEFAULT
       use_large_pages    2 AUTO
       use_large_pages    3 ONLY
       use_large_pages    4 FALSE
       use_large_pages    5 AUTO_ONLY

--//oracle缺省设置true,优先使用hugepages,不足使用部分small page。false就是不使用hugepages。

--//注意设置use_large_pages=true非常容易混淆,并不是一定全部采用HugePage,而是优先使用HugePage,如果不足采
--//用small pages作为补充,oracle可以继续启动。此时,Oracle实例就运行在内存上使用混合模式(Mixed Mode)下。

--//测试use_large_pages=true.

2.测试use_large_pages=true:

SYS@book> alter system set use_large_pages=true scope=spfile;
System altered.

SYS@book> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.

# grep ^vm /etc/sysctl.d/98-oracle.conf
vm.nr_hugepages = 520
vm.nr_overcommit_hugepages = 20

# sysctl -p /etc/sysctl.d/98-oracle.conf
...
--//注每次修改内核参数文件,必须执行sysctl -p /etc/sysctl.d/98-oracle.conf确认修改内核参数。并且在关闭数据库情况下修改。

SYS@book> startup nomount
ORACLE instance started.
Total System Global Area 1107294056 bytes
Fixed Size                  9684840 bytes
Variable Size             654311424 bytes
Database Buffers          436207616 bytes
Redo Buffers                7090176 bytes

--//查看alter日志:
2026-04-20T16:48:33.819667+08:00
Starting ORACLE instance (normal) (OS id: 7500)
2026-04-20T16:48:33.826579+08:00
****************************************************
 Sys-V shared memory will be used for creating SGA
 ****************************************************
2026-04-20T16:48:33.827533+08:00
**********************************************************************
2026-04-20T16:48:33.827607+08:00
Dump of system resources acquired for SHARED GLOBAL AREA (SGA)

2026-04-20T16:48:33.827745+08:00
 Per process system memlock (soft) limit = 128G
2026-04-20T16:48:33.827899+08:00
 Expected per process system memlock (soft) limit to lock
 instance MAX SHARED GLOBAL AREA (SGA) into memory: 1058M
2026-04-20T16:48:33.828044+08:00
 Available system pagesizes:
  4K, 2048K
2026-04-20T16:48:33.828186+08:00
 Supported system pagesize(s):
2026-04-20T16:48:33.828260+08:00
  PAGESIZE  AVAILABLE_PAGES  EXPECTED_PAGES  ALLOCATED_PAGES  ERROR(s)
2026-04-20T16:48:33.828334+08:00
        4K       Configured               4             5831        NONE
2026-04-20T16:48:33.828492+08:00
     2048K              520             529              517        NONE
2026-04-20T16:48:33.828562+08:00
RECOMMENDATION:
2026-04-20T16:48:33.828632+08:00
 1. For optimal performance, configure system with expected number
 of pages for every supported system pagesize prior to the next
 instance restart operation.
2026-04-20T16:48:33.835047+08:00
**********************************************************************

--//需要529个hugepages,而实际上仅仅建立517,剩下使用4K的small pages,数量5831。

$ ipcs -m
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000000 2981888    oracle     600        10485760   34
0x00000000 3014657    oracle     600        1073741824 34
0x00000000 3047426    oracle     600        16777216   34
0x00000000 3080195    oracle     600        7090176    34
0xafa94c20 3112964    oracle     600        16384      34

--//10485760/2/1024/1024 = 5     --//2M
--//1073741824/2/1024/1024 = 512 --//2M
--//16777216 /4096  = 4096       --//4K
--//7090176  /4096  = 1731       --//4k
--//16384    /4096  = 4          --//4K  
--//5+512 = 517
--//4096+1731+4 = 5831

$ ipcs -mu

------ Shared Memory Status --------
segments allocated 5
pages allocated 270535
pages resident  261298
pages swapped   0
Swap performance: 0 attempts     0 successes

$ grep -i huge /proc/meminfo
AnonHugePages:     55296 kB
HugePages_Total:     520
HugePages_Free:       10
HugePages_Rsvd:        7
HugePages_Surp:        0
Hugepagesize:       2048 kB

--//使用数量可以这样计算:
--//HugePages_Total-HugePages_Free+HugePages_Rsvd = 520-10+7  = 517

$ pmap -x $(pgrep pmon) | head -13
7521:   ora_pmon_book
Address           Kbytes     RSS   Dirty Mode  Mapping
0000000000400000  422472   12332       0 r-x-- oracle
000000001a292000    1540     120       4 r---- oracle
000000001a413000     468      20      20 rw--- oracle
000000001a488000     344     192     192 rw---   [ anon ]
000000001a99c000     316     256     256 rw---   [ anon ]
0000000060000000   10240       0       0 rw-s- SYSV00000000 (deleted)
0000000061000000 1048576       0       0 rw-s- SYSV00000000 (deleted)
00000000a1000000   16384       0       0 rw-s-   [ shmid=0x2e8002 ] --//4K pages
00000000a2000000    6924       0       0 rw-s-   [ shmid=0x2f0003 ] --//4K pages
00000000a3000000      16       4       4 rw-s-   [ shmid=0x2f8004 ] --//4K pages
00007f71d4872000     192     160     160 rw---   [ anon ]

$ pmap -x $(pgrep pmon) | grep "rw-s"
0000000060000000   10240       0       0 rw-s- SYSV00000000 (deleted)
0000000061000000 1048576       0       0 rw-s- SYSV00000000 (deleted)
00000000a1000000   16384       0       0 rw-s-   [ shmid=0x2e8002 ]
00000000a2000000    6924       0       0 rw-s-   [ shmid=0x2f0003 ]
00000000a3000000      16       4       4 rw-s-   [ shmid=0x2f8004 ]
00007f71d9f33000       4       4       0 rw-s- hc_book.dat

SYS@book> oradebug setmypid
Statement processed.
SYS@book> oradebug ipc
IPC information written to the trace file

*** 2026-04-20T17:03:29.558919+08:00 (CDB$ROOT(1))
Processing Oradebug command 'ipc'
Dump of unix-generic skgm context
areaflags            00001fb7
realmflags           0003ffff
mapsize              00001000
protectsize          00001000
lcmsize              00001000
seglen               00001000
largestsize  0000040000000000
smallestsize 0000000001000000
stacklimit     0x7ffc2a61fa32
stackdir                   -1
mode                      600
magic                acc01ade
 Dump of unix-generic realm handle `/u01/app/oracle/product/21.0.0/dbhome_1book', flags = 00000000
  key 2947107872 actual_key 2947107872 num_areas 4 num_subareas 5
  primary shmid: 3112964 primary sanum 4 version 3
  deferred alloc: FALSE (0) def_post_create: FALSE (0) exp_memlock: 1058M
 Area #0 `Fixed Size' containing Subareas 3-3
  Total size 000000000093c768 Minimum Subarea size 00000000
   Area  Subarea    Shmid    Segment Addr    Stable Addr    Actual Addr
      0        3  2981888 0x00000060000000 0x00000060000000 0x00000060000000
               Subarea size     Segment size   Req_Protect  Cur_protect
                          000000000093d000 0000000000a00000 default       readwrite
 Area #1 `Variable Size' containing Subareas 0-1
  Total size 0000000041000000 Minimum Subarea size 01000000
   Area  Subarea    Shmid    Segment Addr    Stable Addr    Actual Addr
      1        0  3014657 0x00000061000000 0x00000061000000 0x00000061000000
               Subarea size     Segment size   Req_Protect  Cur_protect
                          0000000040000000 0000000040000000 default       readwrite
   Area  Subarea    Shmid    Segment Addr    Stable Addr    Actual Addr
      1        1  3047426 0x000000a1000000 0x000000a1000000 0x000000a1000000
               Subarea size     Segment size   Req_Protect  Cur_protect
                          0000000001000000 0000000001000000 default       readwrite
--//分成2部分。
 Area #2 `Redo Buffers' containing Subareas 2-2
  Total size 00000000006c3000 Minimum Subarea size 00001000
   Area  Subarea    Shmid    Segment Addr    Stable Addr    Actual Addr
      2        2  3080195 0x000000a2000000 0x000000a2000000 0x000000a2000000
               Subarea size     Segment size   Req_Protect  Cur_protect
                          00000000006c3000 00000000006c3000 default       readwrite
 Area #3 `skgm overhead' containing Subareas 4-4
  Total size 0000000000004000 Minimum Subarea size 00000000
   Area  Subarea    Shmid    Segment Addr    Stable Addr    Actual Addr
      3        4  3112964 0x000000a3000000 0x000000a3000000 0x000000a3000000
               Subarea size     Segment size   Req_Protect  Cur_protect
                          0000000000004000 0000000000004000 default       readwrite

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3116906/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969384