主頁 >  其他 > [20191115]oracle實體占用記憶體計算.txt

[20191115]oracle實體占用記憶體計算.txt

2020-12-10 07:16:45 其他

[20191115]oracle實體占用記憶體計算.txt

--//以前學習oracle資料庫時,總想了解實體占用記憶體多少,我曾經在一些會議底下問過一位高手,對方說計算這個相對很難,許多東西是共享的.
--//很難有一個好方法計算,不過當時給了一個命令pmap,可以查看行程的記憶體使用情況,我當時使用命令看了一些,感覺輸出許多東西都不理解.
--//只能放棄.我現在基本使用smem大致了解該實體使用記憶體的情況.實際上上面的輸出不包括共享記憶體段使用情況.

--//正好前幾天論壇有人問類似的問題,鏈接http://www.itpub.net/thread-2121531-1-1.html,自己嘗試了解學習這方面內容.
--//順便說一下,對于作業系統這方面的內容十分欠缺,許多只能是猜測,也許完全不對.

1.環境:
SYS@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

# cat /etc/issue
Oracle Linux Server release 5.9
Kernel \r on an \m

2.共享記憶體段的確定:
$ ps -ef | egrep "[o]raclebook|[o]ra_.*_book" | awk '{print $2}'| paste -sd' '
43689 43691 43693 43697 43699 43701 43703 43705 43707 43709 43711 43713 43715 43717 43719 43721 43723 43725 43727 43734 43737 43739 43741 43757 43822 52465 56819 57058

$ all=$(ps -ef | egrep "[o]raclebook|[o]ra_.*_book" | awk '{print $2}'| paste -sd' ')

$ ps -ef | egrep "[o]raclebook|[o]ra_.*_book" | awk '{print $2}'| wc
     28      28     168
--//當前全部28個行程.

SYS@book> @ spid
       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
       295        175 56818                    DEDICATED 56819       21         62 alter system kill session '295,175' immediate;

$ pmap -x 56819 | head
56819:   oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
Address           Kbytes     RSS   Dirty Mode   Mapping
0000000000400000  189264   21624       0 r-x--  oracle
000000000bed4000    2020     352      76 rw---  oracle
000000000c0cd000     348     196     196 rw---    [ anon ]
000000000d6a6000     568     484     484 rw---    [ anon ]
0000000060000000   12288       0       0 rw-s-  SYSV00000000 (deleted)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0000000060c00000  618496       0       0 rw-s-  SYSV00000000 (deleted)
0000000086800000    2048       0       0 rw-s-  SYSVe8a8ec10 (deleted)
00000032cac00000     520     124       0 r-x--  libm-2.5.so
--//你可以發現下劃線內容應該上是共享記憶體段.很奇怪為什么后面標識都是deleted.另外我這里測驗不包括AMM的情況.AMM好像共享記憶體段使用/dev/shm/...

$ sysresv

IPC Resources for ORACLE_SID "book" :
Shared Memory:
ID              KEY
368312329       0x00000000
368345098       0x00000000
368377867       0xe8a8ec10
Semaphores:
ID              KEY
324927491       0x6aa88594
Oracle Instance alive for sid "book"
--//可以發現完全能對上.

$ pmap -x $all | grep "SYSV" | sort | uniq -c
     28 0000000060000000   12288       0       0 rw-s-  SYSV00000000 (deleted)
     28 0000000060c00000  618496       0       0 rw-s-  SYSV00000000 (deleted)
     28 0000000086800000    2048       0       0 rw-s-  SYSVe8a8ec10 (deleted)
--//可以確定要確定Shared Memory segment的計算僅僅找一個相關行程就可以確定.

3.pmap的mode相關問題:
--//我注意到mode這列.我的理解rw表示這段記憶體可以讀寫權限.而r_僅僅有讀權限.
--//先看看有多少mode模式:
$ pmap -q -x $all | grep -v ":" | awk '{print $5}' | sort | uniq -c
    548 -----
    218 r----
   1438 rw---
    104 rw-s-
    656 r-x--
--//僅僅存在這些模式.

