[20190321]smem的显示缺陷.txt

[20190321]smem的显示缺陷.txt

1.smem 加入-m参数显示存在缺陷,map的信息不全:

# smem -tk -m -U oracle -P "oraclepeis|ora_"
Map                                       PIDs   AVGPSS      PSS
/u01/app/oracle/product/10.2.0/db_1/dbs/    15        0        0
[vdso]                                     308        0        0
[vsyscall]                                 308        0        0
/lib64/libaio.so.1.0.1                     308     3.0K     1.1M
/lib64/libnsl-2.12.so                      308     7.0K     2.1M
/lib64/ld-2.12.so                          308     7.0K     2.1M
/u01/app/oracle/product/10.2.0/db_1/lib/   308     7.0K     2.1M
/u01/app/oracle/product/10.2.0/db_1/lib/   308     7.0K     2.1M
/lib64/libdl-2.12.so                       308     7.0K     2.1M
/lib64/libnss_files-2.12.so                308     7.0K     2.2M
/lib64/libpthread-2.12.so                  308     7.0K     2.2M
/lib64/libm-2.12.so                        308     7.0K     2.3M
/lib64/libc-2.12.so                        308    12.0K     3.7M
/u01/app/oracle/product/10.2.0/db_1/lib/   308    14.0K     4.2M
/u01/app/oracle/product/10.2.0/db_1/lib/   308    21.0K     6.5M
/u01/app/oracle/product/10.2.0/db_1/lib/   308    21.0K     6.5M
/u01/app/oracle/product/10.2.0/db_1/lib/   308    32.0K     9.7M
/u01/app/oracle/product/10.2.0/db_1/lib/   308    56.0K    17.1M
[stack]                                    308    80.0K    24.1M
/u01/app/oracle/product/10.2.0/db_1/lib/   308   103.0K    31.2M
/u01/app/oracle/product/10.2.0/db_1/bin/   308   127.0K    38.3M
<anonymous>                                308   242.0K    72.8M
[heap]                                     308   466.0K   140.5M
/dev/zero                                  308   561.0K   168.9M
/u01/app/oracle/product/10.2.0/db_1/lib/   308   589.0K   177.4M
/u01/app/oracle/product/10.2.0/db_1/lib/   308     1.4M   417.1M
/SYSV94f021f8                              308     2.8M   876.1M
-----------------------------------------------------------------
27                                        8023     6.5M     2.0G

--//Map部分显示宽度不足.可以加宽到80.很容易修改python的脚本,我不懂python,看一下源代码就可以了.
--//修改前注意备份!!

