Hugepages你用了吗?--测试案例篇

简介:

Hugepages你用了吗?----原理概念篇

Hugepages你用了吗?----测试案例篇

书接上回,关于Hugepages的设置方法和相关概念已经在“原理概念篇”介绍完成,下面我会针对几种情况进行测试,并分析测试结果

------------------------------------

测试目的及意外发现

1. 如何配置Hugepages?

2. Hugepages size是需要大于sga_max_size才生效,还是大于sga_target 就满足条件呢?

3. AMM在使用的情况下,Hugepages生效吗?

4. 通过测试,意外发现,在使用Hugepags前后,SGA的共享内存在OS系统上是以不同的形态存在的。 根据测试和网络搜索,发现/dev/shm是否使用是与AMM相关的,后续再单独测试并更新一篇博客

------------------------------------

一、 如何配置Hugepages

1. 查看文件系统,可以看到共享文件系统/dev/shm

 
 
  1. [root@OEL ~]# df -h
  2.  
  3. Filesystem            Size  Used Avail Use% Mounted on
  4.  
  5. /dev/mapper/VolGroup00-LogVol00
  6.  
  7.                       6.8G  2.7G  3.8G  41% /
  8.  
  9. /dev/sda1              99M   24M   71M  25% /boot
  10.  
  11. tmpfs                 1.5G     0  1.5G   0% /dev/shm               <<<<<<共享内存文件系统
  12.  
  13. /dev/sdo1             9.9G  7.3G  2.1G  78% /u01
  14.  
  15. /dev/sr0              2.4G  2.4G     0 100% /media/20120514_120722

2. 查看当前共享内存使用(oracle数据库启动前)

 
 
  1. [root@OEL ~]# ipcs -m
  2.  
  3. ------ Shared Memory Segments --------
  4.  
  5. key        shmid      owner      perms      bytes      nattch     status     
  6.  
  7. 0x00000000 3538944    root      644        80         2                      
  8.  
  9. 0x00000000 3571713    root      644        16384      2                      
  10.  
  11. 0x00000000 3604482    root      644        280        2                      
  12.  
  13. 0x00000000 3670019    root      600        393216     2          dest        
  14.  
  15. 0x00000000 3702788    root      600        393216     2          dest        
  16.  
  17. 0x00000000 3735557    root      600        393216     2          dest        
  18.  
  19. 0x00000000 3768326    root      600        393216     2          dest        
  20.  
  21. 0x00000000 3801095    root      600        393216     2          dest        
  22.  
  23. 0x00000000 3833864    root      600        393216     2          dest        
  24.  
  25. 0x00000000 3866633    root      600        393216     2          dest        
  26.  
  27. 0x00000000 3899402    root      600        393216     2          dest        
  28.  
  29. 0x00000000 3932171    root      600        393216     2          dest        
  30.  
  31. 0x00000000 3964940    root      600        393216     2          dest   

3. 查看当前共享内存使用(oracle数据库启动后)

 
 
  1. [root@OEL ~]# ipcs -a
  2.  
  3. ------ Shared Memory Segments --------
  4.  
  5. key        shmid      owner      perms      bytes      nattch     status     
  6.  
  7. 0x00000000 3538944    root      644        80         2                      
  8.  
  9. 0x00000000 3571713    root      644        16384      2                      
  10.  
  11. 0x00000000 3604482    root      644        280        2                      
  12.  
  13. 0x00000000 3670019    root      600        393216     2          dest        
  14.  
  15. 0x00000000 3702788    root      600        393216     2          dest        
  16.  
  17. 0x00000000 3735557    root      600        393216     2          dest        
  18.  
  19. 0x00000000 3768326    root      600        393216     2          dest        
  20.  
  21. 0x00000000 3801095    root      600        393216     2          dest        
  22.  
  23. 0x00000000 3833864    root      600        393216     2          dest        
  24.  
  25. 0x00000000 3866633    root      600        393216     2          dest        
  26.  
  27. 0x00000000 3899402    root      600        393216     2          dest        
  28.  
  29. 0x00000000 3932171    root      600        393216     2          dest        
  30.  
  31. 0x00000000 3964940    root      600        393216     2          dest        
  32.  
  33. 0xa3c20e68 4030477    oracle    660        4096       0                      
  34.  
  35. 0x6010c970 4096014    oracle    660        4096       0       
  36.  
  37. ------ Semaphore Arrays --------
  38.  
  39. key        semid      owner      perms      nsems    
  40.  
  41. 0x000000a7 0          root      600        1        
  42.  
  43. 0x253c0f5c 131073     oracle    660        104      
  44.  
  45. 0xf8987fd4 262146     oracle    660        154      
  46.  
  47. [root@OEL ~]# df -h
  48.  
  49. Filesystem            Size  Used Avail Use% Mounted on
  50.  
  51. /dev/mapper/VolGroup00-LogVol00
  52.  
  53.                       6.8G  2.7G  3.8G  41% /
  54.  
  55. /dev/sda1              99M   24M   71M  25% /boot
  56.  
  57. tmpfs                 1.5G  635M  840M  44% /dev/shm            <<<<<已经有共享内存被使用
  58.  
  59. /dev/sdo1             9.9G  7.3G  2.1G  78% /u01
  60.  
  61. /dev/sr0              2.4G  2.4G     0 100% /media/20120514_120722