$ pmap -q -x $all | grep -v ":" | awk '($5=="r----" || $5=="-----" || $5=="r-x--") {print}' | sort | uniq -c | head -60
      1 0000000000400000  189264   10968       0 r-x--  oracle
      1 0000000000400000  189264   11068       0 r-x--  oracle
      1 0000000000400000  189264   11636       0 r-x--  oracle
      1 0000000000400000  189264   11668       0 r-x--  oracle
      1 0000000000400000  189264   11708       0 r-x--  oracle
      1 0000000000400000  189264   11724       0 r-x--  oracle
      1 0000000000400000  189264   11788       0 r-x--  oracle
      1 0000000000400000  189264   11860       0 r-x--  oracle
      1 0000000000400000  189264   12032       0 r-x--  oracle
      1 0000000000400000  189264   12080       0 r-x--  oracle
      1 0000000000400000  189264   12096       0 r-x--  oracle
      1 0000000000400000  189264   12148       0 r-x--  oracle
      1 0000000000400000  189264   12152       0 r-x--  oracle
      1 0000000000400000  189264   12180       0 r-x--  oracle
      1 0000000000400000  189264   12368       0 r-x--  oracle
      1 0000000000400000  189264   12568       0 r-x--  oracle
      1 0000000000400000  189264   12592       0 r-x--  oracle
      1 0000000000400000  189264   12736       0 r-x--  oracle
      1 0000000000400000  189264   12808       0 r-x--  oracle
      1 0000000000400000  189264   12920       0 r-x--  oracle
      1 0000000000400000  189264   16504       0 r-x--  oracle
      1 0000000000400000  189264   16952       0 r-x--  oracle
      1 0000000000400000  189264   18828       0 r-x--  oracle
      1 0000000000400000  189264   21152       0 r-x--  oracle
      1 0000000000400000  189264   21624       0 r-x--  oracle
      1 0000000000400000  189264   23452       0 r-x--  oracle
      1 0000000000400000  189264   27616       0 r-x--  oracle
      2 00000032cac00000     520     124       0 r-x--  libm-2.5.so
      1 00000032cac00000     520     136       0 r-x--  libm-2.5.so
      1 00000032cac00000     520     144       0 r-x--  libm-2.5.so
      2 00000032cac00000     520      20       0 r-x--  libm-2.5.so
     17 00000032cac00000     520      64       0 r-x--  libm-2.5.so
      1 00000032cac00000     520      68       0 r-x--  libm-2.5.so
      2 00000032cac00000     520      80       0 r-x--  libm-2.5.so
      1 00000032cac00000     520      88       0 r-x--  libm-2.5.so
     27 00000032cac82000    2044       0       0 -----  libm-2.5.so
     27 00000032cae81000       4       4       4 r----  libm-2.5.so
     27 0000003798c00000     112     108       0 r-x--  ld-2.5.so
     27 0000003798e1c000       4       4       4 r----  ld-2.5.so
     12 0000003799000000    1340     468       0 r-x--  libc-2.5.so
      7 0000003799000000    1340     480       0 r-x--  libc-2.5.so
      3 0000003799000000    1340     484       0 r-x--  libc-2.5.so
      2 0000003799000000    1340     488       0 r-x--  libc-2.5.so
      1 0000003799000000    1340     500       0 r-x--  libc-2.5.so
      1 0000003799000000    1340     524       0 r-x--  libc-2.5.so
      1 0000003799000000    1340     536       0 r-x--  libc-2.5.so
     27 000000379914f000    2048       0       0 -----  libc-2.5.so
     27 000000379934f000      16      16       8 r----  libc-2.5.so
     27 0000003799800000       8       8       0 r-x--  libdl-2.5.so
     27 0000003799802000    2048       0       0 -----  libdl-2.5.so
     27 0000003799a02000       4       4       4 r----  libdl-2.5.so
     25 000000379a000000      88      56       0 r-x--  libpthread-2.5.so
      2 000000379a000000      88      60       0 r-x--  libpthread-2.5.so
     27 000000379a016000    2048       0       0 -----  libpthread-2.5.so
     27 000000379a216000       4       4       4 r----  libpthread-2.5.so
     27 000000379a400000      28      16       0 r-x--  librt-2.5.so
     27 000000379a407000    2048       0       0 -----  librt-2.5.so
     27 000000379a607000       4       4       4 r----  librt-2.5.so
     27 000000379c400000      84      24       0 r-x--  libnsl-2.5.so
     27 000000379c415000    2044       0       0 -----  libnsl-2.5.so

