1. 首页
  2. IT资讯

[20191223]关于共享内存段相关问题3.txt

[20191223]关于共享内存段相关问题3.txt

–//我一直很好奇如果设置内核参数kernel.shmmax = 68719476736足够大,为什么我的测试实例还是建立3个共享内存段.
–//最后1个很特殊key=0xe8a8ec10,大小2M,我看过许多服务器只要key<>=0x00000000,最后都会有1个2M的共享内存段.
–//上个星期链接http://blog.itpub.net/267265/viewspace-2669718/=>[20191220]关于共享内存段相关问题.txt
–//实际上已经给出答案,我没有写清楚.主要不好表达.

–//oracle启动建立的第1个共享内存段主要包括Fixed SGA Size +Redo Buffers.
–//oracle启动建立的第2个共享内存段主要包括buffer cache,java pool,large pool,shared pool.

–//如何验证log buffer在第1个共享内存段呢?

1.环境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
—————————— ————– ——————————————————————————–
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production

2.看看log_buffer在哪里.
$ ipcs -m
—— Shared Memory Segments ——–
key        shmid      owner      perms      bytes      nattch     status
0x00000000 451674112  oracle    640        12582912   27
0x00000000 451706881  oracle    640        633339904  27
0xe8a8ec10 451739650  oracle    640        2097152    27

$ ipcs -m | awk '{print $5/1024/1024}' | grep -v "^0"
12
604
2

$ cat memalloc.sql
col component format a32
select min(BASEADDR), max(BASEADDR), count(1) Granules, sum(a.gransize)/1048576 MB, a.GRANFLAGS, component, a.GRANSTATE
from x$ksmge a, x$kmgsct b
where a.grantype = b.grantype (+)
group by a.GRANFLAGS, component, a.GRANSTATE
order by 1,2;

pause press enter …..

select a.BASEADDR, a.gransize, a.GRANFLAGS, b.component, a.GRANSTATE
from x$ksmge a, x$kmgsct b
where a.grantype = b.grantype (+)
order by 1,2;

SYS@book> @ memalloc
MIN(BASEADDR)    MAX(BASEADDR)      GRANULES         MB  GRANFLAGS COMPONENT                        GRANSTATE
—————- —————- ———- ———- ———- ——————————– —————-
0000000060C00000 0000000061C00000          5         20          4 streams pool                     ALLOC
0000000062000000 0000000086400000         48        192          4 shared pool                      ALLOC
0000000063400000 000000007A000000         92        368          4 DEFAULT buffer cache             ALLOC
000000007A400000 000000007AC00000          3         12          4 java pool                        ALLOC
000000007B000000 000000007B800000          3         12          4 large pool                       ALLOC
press enter …..
–//后面一段太长,不贴上来了.

$ cat imu.sql
 $ cat imu.sql
SELECT INDX
      ,FIRST_BUF_KCRFA
      ,last_buf_kcrfa
      ,PNEXT_BUF_KCRFA_CLN nxtbufadr
      ,NEXT_BUF_NUM_KCRFA_CLN nxtbuf#
      ,BYTES_IN_BUF_KCRFA_CLN "B/buf"
      ,PVT_STRAND_STATE_KCRFA_CLN state
      ,STRAND_NUM_ORDINAL_KCRFA_CLN strand#
      ,PTR_KCRF_PVT_STRAND stradr
      ,INDEX_KCRF_PVT_STRAND stridx
      ,SPACE_KCRF_PVT_STRAND strspc
      ,TXN_KCRF_PVT_STRAND txn
      ,TOTAL_BUFS_KCRFA totbufs#
      ,STRAND_SIZE_KCRFA strsz
  FROM X$KCRFSTRAND ;

SYS@book> @ imu
      INDX FIRST_BUF_KCRFA  LAST_BUF_KCRFA   NXTBUFADR           NXTBUF#      B/buf      STATE    STRAND# STRADR               STRIDX     STRSPC        TXN   TOTBUFS#      STRSZ
———- —————- —————- —————- ———- ———- ———- ———- —————- ———- ———- ———- ———- ———-
         0 0000000060227000 0000000060590E00 000000006050E800       5947          0          0 3735928559 00                        0          0          0       6992    3579904
         1 0000000060591000 00000000608FAE00 0000000060592C00         13          0          0 3735928559 00                        0          0          0       6992    3579904
         2 0000000081E27000 00               00                        0          0          0 3735928559 0000000081E27054 3735928559     126464          0        249     132096
         3 0000000081E49000 00               00                        0          0          0 3735928559 0000000081E49054 3735928559     126464          1        249     132096
         4 0000000081E6A000 00               00                        0          0          0 3735928559 0000000081E6A054 3735928559     126464          2        249     132096
         5 0000000081E8B000 00               00                        0          0          0 3735928559 0000000081E8B054 3735928559     126464          3        249     132096
         6 0000000081EAC000 00               00                        0          0          0 3735928559 0000000081EAC054 3735928559     126464          4        249     132096
         7 0000000081ECE000 00               00                        0          0          0 3735928559 0000000081ECE054 3735928559     126464          5        249     132096
         8 0000000081EEF000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
         9 0000000081F10000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        10 0000000081F31000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        11 0000000081F53000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        12 0000000081F74000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        13 0000000081F95000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        14 0000000081FB6000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        15 0000000081FD8000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        16 0000000081835000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        17 0000000081856000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
        18 0000000081877000 00               00                        0          0          0 3735928559 00                        0          0          0        249     132096