4. 查看Hugepages,还没有被使用

 
 
  1. [root@OEL ~]# more /proc/meminfo |grep Hug
  2.  
  3. HugePages_Total:       0
  4.  
  5. HugePages_Free:        0
  6.  
  7. HugePages_Rsvd:        0
  8.  
  9. HugePages_Surp:        0
  10.  
  11. Hugepagesize:       2048 kB

5. 下面开始进行Hugepages的设置和使用

 
 
  1. [root@OEL ~]# su - oracle 
  2.  
  3. [oracle@OEL ~]$ sqlplus / as sysdba 
  4.  
  5. SQL> show parameter sga 
  6.  
  7. NAME                                 TYPE        VALUE 
  8.  
  9. ------------------------------------ ----------- ------------------------------ 
  10.  
  11. lock_sga                             boolean     FALSE 
  12.  
  13. pre_page_sga                         boolean     FALSE 
  14.  
  15. sga_max_size                         big integer 800M 
  16.  
  17. sga_target                           big integer 0 
  18.  
  19. SQL> show parameter shared_pool 
  20.  
  21. NAME                                 TYPE        VALUE 
  22.  
  23. ------------------------------------ ----------- ------------------------------ 
  24.  
  25. shared_pool_reserved_size            big integer 7969177 
  26.  
  27. shared_pool_size                     big integer 0 

6. 查看当前的pmon进程号

 
 
  1. [oracle@OEL ~]$ ps -ef|grep pmon 
  2.  
  3. oracle    7267     1  0 10:01 ?        00:00:00 asm_pmon_+ASM 
  4.  
  5. oracle    7426     1  0 10:02 ?        00:00:00 ora_pmon_db 
  6.  
  7. oracle    8703  8593  0 10:25 pts/2    00:00:00 grep pmon 

注:pmap命令用于检查进程,显示进程空间中的所有映射。每个映射都包括了常驻内存空间,是有内存空间和共享内存空间的数量。这有助于我们估计共享内存空间和是有内存空间的使用量。

7. 查看DB使用的内存

 
 
  1. [oracle@OEL ~]$ pmap 7426 
  2.  
  3. 7426:   ora_pmon_db 
  4.  
  5. 0000000000400000 155140K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/bin/oracle 
  6.  
  7. 0000000009d81000  12404K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/bin/oracle 
  8.  
  9. 000000000a99e000    280K rwx--    [ anon ]                                             
  10.  
  11. 000000000bfb0000    672K rwx--    [ anon ] 
  12.  
  13. 0000000060000000      4K r-xs-  /dev/shm/ora_db_4096014_0 
  14.  
  15. 0000000060001000   4092K rwxs-  /dev/shm/ora_db_4096014_0 
  16.  
  17. 0000000060400000   4096K rwxs-  /dev/shm/ora_db_4096014_1 
  18.  
  19. ...... 
  20.  
  21. 00007fceb4bf0000    228K rwx--  /dev/zero 
  22.  
  23. 00007fceb4c29000   1700K rwx--    [ anon ] 
  24.  
  25. 00007fceb4dd2000     40K r-x--  /lib64/libnss_files-2.5.so 
  26.  
  27. 00007fceb4ddc000   2044K -----  /lib64/libnss_files-2.5.so 
  28.  
  29. 00007fceb4fdb000      4K r-x--  /lib64/libnss_files-2.5.so 
  30.  
  31. 00007fceb4fdc000      4K rwx--  /lib64/libnss_files-2.5.so 
  32.  
  33. 00007fceb4fed000    416K rwx--    [ anon ] 
  34.  
  35. 00007fceb5055000      4K r-x--  /usr/lib64/libaio.so.1.0.1 
  36.  
  37. 00007fceb5056000   2044K -----  /usr/lib64/libaio.so.1.0.1 
  38.  
  39. 00007fceb5255000      4K rwx--  /usr/lib64/libaio.so.1.0.1 
  40.  
  41. 00007fceb5256000      4K rwx--    [ anon ] 
  42.  
  43. 00007fceb5257000    444K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libasmclnt11.so 
  44.  
  45. ...... 
  46.  
  47. 00007fceb687f000      4K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libodmd11.so 
  48.  
  49. 00007fceb6880000      8K rwx--    [ anon ] 
  50.  
  51. 00007fff1e203000     84K rwx--    [ stack ] 
  52.  
  53. 00007fff1e31e000      4K r-x--    [ anon ] 
  54.  
  55. ffffffffff600000      4K r-x--    [ anon ] 
  56.  
  57. total          1037992K 