$ pmap -q -x $all | grep -v ":" | awk '($5=="r----" || $5=="-----" || $5=="r-x--") {print}' | sort | uniq -c | tail
      1 00007fffd35c2000       4       4       0 r-x--    [ anon ]
      1 00007fffdfd90000       4       4       0 r-x--    [ anon ]
      1 00007fffe77ea000       4       4       0 r-x--    [ anon ]
      1 00007fffebbff000       4       4       0 r-x--    [ anon ]
      1 00007fffef1ff000       4       4       0 r-x--    [ anon ]
      1 00007ffff1dff000       4       4       0 r-x--    [ anon ]
      1 00007ffff63ff000       4       4       0 r-x--    [ anon ]
      1 00007ffffb1ff000       4       4       0 r-x--    [ anon ]
      1 00007ffffb5ff000       4       4       0 r-x--    [ anon ]
     27 ffffffffff600000       4       0       0 r-x--    [ anon ]

--//這些都是共享庫以及oracle命令在記憶體中的映射.不知道為什么最后Mapping資訊不包括路徑.出了后面的標識"[ anon ]"
--//anon 應該是 anonymous的縮寫,表示無名的; 假名的; 匿名的; 的意思.也就是這些基本對于的是oracle.

--//順便說一下,我在測驗中發現ora_w000_book行程會隔一段時間重新建立.不知道為什么.這樣你看到的前面計數是27.好像20分鐘重新建立一個.
$ ps -ef | egrep "[o]raclebook|[o]ra_.*_book" | grep ora_w000_boo[k]
oracle   57612     1  0 10:11 ?        00:00:00 ora_w000_book
..
$ ps -ef | egrep "[o]raclebook|[o]ra_.*_book" | grep ora_w000_boo[k]
oracle   57943     1  0 10:31 ?        00:00:00 ora_w000_book

--//繼續查看mode="rw-s-"的情況:
$ pmap -q -x $all | grep -v ":" | awk '( $5=="rw-s-") {print}' | sort | uniq -c
     27 0000000060000000   12288       0       0 rw-s-  SYSV00000000 (deleted)
     27 0000000060c00000  618496       0       0 rw-s-  SYSV00000000 (deleted)
     27 0000000086800000    2048       0       0 rw-s-  SYSVe8a8ec10 (deleted)
      1 00007f0ad0240000       4       4       0 rw-s-  hc_book.dat
      1 00007f143e5f5000       4       4       0 rw-s-  hc_book.dat
      1 00007f19de855000       4       4       0 rw-s-  hc_book.dat
      1 00007f1d13463000       4       4       0 rw-s-  hc_book.dat
      1 00007f1d7224d000       4       4       0 rw-s-  hc_book.dat
      1 00007f29117de000       4       4       0 rw-s-  hc_book.dat
      1 00007f35cb9ba000       4       4       0 rw-s-  hc_book.dat
      1 00007f36a9947000       4       4       0 rw-s-  hc_book.dat
      1 00007f4033b74000       4       4       0 rw-s-  hc_book.dat
      1 00007f4cb071b000       4       4       0 rw-s-  hc_book.dat
      1 00007f5631d35000       4       4       0 rw-s-  hc_book.dat
      1 00007f58f5e27000       4       4       0 rw-s-  hc_book.dat
      1 00007f59cc7ac000       4       4       0 rw-s-  hc_book.dat
      1 00007f68e6c57000       4       4       0 rw-s-  hc_book.dat
      1 00007f759b1f5000       4       4       0 rw-s-  hc_book.dat
      1 00007f7b9765e000       4       4       0 rw-s-  hc_book.dat
      1 00007fac270b9000       4       4       0 rw-s-  hc_book.dat
      1 00007fbb8cd8c000       4       4       0 rw-s-  hc_book.dat
      1 00007fcab3977000       4       4       0 rw-s-  hc_book.dat
      1 00007fd4459ac000       4       4       0 rw-s-  hc_book.dat
      1 00007fdba0f0a000       4       4       0 rw-s-  hc_book.dat
      1 00007ff09931d000       4       4       0 rw-s-  hc_book.dat
      1 00007ff844549000       4       4       0 rw-s-  hc_book.dat