19 rows selected.

SYS@book> show parameter log_buffer
NAME       TYPE     VALUE
———- ——– ———
log_buffer integer  7159808

SYS@book> @ hide _log_parallelism_max
NAME                 DESCRIPTION                          DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE ISSES ISSYS_MOD
——————– ———————————— ————- ————- ———— —– ———
_log_parallelism_max Maximum number of log buffer strands TRUE          2             2            FALSE FALSE

SYS@book> show parameter cpu_count
NAME      TYPE    VALUE
——— ——- —–
cpu_count integer 24

–//cpu_count=24,这样_log_parallelism_max缺省ceil(cpu_count/16)=2.
–//log_buffer/2 =  7159808/2 = 3579904 .与执行@ imu 看到的STRAND_SIZE_KCRFA大小3579904一致.也就是@imu显示的前2行对应log_buffer信息.

$ ps -ef | grep lgw[r]
oracle   21810     1  0 Dec20 ?        00:00:27 ora_lgwr_book

$ cat /proc/21810/smaps  | grep -A1 SYSV
60000000-60c00000 rw-s 00000000 00:0b 451674112                          /SYSV00000000 (deleted)
Size:              12288 kB

60c00000-86800000 rw-s 00000000 00:0b 451706881                          /SYSV00000000 (deleted)
Size:             618496 kB

86800000-86a00000 rw-s 00000000 00:0b 451739650                          /SYSVe8a8ec10 (deleted)
Size:               2048 kB

–//注意看第1个共享内存段范围60000000-60c00000,查询@ imu的FIRST_BUF_KCRFA  LAST_BUF_KCRFA在这个范围之内.可以证明log_buffer在第1个共享内存段内.
–//0x0000000060590E00 – 0x0000000060227000 = 3579392(10进制), 3579392+512 = 3579904.大小等于STRAND_SIZE_KCRFA.
–//0x00000000608FAE00 – 0x0000000060591000 = 3579392(10进制).
–//512 = 0x200
–//0x0000000060590E00 + 0x200 = 0x0000000060591000,正好等于index=1的FIRST_BUF_KCRFA=0000000060591000.

3.继续测试:
SYS@book> oradebug setmypid
Statement processed.

SYS@book> oradebug DUMPvar SGA kcsgscn_
kcslf kcsgscn_ [06001AE70, 06001AEA0) = 17750548 00000003 00000000 00000000 000422E2 00000000 00000000 00000000 00000000 00000000 6001AB50 00000000

–//可以发现一些重要参数实际都定位在第1个共享内存段内.

$ cat fv2.sql
column fv_ksmfsnam heading SGAVARNAME for a50 wrap
column fv_ksmfstyp heading DATATYPE for a25 wrap
column fv_ksmmval_dec heading KSMMVAL_DEC for 99999999999999999999

prompt Display Fixed SGA Variables matching &1

select /*+ ORDERED USE_NL(m) */
    f.addr
  , f.indx
  , f.ksmfsnam fv_ksmfsnam
  , to_number(m.ksmmmval, 'XXXXXXXXXXXXXXXX') fv_ksmmval_dec
  , m.ksmmmval
  , f.ksmfstyp fv_ksmfstyp
  , f.ksmfsadr
  , f.ksmfssiz
from
    x$ksmfsv f, x$ksmmem m
where
    f.ksmfsadr = m.addr
and (lower(ksmfsnam) like lower('&1') or lower(ksmfstyp) like lower('&1'))
order by
    ksmfsnam
/

SYS@book>  @ tpt/fv2  kcsgscn_
Display Fixed SGA Variables matching %kcsgscn_%
old  14: and (lower(ksmfsnam) like lower('&1') or lower(ksmfstyp) like lower('&1'))
new  14: and (lower(ksmfsnam) like lower('%kcsgscn_%') or lower(ksmfstyp) like lower('%kcsgscn_%'))
ADDR                   INDX SGAVARNAME                                                   KSMMVAL_DEC KSMMMVAL         DATATYPE                  KSMFSADR           KSMFSSIZ
—————- ———- ————————————————– ——————— —————- ————————- —————- ———-
0000000009B159E0       3260 kcsgscn_                                                     13278447743 000000031775087F kcslf                     000000006001AE70         48

–//如果查询@ tpt/fv2  %,可以发现KSMFSADR地址都在第1个共享内存段内.

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

主题测试文章,只做测试使用。发布者:深沉的少年,转转请注明出处:http://www.cxybcw.com/182804.html

联系我们

13687733322

在线咨询:点击这里给我发消息

邮件:1877088071@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

QR code