8. 查看ASM使用的内存

 
 
  1. [oracle@OEL shm]$ pmap -x 9421 
  2.  
  3. 9421:   ora_pmon_db 
  4.  
  5. Address           Kbytes     RSS   Dirty Mode   Mapping 
  6.  
  7. 0000000000400000  155140   11652       0 r-x--  oracle 
  8.  
  9. 0000000009d81000   12404     284      80 rwx--  oracle 
  10.  
  11. 000000000a99e000     280     184     176 rwx--    [ anon ]       <<<<私有进程 
  12.  
  13. 000000000aedd000     724     544     544 rwx--    [ anon ] 
  14.  
  15. 0000000060000000  718848       0       0 rwxs-  SYSV6010c970 (deleted) 
  16.  
  17. 00000032f7e00000     112     100       0 r-x--  ld-2.5.so 
  18.  
  19. ...... 
  20.  
  21. 00007fffc1d58000      84      40      40 rwx--    [ stack ] 
  22.  
  23. 00007fffc1d97000       4       4       0 r-x--    [ anon ] 
  24.  
  25. ffffffffff600000       4       0       0 r-x--    [ anon ] 
  26.  
  27. ----------------  ------  ------  ------ 
  28.  
  29. total kB          933320   15716    2056 

注:共享内存,该数值合计等于database SGA_MAX,同时可以发现分配的共享地址空间是连续的(000000008f800000 ~ 000000008fc00000   )每个大小是4096K, 这里引出一个问题,为什么普通的page是4K,这里显示的确实4096K?这是由于,oracle database的内存最小分配单位是granule,这里是granule size。

9. 查询DB实例的共享内存

 
 
  1. [oracle@OEL ~]$ pmap 7426|grep sh
  2.  
  3. 0000000060000000      4K r-xs-  /dev/shm/ora_db_4096014_0
  4.  
  5. 0000000060001000   4092K rwxs-  /dev/shm/ora_db_4096014_0
  6.  
  7. 0000000060400000   4096K rwxs-  /dev/shm/ora_db_4096014_1
  8.  
  9. 0000000060800000   4096K rwxs-  /dev/shm/ora_db_4096014_2
  10.  
  11. 0000000060c00000   4096K rwxs-  /dev/shm/ora_db_4096014_3
  12.  
  13. 0000000061000000   4096K rwxs-  /dev/shm/ora_db_4096014_4
  14.  
  15. ......
  16.  
  17. 000000008f800000   4096K rwxs-  /dev/shm/ora_db_4096014_190
  18.  
  19. 000000008fc00000   4096K rwxs-  /dev/shm/ora_db_4096014_191
  20.  
  21. 0000000090000000   4096K rwxs-  /dev/shm/ora_db_4096014_192
  22.  
  23. 0000000090400000   4096K rwxs-  /dev/shm/ora_db_4096014_193
  24.  
  25. 0000000090800000   4096K rwxs-  /dev/shm/ora_db_4096014_194
  26.  
  27. 0000000090c00000   4096K rwxs-  /dev/shm/ora_db_4096014_195
  28.  
  29. 0000000091000000   4096K rwxs-  /dev/shm/ora_db_4096014_196
  30.  
  31. 0000000091400000   4096K rwxs-  /dev/shm/ora_db_4096014_197
  32.  
  33. 0000000091800000   4096K rwxs-  /dev/shm/ora_db_4096014_198
  34.  
  35. 0000000091c00000   4096K rwxs-  /dev/shm/ora_db_4096014_199
  36.  
  37. 0000000092000000   4096K rwxs-  /dev/shm/ora_db_4096014_200
  38.  
  39. [oracle@OEL ~]$ pmap 7426|grep sh|wc -l
  40.  
  41. 202
  42.  
  43. 202x4096K=830M正好是SGA的大小

10. 查看共享内存,发现oracle用户下已经有两个共享区域了。

 
 
  1. [oracle@OEL ~]$ ipcs -m 
  2.  
  3. ------ Shared Memory Segments -------- 
  4.  
  5. key        shmid      owner      perms      bytes      nattch     status     
  6.  
  7. 0x00000000 3538944    root      644        80         2                      
  8.  
  9. 0x00000000 3571713    root      644        16384      2                      
  10.  
  11. 0x00000000 3604482    root      644        280        2                      
  12.  
  13. 0xa3c20e68 4030477    oracle    660        4096       0                      
  14.  
  15. 0x6010c970 4096014    oracle    660        4096       0               

二、AMM在使用的情况下,Hugepages生效吗?

1. 备份spfile,后续需要更改spfile参数,防止更改出错后恢复

 
 
  1. [oracle@OEL ~]$ sqlplus / as sysdba 
  2.  
  3. SQL> create pfile='/tmp/liangxx' from spfile; 
  4.  
  5. File created. 
  6.  
  7. SQL> show parameter memory 
  8.  
  9. NAME                                 TYPE        VALUE 
  10.  
  11. ------------------------------------ ----------- ------------------------------ 
  12.  
  13. memory_max_target                    big integer 800M 
  14.  
  15. memory_target                            big integer 800M 

2. AMM启用时,hugepages没有生效

 
 
  1. [oracle@OEL ~]$ more /proc/meminfo |grep Hug 
  2.  
  3. HugePages_Total:     700 
  4.  
  5. HugePages_Free:      700 
  6.  
  7. HugePages_Rsvd:        0 
  8.  
  9. HugePages_Surp:        0 
  10.  
  11. Hugepagesize:       2048 kB 