--//基本mode="rw-s-"都是Shared Memory segment以及hc_book.dat.
$ ls -l `which oracle `
-rwsr-s--x 1 oracle oinstall 239627073 2018-05-02 09:51:04 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle
--//mode里面的s,表示什么,share嗎?

$ ls -l `locate hc_book.dat`
-rw-rw---- 1 oracle oinstall 1544 2019-11-14 08:41:02 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/hc_book.dat

--//--//繼續查看mode="rw---"的情況:
 $ pmap -q -x $all | grep -v ":" | awk '( $5=="rw---") {print}' | sort | uniq -c | head -60
     13 000000000bed4000    2020     256      76 rw---  oracle
      1 000000000bed4000    2020     256      80 rw---  oracle
      1 000000000bed4000    2020     260      76 rw---  oracle
      2 000000000bed4000    2020     264      76 rw---  oracle
      2 000000000bed4000    2020     268      76 rw---  oracle
      1 000000000bed4000    2020     272      76 rw---  oracle
      1 000000000bed4000    2020     276      80 rw---  oracle
      1 000000000bed4000    2020     308      76 rw---  oracle
      1 000000000bed4000    2020     320      76 rw---  oracle
      1 000000000bed4000    2020     344      76 rw---  oracle
      2 000000000bed4000    2020     352      76 rw---  oracle
      1 000000000bed4000    2020     432      76 rw---  oracle
     18 000000000c0cd000     348     188     188 rw---    [ anon ]
      7 000000000c0cd000     348     192     192 rw---    [ anon ]
      2 000000000c0cd000     348     196     196 rw---    [ anon ]
      1 000000000c1e0000     436     340     340 rw---    [ anon ]
      1 000000000c37f000     436     376     376 rw---    [ anon ]
      1 000000000c448000     436     340     340 rw---    [ anon ]
      1 000000000c554000     568     516     516 rw---    [ anon ]
      1 000000000c5d7000    1616    1460    1460 rw---    [ anon ]
      1 000000000c635000     436     340     340 rw---    [ anon ]
      1 000000000c737000     436     340     340 rw---    [ anon ]
      1 000000000cb07000     436     340     340 rw---    [ anon ]
      1 000000000cb4a000     436     340     340 rw---    [ anon ]
      1 000000000ce91000     436     348     348 rw---    [ anon ]
      1 000000000ce92000     436     348     348 rw---    [ anon ]
      1 000000000cf23000     568     476     476 rw---    [ anon ]
      1 000000000cfa4000     576     504     504 rw---    [ anon ]
      1 000000000d087000     436     340     340 rw---    [ anon ]
      1 000000000d0a9000     436     348     348 rw---    [ anon ]
      1 000000000d1a1000     436     348     348 rw---    [ anon ]
      1 000000000d1c0000     436     348     348 rw---    [ anon ]
      1 000000000d29d000     436     344     344 rw---    [ anon ]
      1 000000000d313000     436     340     340 rw---    [ anon ]
      1 000000000d667000     436     340     340 rw---    [ anon ]
      1 000000000d6a6000     568     484     484 rw---    [ anon ]
      1 000000000d936000     436     340     340 rw---    [ anon ]
      1 000000000d958000     436     388     388 rw---    [ anon ]
      1 000000000dd0e000     436     348     348 rw---    [ anon ]
      1 000000000de97000     436     348     348 rw---    [ anon ]
      1 000000000dfc2000     436     348     348 rw---    [ anon ]
      1 000000000dfcc000     436     340     340 rw---    [ anon ]
     27 00000032cae82000       4       4       4 rw---  libm-2.5.so
     27 0000003798e1d000       4       4       4 rw---  ld-2.5.so
     27 0000003799353000       4       4       4 rw---  libc-2.5.so
     27 0000003799354000      20      20      20 rw---    [ anon ]
     27 0000003799a03000       4       4       4 rw---  libdl-2.5.so
     27 000000379a217000       4       4       4 rw---  libpthread-2.5.so
     27 000000379a218000      16       4       4 rw---    [ anon ]
     27 000000379a608000       4       4       4 rw---  librt-2.5.so
     27 000000379c615000       4       4       4 rw---  libnsl-2.5.so
     27 000000379c616000       8       0       0 rw---    [ anon ]
      1 000000379ea12000       4       4       4 rw---  libresolv-2.5.so
      1 000000379ea13000       8       0       0 rw---    [ anon ]
      1 00007f0ad0241000       8       8       8 rw---    [ anon ]
      1 00007f0ad044d000       4       4       4 rw---  libnss_files-2.5.so
      1 00007f0ad044e000      72      24      24 rw---  zero
      1 00007f0ad0460000      64      16      16 rw---  zero
      1 00007f0ad0470000      64      20      20 rw---  zero
      1 00007f0ad0480000      64      56      56 rw---  zero