# diff -Nur  smem.ORG smem
--- smem.ORG    2019-03-21 11:18:59.117243470 +0800
+++ smem        2013-03-28 11:01:07.000000000 +0800
@@ -330,7 +330,7 @@
     pt = maptotals(p)

     fields = dict(
-        map=('Map', lambda n: n, '%-80.80s', len,
+        map=('Map', lambda n: n, '%-40.40s', len,
              'mapping name'),
         count=('Count', lambda n: pt[n]['count'], '% 5s', sum,
                'number of mappings found'),

# smem.ORG -tk -m -U oracle -P "oraclepeis|ora_"
Map                                                                               PIDs   AVGPSS      PSS
/u01/app/oracle/product/10.2.0/db_1/dbs/hc_peis.dat                                 15        0        0
[vdso]                                                                             151        0        0
[vsyscall]                                                                         151        0        0
/lib64/libaio.so.1.0.1                                                             151     3.0K   588.0K
/u01/app/oracle/product/10.2.0/db_1/lib/libclsra10.so                              151     7.0K     1.1M
/lib64/libnsl-2.12.so                                                              151     7.0K     1.1M
/lib64/libnss_files-2.12.so                                                        151     7.0K     1.1M
/u01/app/oracle/product/10.2.0/db_1/lib/libskgxn2.so                               151     7.0K     1.1M
/lib64/libdl-2.12.so                                                               151     7.0K     1.1M
/lib64/ld-2.12.so                                                                  151     7.0K     1.1M
/lib64/libpthread-2.12.so                                                          151     7.0K     1.1M
/lib64/libm-2.12.so                                                                151     8.0K     1.2M
/lib64/libc-2.12.so                                                                151    14.0K     2.2M
/u01/app/oracle/product/10.2.0/db_1/lib/libdbcfg10.so                              151    15.0K     2.2M
/u01/app/oracle/product/10.2.0/db_1/lib/libocrb10.so                               151    22.0K     3.4M
/u01/app/oracle/product/10.2.0/db_1/lib/libskgxp10.so                              151    22.0K     3.4M
/u01/app/oracle/product/10.2.0/db_1/lib/libocr10.so                                151    34.0K     5.0M
/u01/app/oracle/product/10.2.0/db_1/lib/libocrutl10.so                             151    61.0K     9.0M
[stack]                                                                            151    97.0K    14.4M
/u01/app/oracle/product/10.2.0/db_1/lib/libhasgen10.so                             151   110.0K    16.3M
/u01/app/oracle/product/10.2.0/db_1/bin/oracle                                     151   222.0K    32.8M
<anonymous>                                                                        151   265.0K    39.2M
[heap]                                                                             151   488.0K    72.0M
/u01/app/oracle/product/10.2.0/db_1/lib/libnnz10.so                                151   640.0K    94.4M
/dev/zero                                                                          151   950.0K   140.1M
/u01/app/oracle/product/10.2.0/db_1/lib/libjox10.so                                151     1.5M   221.0M
/SYSV94f021f8                                                                      151     5.8M   880.7M
---------------------------------------------------------------------------------------------------------
27                                                                                3941    10.2M     1.5G

--//PIDS表示查询的进程数量,它是将PSS平均分摊到各个用户.
--//SYSV94f021f8表示共享内存段.

# ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x94f021f8 32768      oracle     640        1176502272 151
              
--//key=0x94f021f8,不过后面的PSS如果计算的不是很清楚感觉应该是1176502272/1024/1024 = 1122M.难道不过全部加载吗?
--//nattch表示连接使用共享内存段的进程数.正好151可以与smem显示的PIDS对上.不再生产系统折腾,换测试机器测试.

2.测试环境:

# smem -tk -m -U oracle -P "oraclebook|ora_"
Map                                                                               PIDs   AVGPSS      PSS
/SYSV00000000                                                                       26        0        0
/SYSVe8a8ec10                                                                       26        0        0
/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/hc_book.dat                           21        0        0
[vdso]                                                                              26        0        0
[vsyscall]                                                                          26        0        0
/lib64/libnss_dns-2.5.so                                                             1    24.0K    24.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnque11.so                           6     5.0K    30.0K
/lib64/libresolv-2.5.so                                                              1    35.0K    35.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclsra11.so                         26     4.0K   104.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocrutl11.so                        26     4.0K   104.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libskgxn2.so                          26     4.0K   104.0K
/usr/lib64/libaio.so.1.0.1                                                          26     4.0K   104.0K
/usr/lib64/libnuma.so.1                                                             26     4.0K   104.0K
/lib64/libdl-2.5.so                                                                 26     8.0K   208.0K
/lib64/libnsl-2.5.so                                                                26     8.0K   208.0K
/lib64/librt-2.5.so                                                                 26     8.0K   208.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libdbcfg11.so                         26     8.0K   208.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnfsodm11.so                        26     8.0K   208.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libskgxp11.so                         26     8.0K   208.0K
/lib64/libnss_files-2.5.so                                                          26     8.0K   212.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocrb11.so                          26     9.0K   234.0K
/lib64/libpthread-2.5.so                                                            26     9.0K   237.0K
/lib64/ld-2.5.so                                                                    26    10.0K   260.0K
/lib64/libm-2.5.so                                                                  26    12.0K   328.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocr11.so                           26    14.0K   364.0K
/lib64/libc-2.5.so                                                                  26    22.0K   581.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libcell11.so                          26    69.0K     1.8M
[stack]                                                                             26    82.0K     2.1M
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libhasgen11.so                        26   162.0K     4.1M
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnnz11.so                           26   231.0K     5.9M
[heap]                                                                              26   418.0K    10.6M
/dev/zero                                                                           26   793.0K    20.1M
/u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle                                26     1.3M    35.1M
<anonymous>                                                                         26     1.6M    42.4M
---------------------------------------------------------------------------------------------------------
34                                                                                 809     4.9M   126.1M
--//奇怪在共享内存段使用0.

# ipcs -m
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000000 349011969  oracle    640        12582912   26
0x00000000 349044738  oracle    640        633339904  26
0xe8a8ec10 349077507  oracle    640        2097152    26

3.关闭hugepages看看.
vm.nr_hugepages = 0
vm.nr_overcommit_hugepages = 0

# grep -i page /proc/meminfo
AnonPages:        249336 kB
PageTables:        18228 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB

# ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000000 349208577  oracle    640        12582912   22
0x00000000 349241346  oracle    640        633339904  22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0xe8a8ec10 349274115  oracle    640        2097152    22

# smem -tk -m -U oracle -P "oraclebook|ora_"
Map                                                                               PIDs   AVGPSS      PSS
/SYSVe8a8ec10                                                                       22        0        0
/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/hc_book.dat                           20        0        0
[vdso]                                                                              22        0        0
[vsyscall]                                                                          22        0        0
/lib64/libnss_dns-2.5.so                                                             1    24.0K    24.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnque11.so                           4     6.0K    24.0K
/lib64/libresolv-2.5.so                                                              1    35.0K    35.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclsra11.so                         22     4.0K    88.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocrutl11.so                        22     4.0K    88.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libskgxn2.so                          22     4.0K    88.0K
/usr/lib64/libaio.so.1.0.1                                                          22     4.0K    88.0K
/usr/lib64/libnuma.so.1                                                             22     4.0K    88.0K
/lib64/libdl-2.5.so                                                                 22     8.0K   176.0K
/lib64/libnsl-2.5.so                                                                22     8.0K   176.0K
/lib64/librt-2.5.so                                                                 22     8.0K   176.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libdbcfg11.so                         22     8.0K   176.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnfsodm11.so                        22     8.0K   176.0K
/lib64/libnss_files-2.5.so                                                          22     8.0K   179.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocrb11.so                          22     9.0K   198.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libskgxp11.so                         22     9.0K   198.0K
/lib64/libpthread-2.5.so                                                            22     9.0K   200.0K
/lib64/ld-2.5.so                                                                    22    10.0K   220.0K
/lib64/libm-2.5.so                                                                  22    12.0K   281.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocr11.so                           22    14.0K   308.0K
/lib64/libc-2.5.so                                                                  22    22.0K   492.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libcell11.so                          22    70.0K     1.5M
[stack]                                                                             22    73.0K     1.6M
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libhasgen11.so                        22   166.0K     3.6M
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnnz11.so                           22   232.0K     5.0M
[heap]                                                                              22   420.0K     9.0M
/dev/zero                                                                           22   572.0K    12.3M
/u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle                                22     1.6M    34.4M
<anonymous>                                                                         22     1.8M    38.6M
/SYSV00000000                                                                       22     4.0M    88.6M
---------------------------------------------------------------------------------------------------------
34                                                                                 686     9.1M   198.0M

--///SYSV00000000那行PSS=88.6M.
SYS@book> select /*+ full(A) */ count(*) from sh.sales a;
  COUNT(*)
----------
    918843

[root@gxqyydg4 IP=100.78 /etc ] # smem -tk -m -U oracle -P "oraclebook|ora_"
Map                                                                               PIDs   AVGPSS      PSS
/SYSVe8a8ec10                                                                       22        0        0
/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/hc_book.dat                           20        0        0
[vdso]                                                                              22        0        0
[vsyscall]                                                                          22        0        0
/lib64/libnss_dns-2.5.so                                                             1    24.0K    24.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnque11.so                           4     6.0K    24.0K
/lib64/libresolv-2.5.so                                                              1    35.0K    35.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclsra11.so                         22     4.0K    88.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocrutl11.so                        22     4.0K    88.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libskgxn2.so                          22     4.0K    88.0K
/usr/lib64/libaio.so.1.0.1                                                          22     4.0K    88.0K
/usr/lib64/libnuma.so.1                                                             22     4.0K    88.0K
/lib64/libdl-2.5.so                                                                 22     8.0K   176.0K
/lib64/libnsl-2.5.so                                                                22     8.0K   176.0K
/lib64/librt-2.5.so                                                                 22     8.0K   176.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libdbcfg11.so                         22     8.0K   176.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnfsodm11.so                        22     8.0K   176.0K
/lib64/libnss_files-2.5.so                                                          22     8.0K   179.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocrb11.so                          22     9.0K   198.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libskgxp11.so                         22     9.0K   198.0K
/lib64/libpthread-2.5.so                                                            22     9.0K   200.0K
/lib64/ld-2.5.so                                                                    22    10.0K   220.0K
/lib64/libm-2.5.so                                                                  22    12.0K   282.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocr11.so                           22    14.0K   308.0K
/lib64/libc-2.5.so                                                                  22    22.0K   492.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libcell11.so                          22    70.0K     1.5M
[stack]                                                                             22    76.0K     1.6M
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libhasgen11.so                        22   166.0K     3.6M
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnnz11.so                           22   232.0K     5.0M
[heap]                                                                              22   420.0K     9.0M
/dev/zero                                                                           22   642.0K    13.8M
/u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle                                22     1.6M    35.0M
<anonymous>                                                                         22     1.8M    38.7M
/SYSV00000000                                                                       24     6.0M   143.7M
---------------------------------------------------------------------------------------------------------
34                                                                                 747    11.0M   262.4M
--///SYSV00000000那行PSS=143.7M.说明共享内存的分配可以动态变化.

4.关闭hugepages以及设置参数pre_page_sga=true:

# smem -tk -m -U oracle -P "oraclebook|ora_"
Map                                                                               PIDs   AVGPSS      PSS
/SYSVe8a8ec10                                                                       22        0        0
/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/hc_book.dat                           20        0        0
[vdso]                                                                              22        0        0
[vsyscall]                                                                          22        0        0
/lib64/libnss_dns-2.5.so                                                             1    24.0K    24.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnque11.so                           4     6.0K    24.0K
/lib64/libresolv-2.5.so                                                              1    35.0K    35.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclsra11.so                         22     4.0K    88.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocrutl11.so                        22     4.0K    88.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libskgxn2.so                          22     4.0K    88.0K
/usr/lib64/libaio.so.1.0.1                                                          22     4.0K    88.0K
/usr/lib64/libnuma.so.1                                                             22     4.0K    88.0K
/lib64/libdl-2.5.so                                                                 22     8.0K   176.0K
/lib64/libnsl-2.5.so                                                                22     8.0K   176.0K
/lib64/librt-2.5.so                                                                 22     8.0K   176.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libdbcfg11.so                         22     8.0K   176.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnfsodm11.so                        22     8.0K   176.0K
/lib64/libnss_files-2.5.so                                                          22     8.0K   179.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocrb11.so                          22     9.0K   198.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libskgxp11.so                         22     9.0K   198.0K
/lib64/libpthread-2.5.so                                                            22     9.0K   200.0K
/lib64/ld-2.5.so                                                                    22    10.0K   220.0K
/lib64/libm-2.5.so                                                                  22    12.0K   281.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libocr11.so                           22    14.0K   308.0K
/lib64/libc-2.5.so                                                                  22    22.0K   492.0K
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libcell11.so                          22    70.0K     1.5M
[stack]                                                                             22    72.0K     1.5M
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libhasgen11.so                        22   166.0K     3.6M
/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libnnz11.so                           22   232.0K     5.0M
[heap]                                                                              22   420.0K     9.0M
/dev/zero                                                                           22   589.0K    12.7M
/u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle                                22     1.6M    34.4M
<anonymous>                                                                         22     1.8M    38.6M
/SYSV00000000                                                                       22    27.8M   611.5M
---------------------------------------------------------------------------------------------------------
34                                                                                 686    32.8M   721.2M

--//设置pre_page_sga=true,表示启动数据库全部加载整个SGA到内存.
--//633339904/1024/1024 = 604M
--//其实这样后面的PSS内存总和基本表示这个实例使用的内存量.

--//看看官方的定义:
http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams201.htm#REFRN10174

PRE_PAGE_SGA determines whether Oracle reads the entire SGA into memory at instance startup. Operating system page table
entries are then prebuilt for each page of the SGA. This setting can increase the amount of time necessary for instance
startup, but it is likely to decrease the amount of time necessary for Oracle to reach its full performance capacity
after startup.

--//我看了几台机器,使用hugepages,map对应是共享内存段的都是0,对于这些不熟悉.^_^.

posted @ 2019-03-21 16:07 lfree 阅读(...) 评论(...) 编辑 收藏