3. 查看共享内存

 
 
  1. [oracle@OEL ~]$ ps -ef|grep pmon 
  2.  
  3. oracle    6438     1  0 16:48 ?        00:00:00 asm_pmon_+ASM 
  4.  
  5. oracle   11376     1  0 18:30 ?        00:00:00 ora_pmon_db 
  6.  
  7. oracle   11908 10931  0 18:42 pts/1    00:00:00 grep pmon 
  8.  
  9. [oracle@OEL ~]$ pmap 11376 |grep sh 
  10.  
  11. 0000000060000000      4K r-xs-  /dev/shm/ora_db_3833861_0 
  12.  
  13. 0000000060001000   4092K rwxs-  /dev/shm/ora_db_3833861_0 
  14.  
  15. 0000000060400000   4096K rwxs-  /dev/shm/ora_db_3833861_1 
  16.  
  17. 0000000060800000   4096K rwxs-  /dev/shm/ora_db_3833861_2 
  18.  
  19. 0000000060c00000   4096K rwxs-  /dev/shm/ora_db_3833861_3 
  20.  
  21. 0000000061000000   4096K rwxs-  /dev/shm/ora_db_3833861_4 
  22.  
  23. 0000000061400000   4096K rwxs-  /dev/shm/ora_db_3833861_5 
  24.  
  25. 0000000061800000   4096K rwxs-  /dev/shm/ora_db_3833861_6 
  26.  
  27. 0000000061c00000   4096K rwxs-  /dev/shm/ora_db_3833861_7 
  28.  
  29. 0000000062000000   4096K rwxs-  /dev/shm/ora_db_3833861_8 
  30.  
  31. 0000000062400000   4096K rwxs-  /dev/shm/ora_db_3833861_9 
  32.  
  33. 0000000062800000   4096K rwxs-  /dev/shm/ora_db_3833861_10 
  34.  
  35. ...... 
  36.  
  37. 000000006d000000   4096K rwxs-  /dev/shm/ora_db_3833861_52 
  38.  
  39. [oracle@OEL ~]$ pmap 11376 |grep sh|wc -l 
  40.  
  41. 54 

4. 在禁用AMM之后,还需要设置max locked memory值,该值代表系统最大的可分配的共享内存。

 
 
  1. [oracle@OEL ~]$ ulimit -a 
  2.  
  3. core file size          (blocks, -c) 0 
  4.  
  5. data seg size           (kbytes, -d) unlimited 
  6.  
  7. scheduling priority             (-e) 0 
  8.  
  9. file size               (blocks, -f) unlimited 
  10.  
  11. pending signals                 (-i) 23543 
  12.  
  13. max locked memory       (kbytes, -l) 64         <<<<<这里的值设置太小,所以hugepages没有生效
  14.  
  15. max memory size         (kbytes, -m) unlimited 
  16.  
  17. open files                      (-n) 1024 
  18.  
  19. pipe size            (512 bytes, -p) 8 
  20.  
  21. POSIX message queues     (bytes, -q) 819200 
  22.  
  23. real-time priority              (-r) 0 
  24.  
  25. stack size              (kbytes, -s) 8192 
  26.  
  27. cpu time               (seconds, -t) unlimited 
  28.  
  29. max user processes              (-u) 2047 
  30.  
  31. virtual memory          (kbytes, -v) unlimited 
  32.  
  33. file locks                      (-x) unlimited 

5. 在/etc/security/limits.conf中设置以下参数,就是设置max locked memory  

 
 
  1. [root@OEL ~]# vi /etc/security/limits.conf 
  2.  
  3. *   soft   memlock    60397977 
  4.  
  5. *   hard   memlock    60397977 

重启系统 或者 sysctl -p使设置生效

检查设置结果

 
 
  1. [oracle@OEL ~]$ ulimit -a 
  2.  
  3. 60397977 

6. 查询到Hugepage已经被使用到

 
 
  1. [oracle@OEL tmp]$ more /proc/meminfo|grep Hug 
  2.  
  3. HugePages_Total:     700 
  4.  
  5. HugePages_Free:      548 
  6.  
  7. HugePages_Rsvd:       99 
  8.  
  9. HugePages_Surp:        0 
  10.  
  11. Hugepagesize:       2048 kB 

7. 查看ASM实例的SGA是否使用到Hugepage,首先确认是否有设置memory_max_size

 
 
  1. [oracle@OEL tmp]$ sqlplus / as sysdba 
  2.  
  3. SQL> show parameter memory 
  4.  
  5. NAME                                 TYPE        VALUE 
  6.  
  7. ------------------------------------ ----------- ------------------------------ 
  8.  
  9. memory_max_target                        big integer 272M 
  10.  
  11. memory_target                            big integer 272M 
  12.  
  13. SQL> create pfile='/tmp/asmxx' from spfile; 
  14.  
  15. File created. 
  16.  
  17. SQL> alter system set memory_max_target=0 scope=spfile
  18.  
  19. System altered. 
  20.  
  21. SQL> alter system set memory_target=0 scope=spfile
  22.  
  23. System altered. 
  24.  
  25. SQL> show parameter sga 
  26.  
  27. NAME                                 TYPE        VALUE 
  28.  
  29. ------------------------------------ ----------- ------------------------------ 
  30.  
  31. lock_sga                             boolean     FALSE 
  32.  
  33. sga_max_size                         big integer 272M 
  34.  
  35. sga_target                           big integer 0 
  36.  
  37. SQL> alter system set sga_max_size=500M scope=spfile
  38.  
  39. System altered. 