--//奇怪一些library檔案也有一些區域可以寫入.

4.繼續探究:
--//pmap的輸出第1,2個欄位是Address,Kbytes看看是否出現重疊的情況.

SCOTT@book> create table tx ( a varchar2(40),b number );
Table created.

$ all=$(ps -ef | egrep "[o]raclebook|[o]ra_.*_book" | awk '{print $2}'| paste -sd' ')
$ pmap -q -x $all | grep -v ":" | sort | awk '{print $1 "\x27," $2 }' | uniq | sed "s/^/insert into tx values (\'/;s/$/);/" | sqlplus -s -l scott/book

WITH sub1
     AS (  SELECT a, b, LEAD (a, 1, NULL) OVER (ORDER BY a) c
             FROM tx
         ORDER BY a)
    ,sub2
     AS (SELECT TO_NUMBER (a, 'xxxxxxxxxxxxxxxxxxxxxx') a1
               ,b * 1024 b1
               ,TO_NUMBER (c, 'xxxxxxxxxxxxxxxxxxxxxx') c1
               ,a,c
           FROM sub1)
SELECT c1 - a1 delta
      ,b1
      ,c1
      ,a1
      ,a,c
  FROM sub2
 WHERE c1 -a1 <b1;

 DELTA         B1         C1         A1 A                C
------ ---------- ---------- ---------- ---------------- ----------------
536576     581632  207450112  206913536 000000000c554000 000000000c5d7000
385024    1654784  207835136  207450112 000000000c5d7000 000000000c635000
274432     446464  213164032  212889600 000000000cb07000 000000000cb4a000
  4096     446464  216604672  216600576 000000000ce91000 000000000ce92000
528384     581632  217726976  217198592 000000000cf23000 000000000cfa4000
139264     446464  218796032  218656768 000000000d087000 000000000d0a9000
196608     581632  219811840  219615232 000000000d171000 000000000d1a1000
126976     446464  219938816  219811840 000000000d1a1000 000000000d1c0000
139264     446464  227901440  227762176 000000000d936000 000000000d958000
 40960     446464  234668032  234627072 000000000dfc2000 000000000dfcc000
167936     446464  234835968  234668032 000000000dfcc000 000000000dff5000
11 rows selected.

$ pmap -q -x $all | egrep "000000000c554000|000000000c5d7000|000000000cb07000|000000000ce91000|000000000cf23000|000000000d087000|000000000d171000|000000000d1a1000|000000000d936000|000000000dfc2000|000000000dfcc000"|sort
000000000c554000     568     516     516 rw---    [ anon ]
000000000c5d7000    1616    1460    1460 rw---    [ anon ]
000000000cb07000     436     340     340 rw---    [ anon ]
000000000ce91000     436     348     348 rw---    [ anon ]
000000000cf23000     568     476     476 rw---    [ anon ]
000000000d087000     436     340     340 rw---    [ anon ]
000000000d171000     568     480     480 rw---    [ anon ]
000000000d1a1000     436     348     348 rw---    [ anon ]
000000000d936000     436     340     340 rw---    [ anon ]
000000000dfc2000     436     348     348 rw---    [ anon ]
000000000dfcc000     436     340     340 rw---    [ anon ]
--//不知道為什么?不過這些重疊區域占用大小不大.
$ all=$(ps -ef | egrep "[o]racle${sid}|[o]ra_.*_${sid}" | awk '{print $2}'| paste -sd' ' )
$ client=$(ps -ef | egrep "[o]racle${sid}" | awk '{print $2}'| paste -sd' ' )