8. SGA设置不正确的值,报错,通过之前备份的pfile启动

 
 
  1. [oracle@OEL tmp]$ sqlplus / as sysdba 
  2.  
  3. SQL> startup nomount 
  4.  
  5. ORA-00843: Parameter not taking MEMORY_MAX_TARGET into account 
  6.  
  7. ORA-00849: SGA_TARGET 524288000 cannot be set to more than MEMORY_MAX_TARGET 0. 
  8.  
  9. SQL> exit 
  10.  
  11. Disconnected 

注:这里引出之前介绍的问题,直接alter system set memory_target=0 scope=spfile;是更改不成功的。直接设置为‘0’,以上错误。通过创建pfile.ora文件,然后在文件里删除两个参数"MEMORY_TARGET/MEMORY_MAX_TARGET"。然后再创建spfile就可以了。

9. 查询memory_max_target,发现没有设置成功                  

 
 
  1. [oracle@OEL tmp]$ sqlplus / as sysasm 
  2.  
  3. SQL> startup mount pfile='/tmp/asmxx'
  4.  
  5. SQL> show parameter memory 
  6.  
  7. NAME                                 TYPE        VALUE 
  8.  
  9. ------------------------------------ ----------- ------------------------------ 
  10.  
  11. memory_max_target                    big integer 388M 
  12.  
  13. memory_target                        big integer 0 

10. 再次查询Hugepages确认,只要AMM使用,Hugepage设置就不会生效

 
 
  1. [oracle@OEL tmp]$ more /proc/meminfo|grep Hug 
  2.  
  3. HugePages_Total:     700 
  4.  
  5. HugePages_Free:      700 
  6.  
  7. HugePages_Rsvd:        0 
  8.  
  9. HugePages_Surp:        0 
  10.  
  11. Hugepagesize:       2048 kB 

11. 启动DB实例后,由于memory_max_target已经禁用,可以看到Hugepage设置已经生效,

 
 
  1. [oracle@OEL tmp]$ more /proc/meminfo|grep Hug 
  2.  
  3. HugePages_Total:     700 
  4.  
  5. HugePages_Free:      630 
  6.  
  7. HugePages_Rsvd:      181 
  8.  
  9. HugePages_Surp:        0 
  10.  
  11. Hugepagesize:       2048 kB 

测试结论,如果使用Hugepages,就必须禁用memory_max_target和memory_target参数。

 

三、Hugepages size是需要大于sga_max_size才生效,还是大于sga_target 就满足条件呢?

    下面测试,前面有提到hugepages size要大于全部SGA size,但是这里有个疑问,SGA size是根据sga_max_size还是sga_target呢?下面的测试就会得出结论    

1. 设置  sga_max_size =1104M,sga_target=512M                                   

 
 
  1. [oracle@OEL ~]$ sqlplus / as sysdba 
  2.  
  3. SQL> show parameter sga 
  4.  
  5. NAME                                 TYPE        VALUE 
  6.  
  7. ------------------------------------ ----------- ------------------------------ 
  8.  
  9. lock_sga                                boolean     FALSE 
  10.  
  11. pre_page_sga                         boolean     FALSE 
  12.  
  13. sga_max_size                         big integer 1104M 
  14.  
  15. sga_target                              big integer 512M 

2. 查询确认Hugepages已经被使用 

 
 
  1. [oracle@OEL tmp]$ more /proc/meminfo|grep Hug 
  2.  
  3. HugePages_Total:     700 
  4.  
  5. HugePages_Free:      616 
  6.  
  7. HugePages_Rsvd:      469 
  8.  
  9. HugePages_Surp:        0 
  10.  
  11. Hugepagesize:       2048 kB 

3. 设置  sga_max_size =1600M,sga_target=512M 

 
 
  1. SQL> startup nomount pfile='/tmp/liangxx'
  2.  
  3. [oracle@OEL ~]$ sqlplus / as sysdba 
  4.  
  5. SQL> show parameter sga 
  6.  
  7. NAME                                 TYPE        VALUE 
  8.  
  9. ------------------------------------ ----------- ------------------------------ 
  10.  
  11. lock_sga                             boolean     FALSE 
  12.  
  13. pre_page_sga                         boolean     FALSE 
  14.  
  15. sga_max_size                         big integer 1600M                   <<<<<<<是否使用Hugepage取决于sga_max_size,而不是sga_target 
  16.  
  17. sga_target                           big integer 512M 

4. 查询,hugepages没有生效,

 
 
  1. [oracle@OEL ~]$ more /proc/meminfo|grep Hug 
  2.  
  3. HugePages_Total:     700 
  4.  
  5. HugePages_Free:      700 
  6.  
  7. HugePages_Rsvd:        0 
  8.  
  9. HugePages_Surp:        0 
  10.  
  11. Hugepagesize:       2048 kB 

5. 设置sga_max_size=700M

 

 
 
  1. SQL> startup nomount pfile='/tmp/liangxx'
  2.  
  3. SQL> show parameter sga 
  4.  
  5. NAME                                 TYPE        VALUE 
  6.  
  7. ------------------------------------ ----------- ------------------------------ 
  8.  
  9. lock_sga                             boolean     FALSE 
  10.  
  11. pre_page_sga                         boolean     FALSE 
  12.  
  13. sga_max_size                         big integer 700M 
  14.  
  15. sga_target                           big integer 500M 

6. 发现HugePages又使用上了

 
 
  1. [oracle@OEL ~]$ more /proc/meminfo|grep Hug 
  2.  
  3. HugePages_Total:     700 
  4.  
  5. HugePages_Free:      548 
  6.  
  7. HugePages_Rsvd:      199 
  8.  
  9. HugePages_Surp:        0 
  10.  
  11. Hugepagesize:       2048 kB 

这里说明,是否使用hugepages取决于sga_max_size的尺寸,而不是sga_target。  

 

四、问题延伸

1. 通过查询共享内存,引出一个新问题,DB使用了Hugepage后,通过 pmap 8863|grep sh 就不能列出sh的共享值了,而是以/SYSV6010c970 (deleted) 的形式出现。

 
 
  1. [oracle@OEL tmp]$ ps -ef|grep pmon 
  2.  
  3. oracle    8464     1  0 19:34 ?        00:00:00 asm_pmon_+ASM 
  4.  
  5. oracle    8863     1  0 19:42 ?        00:00:00 ora_pmon_db 
  6.  
  7. oracle    8957  6753  0 19:43 pts/1    00:00:00 grep pmon 
  8.  
  9. [oracle@OEL tmp]$ pmap 8863|grep sh           <<<<<<<在DB使用了Hugepage后,通过ps就不能列出sh的共享值了 
  10.  
  11. [oracle@OEL tmp]$ pmap 8863                      <<<<<<<直接列出全部 
  12.  
  13. 8863:   ora_pmon_db 
  14.  
  15. 0000000000400000 155140K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/bin/oracle 
  16.  
  17. 0000000009d81000  12404K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/bin/oracle 
  18.  
  19. 000000000a99e000    280K rwx--    [ anon ] 
  20.  
  21. 000000000b148000    724K rwx--    [ anon ] 
  22.  
  23. 0000000060000000 514048K rwxs-  /SYSV6010c970 (deleted)              <<<<<<<这里很可疑,因为DB SGA_TARGET就是500M 
  24.  
  25. 00000032f7e00000    112K r-x--  /lib64/ld-2.5.so 
  26.  
  27. 00000032f801c000      4K r-x--  /lib64/ld-2.5.so 
  28.  
  29. 00000032f801d000      4K rwx--  /lib64/ld-2.5.so 
  30.  
  31. 00000032f8200000   1340K r-x--  /lib64/libc-2.5.so 
  32.  
  33. 00000032f834f000   2044K -----  /lib64/libc-2.5.so 
  34.  
  35. 00000032f854e000     16K r-x--  /lib64/libc-2.5.so 
  36.  
  37. 00000032f8552000      4K rwx--  /lib64/libc-2.5.so 
  38.  
  39. 00000032f8553000     20K rwx--    [ anon ] 
  40.  
  41. 00000032f8600000    520K r-x--  /lib64/libm-2.5.so 
  42.  
  43. 00000032f8682000   2044K -----  /lib64/libm-2.5.so 
  44.  
  45. 00000032f8881000      4K r-x--  /lib64/libm-2.5.so 
  46.  
  47. 00000032f8882000      4K rwx--  /lib64/libm-2.5.so 
  48.  
  49. 00000032f8e00000      8K r-x--  /lib64/libdl-2.5.so 
  50.  
  51. 00000032f8e02000   2048K -----  /lib64/libdl-2.5.so 
  52.  
  53. 00000032f9002000      4K r-x--  /lib64/libdl-2.5.so 
  54.  
  55. 00000032f9003000      4K rwx--  /lib64/libdl-2.5.so 
  56.  
  57. 00000032f9200000     88K r-x--  /lib64/libpthread-2.5.so 
  58.  
  59. 00000032f9216000   2044K -----  /lib64/libpthread-2.5.so 
  60.  
  61. 00000032f9415000      4K r-x--  /lib64/libpthread-2.5.so 
  62.  
  63. 00000032f9416000      4K rwx--  /lib64/libpthread-2.5.so 
  64.  
  65. 00000032f9417000     16K rwx--    [ anon ] 
  66.  
  67. 00000032f9600000     28K r-x--  /lib64/librt-2.5.so 
  68.  
  69. 00000032f9607000   2048K -----  /lib64/librt-2.5.so 
  70.  
  71. 00000032f9807000      4K r-x--  /lib64/librt-2.5.so 
  72.  
  73. 00000032f9808000      4K rwx--  /lib64/librt-2.5.so 
  74.  
  75. 00000032fbe00000     84K r-x--  /lib64/libnsl-2.5.so 
  76.  
  77. 00000032fbe15000   2044K -----  /lib64/libnsl-2.5.so 
  78.  
  79. 00000032fc014000      4K r-x--  /lib64/libnsl-2.5.so 
  80.  
  81. 00000032fc015000      4K rwx--  /lib64/libnsl-2.5.so 
  82.  
  83. 00000032fc016000      8K rwx--    [ anon ] 
  84.  
  85. 00007faf908ab000    912K rwx--    [ anon ] 
  86.  
  87. 00007faf9098f000     40K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnque11.so 
  88.  
  89. 00007faf90999000   1020K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnque11.so 
  90.  
  91. 00007faf90a98000      4K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnque11.so 
  92.  
  93. 00007faf90a99000      4K rwx--    [ anon ] 
  94.  
  95. 00007faf90a9a000     88K rwx--  /dev/zero 
  96.  
  97. 00007faf90ab0000     64K rwx--  /dev/zero 
  98.  
  99. 00007faf90ac0000     64K rwx--  /dev/zero 
  100.  
  101. 00007faf90ad0000     64K rwx--  /dev/zero 
  102.  
  103. 00007faf90ae0000     64K rwx--  /dev/zero 
  104.  
  105. 00007faf90af0000    168K rwx--  /dev/zero 
  106.  
  107. 00007faf90b1a000   1700K rwx--    [ anon ] 
  108.  
  109. 00007faf90cc3000     40K r-x--  /lib64/libnss_files-2.5.so 
  110.  
  111. 00007faf90ccd000   2044K -----  /lib64/libnss_files-2.5.so 
  112.  
  113. 00007faf90ecc000      4K r-x--  /lib64/libnss_files-2.5.so 
  114.  
  115. 00007faf90ecd000      4K rwx--  /lib64/libnss_files-2.5.so 
  116.  
  117. 00007faf90ece000    272K rwx--    [ anon ] 
  118.  
  119. 00007faf90f12000      4K r-x--  /usr/lib64/libaio.so.1.0.1 
  120.  
  121. 00007faf90f13000   2044K -----  /usr/lib64/libaio.so.1.0.1 
  122.  
  123. 00007faf91112000      4K rwx--  /usr/lib64/libaio.so.1.0.1 
  124.  
  125. 00007faf91113000      4K rwx--    [ anon ] 
  126.  
  127. 00007faf91114000    444K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libasmclnt11.so 
  128.  
  129. 00007faf91183000   1024K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libasmclnt11.so 
  130.  
  131. 00007faf91283000     72K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libasmclnt11.so 
  132.  
  133. 00007faf91295000      4K rwx--    [ anon ] 
  134.  
  135. 00007faf91296000     44K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocrutl11.so 
  136.  
  137. 00007faf912a1000   1020K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocrutl11.so 
  138.  
  139. 00007faf913a0000      4K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocrutl11.so 
  140.  
  141. 00007faf913a1000    608K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocrb11.so 
  142.  
  143. 00007faf91439000   1024K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocrb11.so 
  144.  
  145. 00007faf91539000      8K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocrb11.so 
  146.  
  147. 00007faf9153b000      4K rwx--    [ anon ] 
  148.  
  149. 00007faf9153c000    612K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocr11.so 
  150.  
  151. 00007faf915d5000   1020K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocr11.so 
  152.  
  153. 00007faf916d4000      8K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libocr11.so 
  154.  
  155. 00007faf916d6000      8K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libskgxn2.so 
  156.  
  157. 00007faf916d8000   1020K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libskgxn2.so 
  158.  
  159. 00007faf917d7000      4K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libskgxn2.so 
  160.  
  161. 00007faf917d8000   4256K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libhasgen11.so 
  162.  
  163. 00007faf91c00000   1024K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libhasgen11.so 
  164.  
  165. 00007faf91d00000     72K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libhasgen11.so 
  166.  
  167. 00007faf91d12000     20K rwx--    [ anon ] 
  168.  
  169. 00007faf91d17000    136K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libdbcfg11.so 
  170.  
  171. 00007faf91d39000   1020K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libdbcfg11.so 
  172.  
  173. 00007faf91e38000      8K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libdbcfg11.so 
  174.  
  175. 00007faf91e3a000     92K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclsra11.so 
  176.  
  177. 00007faf91e51000   1024K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclsra11.so 
  178.  
  179. 00007faf91f51000      4K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclsra11.so 
  180.  
  181. 00007faf91f52000   2580K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnnz11.so 
  182.  
  183. 00007faf921d7000   1020K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnnz11.so 
  184.  
  185. 00007faf922d6000    268K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnnz11.so 
  186.  
  187. 00007faf92319000      8K rwx--    [ anon ] 
  188.  
  189. 00007faf92326000      4K rwxs-  /u01/app/oracle/product/11.2.0/dbhome_1/dbs/hc_db.dat 
  190.  
  191. 00007faf92327000     16K rwx--    [ anon ] 
  192.  
  193. 00007faf9232b000    732K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libskgxp11.so 
  194.  
  195. 00007faf923e2000   1024K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libskgxp11.so 
  196.  
  197. 00007faf924e2000      8K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libskgxp11.so 
  198.  
  199. 00007faf924e4000    316K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libcell11.so 
  200.  
  201. 00007faf92533000   1020K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libcell11.so 
  202.  
  203. 00007faf92632000     32K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libcell11.so 
  204.  
  205. 00007faf9263a000      4K rwx--    [ anon ] 
  206.  
  207. 00007faf9263b000      4K r-x--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libodmd11.so 
  208.  
  209. 00007faf9263c000   1024K -----  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libodmd11.so 
  210.  
  211. 00007faf9273c000      4K rwx--  /u01/app/oracle/product/11.2.0/dbhome_1/lib/libodmd11.so 
  212.  
  213. 00007faf9273d000      8K rwx--    [ anon ] 
  214.  
  215. 00007fff37756000     84K rwx--    [ stack ] 
  216.  
  217. 00007fff377ff000      4K r-x--    [ anon ] 
  218.  
  219. ffffffffff600000      4K r-x--    [ anon ] 
  220.  
  221. total           728520K 