$ pmap -q -x $client >| /tmp/omapclient.txt
$ pmap -q -x $all    >| /tmp/omap.txt

$ egrep ":|000000000c554000|000000000c5d7000|000000000cb07000|000000000ce91000|000000000cf23000|000000000d087000|000000000d171000|000000000d1a1000|000000000d936000|000000000dfc2000|000000000dfcc000" /tmp/omap.txt
564:   ora_w000_book
43689:   ora_pmon_book
000000000c554000     568     516     516 rw---    [ anon ]
43691:   ora_psp0_book
000000000dfcc000     436     340     340 rw---    [ anon ]
43693:   ora_vktm_book
000000000d087000     436     340     340 rw---    [ anon ]
43697:   ora_gen0_book
000000000d1a1000     436     348     348 rw---    [ anon ]
43699:   ora_diag_book
43701:   ora_dbrm_book
43703:   ora_dia0_book
000000000cb07000     436     340     340 rw---    [ anon ]
43705:   ora_mman_book
43707:   ora_dbw0_book
43709:   ora_dbw1_book
000000000d936000     436     340     340 rw---    [ anon ]
43711:   ora_dbw2_book
43713:   ora_lgwr_book
43715:   ora_ckpt_book
43717:   ora_smon_book
43719:   ora_reco_book
43721:   ora_mmon_book
43723:   ora_mmnl_book
000000000c5d7000    1616    1460    1460 rw---    [ anon ]
43725:   ora_d000_book
43727:   ora_s000_book
43734:   ora_rvwr_book
000000000dfc2000     436     348     348 rw---    [ anon ]
43737:   ora_arc0_book
000000000ce91000     436     348     348 rw---    [ anon ]
43739:   ora_arc1_book
43741:   ora_ctwr_book
43757:   ora_cjq0_book
43822:   ora_smco_book
52465:   oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
000000000cf23000     568     476     476 rw---    [ anon ]
58344:   oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
000000000d171000     568     480     480 rw---    [ anon ]
--//2個client也存在重疊區域.

000000000c554000=> 43689:   ora_pmon_book
000000000c5d7000=> 43723:   ora_mmnl_book

5.我根據前面的測驗:
--//大致按照mode分類累加,消除重復的段,大概能得到oracle占用的記憶體量.當然這些還是不準的.比如libc共享庫,其它程式也需要不僅僅oracle代碼.
--//還有重疊的問題^_^.
--//另外我發現如果相關行程很多有點慢,我先snapshot到檔案,這樣能保存分析的一致性,避免一些行程已經退出的情況.
--//僅僅作為大致了解當前實體的匯總情況,估計給結合smem分析(smem包括交換,以及各個行程的情況).
--//測驗時最好有1個專用連接資料庫,不想做一些判斷了.

$ seq 150 | xargs -I {} bash -c "sqlplus -s -l scott/book <<< \"select sleep(20) from dual ;\" & "
$ . omap.sh book
report memory used by oracle instance book as of  2019/11/15_15:35:29
=================================================================================
shared memory segments .................................... :       632832 KB
Shared binary code and shared libraries ................... :      6396384 KB
private memory (foreground and background)................. :      1129296 KB
sum memory for oracle instance ............................ :      8158512 KB

Number of current dedicated connections ................... :          172
private memory (foreground decicated connections).......... :       878672 KB
=================================================================================

--//順便貼一個生產系統的情況:
#  ./omap.sh xxxx1
report memory used by oracle instance xxxx1 as of  2019/11/15_15:57:31
=================================================================================
shared memory segments .................................... :     79431680 KB
Shared binary code and shared libraries ................... :     45661756 KB
private memory (foreground and background)................. :      9136504 KB
sum memory for oracle instance ............................ :    134229940 KB

Number of current dedicated connections ................... :         4405
private memory (foreground decicated connections).......... :      7372600 KB
=================================================================================

6.補充學習:
$ pmap -x 56819 | head
56819:   oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
Address           Kbytes     RSS   Dirty Mode   Mapping
0000000000400000  189264   21624       0 r-x--  oracle
000000000bed4000    2020     352      76 rw---  oracle
000000000c0cd000     348     196     196 rw---    [ anon ]
000000000d6a6000     568     484     484 rw---    [ anon ]
0000000060000000   12288       0       0 rw-s-  SYSV00000000 (deleted)
0000000060c00000  618496       0       0 rw-s-  SYSV00000000 (deleted)
0000000086800000    2048       0       0 rw-s-  SYSVe8a8ec10 (deleted)
00000032cac00000     520     124       0 r-x--  libm-2.5.so

--//0x000000000bed4000 - 0x0000000000400000 = 195903488, 195903488/1024 = 191312
--//000000000c0cd000 - 000000000bed4000 = 2068480 ,2068480/1024 = 2020

$ size $(which oracle) | column -t
text       data     bss     dec        hex      filename
193804111  2065800  357672  196227583  bb231ff  /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle
--//基本能對上size看到的text,data段大小.0xbb231ff = 196227583

7.源代碼如下:
#! /bin/bash
# Purpose     :  calculate oracle using memory
# Author       : lfree
# Date/Time    : 2019-11-15 10:10:10
# Modified date: 2019-11-15 10:10:11

odebug=${ODEBUG:-0}

if [ $# -lt 1 ]; then
    echo "Usage: $0 ORACLE_SID "
    exit 1
fi

sid=$1

# substr oracle foreground and background of pids
all=$(ps -ef | egrep "[o]racle${sid}|[o]ra_.*_${sid}" | awk '{print $2}'| paste -sd' ' )
client=$(ps -ef | egrep "[o]racle${sid}" | awk '{print $2}'| paste -sd' ' )
conn=$(ps -ef | egrep "[o]racle${sid}" | wc -l )

if [ $odebug -eq 1 ] ; then
        echo $client
        echo $all
        echo $conn
fi

pmap -q -x $client >| /tmp/omapclient.txt
pmap -q -x $all    >| /tmp/omap.txt

sysvsz=$(cat /tmp/omap.txt |  grep  "SYSV" |awk '($5 ~ /^rw-/) {print $1,",",$2}' | sort | uniq | cut -f2 -d, | paste -sd+ | bc )
sharedsz=$(cat /tmp/omap.txt | grep -v ":" | awk '($5=="r----" || $5=="-----" || $5=="r-x--") {print $1,",",$2}' | sort | uniq | cut -f2 -d,| paste -sd+ | bc )
privatesz=$(cat /tmp/omap.txt | grep -v ":" | grep -v "SYSV" |awk '($5 ~ /^rw-/) {print $1,",",$2}' | sort | uniq | cut -f2 -d, | paste -sd+ | bc )
sumsz=$((sharedsz + privatesz + sysvsz ))

clientprivatesz=$(cat /tmp/omapclient.txt | grep -v ":" | grep -v "SYSV" |awk '($5 ~ /^rw-/) {print $1,",",$2}' | sort | uniq | cut -f2 -d, | paste -sd+ | bc )

if [ $odebug -eq 1 ] ; then
        echo connect  = $conn
        echo sysvsz = $sysvsz
        echo sharedsz = $sharedsz
        echo privatesz = $privatesz
        echo sumsz = $sumsz
fi

echo
echo "report memory used by oracle instance $sid as of " `date +'%Y/%m/%d_%T'`
echo "================================================================================="
printf "shared memory segments .................................... : %12d KB\n" $sysvsz
printf "Shared binary code and shared libraries ................... : %12d KB\n" $sharedsz
printf "private memory (foreground and background)................. : %12d KB\n" $privatesz
printf "sum memory for oracle instance ............................ : %12d KB\n" $sumsz
echo
printf "Number of current dedicated connections ................... : %12d\n"    $conn
printf "private memory (foreground decicated connections).......... : %12d KB\n" $clientprivatesz
echo "================================================================================="
echo
#/bin/rm /tmp/omap.txt  /tmp/omapclient.txt


轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/232361.html

標籤:其他

上一篇:MySQL開發規范與使用技巧總結

下一篇:mysql備份

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more