2. 查看文件系统,/dev/shm有被使用

 
 
  1. [oracle@OEL ~]$ df -h 
  2.  
  3. Filesystem            Size  Used Avail Use% Mounted on 
  4.  
  5. /dev/mapper/VolGroup00-LogVol00 
  6.  
  7.                       6.8G  2.7G  3.8G  41% / 
  8.  
  9. /dev/sda1              99M   24M   71M  25% /boot 
  10.  
  11. tmpfs                 1.5G   75M  1.4G   6% /dev/shm 
  12.  
  13. /dev/sdo1             9.9G  7.3G  2.1G  79% /u01 

3. 这里发现另外一个不同的地方,就是oracle用户的bytes值

 
 
  1. [oracle@OEL shm]$ ipcs -m 
  2.  
  3. ------ Shared Memory Segments -------- 
  4.  
  5. key        shmid      owner      perms      bytes      nattch     status     
  6.  
  7. 0x00000000 3538944    root      644        80         2                      
  8.  
  9. 0x00000000 3571713    root      644        16384      2                      
  10.  
  11. 0x00000000 3604482    root      644        280        2                      
  12.  
  13. 0xa3c20e68 4030468    oracle    660        4096       0              <<<<<<<<<<<ASM实例没有使用Hugepage,还是4096,同时也 能通过pmap查询到 
  14.  
  15. 0x6010c970 4390917    oracle    660        736100352  20             <<<<<<<<<<<在不是用Hugepage的时候,这里是4096,但是现在 显示的实际的值 

   通过测试,意外发现,在使用Hugepags前后,SGA的共享内存在OS系统上是以不同的形态存在的。经过网络搜索,发现/dev/shm是否使用是与AMM相关的,后续再单独测试并更新一篇博客










本文转自 hsbxxl 51CTO博客,原文链接:http://blog.51cto.com/hsbxxl/1076712,如需转载请自行联系原作者

目录
相关文章
|
1月前
Mybatis+mysql动态分页查询数据案例——测试类HouseDaoMybatisImplTest)
Mybatis+mysql动态分页查询数据案例——测试类HouseDaoMybatisImplTest)
21 1
|
1月前
|
Java 关系型数据库 数据库连接
Mybatis+MySQL动态分页查询数据经典案例(含代码以及测试)
Mybatis+MySQL动态分页查询数据经典案例(含代码以及测试)
26 1
|
4月前
|
Java 编译器
Java注解案例-简单测试框架
Java注解案例-简单测试框架
25 0
|
7月前
|
SQL 安全 网络安全
交易所开发测试版丨交易所系统开发规则玩法/架构设计/项目步骤/方案逻辑/案例解析/源码部署
The development process of the exchange system involves multiple steps and links. The following is the detailed process and steps for the development of the exchange system:
|
3天前
|
分布式计算 Hadoop Scala
Spark【环境搭建 01】spark-3.0.0-without 单机版(安装+配置+测试案例)
【4月更文挑战第13天】Spark【环境搭建 01】spark-3.0.0-without 单机版(安装+配置+测试案例)
8 0
|
1月前
|
Java 数据库连接 mybatis
mybatis简单案例源码详细【注释全面】——测试层(UserMapperTest.java)
mybatis简单案例源码详细【注释全面】——测试层(UserMapperTest.java)
9 0
|
2月前
|
人工智能 安全
外汇MT5/MT4交易所平台系统开发测试版/案例设计/策略步骤/功能需求/源码程序
When developing the MT5/MT4 foreign exchange documentary trading system, the following functions and intelligence can also be considered:
|
7月前
|
测试技术
软件测试高频面试题“黑盒测试之正交试验法”案例剖析与实践应用
软件测试高频面试题“黑盒测试之正交试验法”案例剖析与实践应用
344 0
|
6月前
24Redis - 事务测试案例
24Redis - 事务测试案例
34 0
|
6月前
|
运维 测试技术 区块链
链动2+1模式系统开发指南流程丨成熟案例丨功能设计丨测试部署丨方案项目丨逻辑需求丨源码出售
链动2+1模式系统开发方案是指一个较为复杂的系统开发模式,其中包含两个公链和一个私链的组合。

热门文章

最新文章