[20191115]oracle例項佔用記憶體計算.txt
[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
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2664371/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- node計算記憶體佔用記憶體
- MySQL記憶體佔用計算公式MySql記憶體公式
- Oracle 11gR2 ASM例項記憶體管理OracleASM記憶體
- oracle RDBMS Kernel Executable 佔用記憶體過高Oracle記憶體
- [20210126]探究oracle記憶體分配.txtOracle記憶體
- [20210412]分析會話佔用的共享記憶體段.txt會話記憶體
- influxdb記憶體佔用剖析UX記憶體
- 資源記憶體佔用記憶體
- 用例項帶你深入理解Java記憶體模型Java記憶體模型
- [20210421]分析會話佔用的共享記憶體段2.txt會話記憶體
- [20210126]探究oracle記憶體分配3.txtOracle記憶體
- [20210126]探究oracle記憶體分配4.txtOracle記憶體
- 怎樣計算Bitmap的記憶體佔用和Bitmap載入優化記憶體優化
- Oracle:記憶體設定注意事項Oracle記憶體
- mariadb 記憶體佔用優化記憶體優化
- python物件的記憶體佔用Python物件記憶體
- 託管堆記憶體佔用記憶體
- 寫個方法近似計算指定陣列或物件佔用記憶體的大小陣列物件記憶體
- [20190202]使用smem查詢oracle記憶體使用.txtOracle記憶體
- 開源大模型佔GPU視訊記憶體計算方法大模型GPU記憶體
- DOTNET記憶體佔用最佳化記憶體
- 如何檢視MySQL資料庫佔多大記憶體,佔用太多記憶體怎麼辦?MySql資料庫記憶體
- Win10記憶體佔用過多怎麼辦 win10清理記憶體佔用的方法Win10記憶體
- 電腦記憶體佔用過高怎麼辦 電腦記憶體佔用過高解決方法記憶體
- win10如何查詢哪些應用記憶體佔用大 win10如何檢視軟體記憶體佔用Win10記憶體
- 如何讓手遊記憶體佔用更小?從記憶體消耗iOS實時統計開始記憶體iOS
- Windbg分析高記憶體佔用問題記憶體
- 分析並優化 Android 應用記憶體佔用優化Android記憶體
- 例項解析網路程式設計中的另類記憶體洩漏程式設計記憶體
- Android中一張圖片佔據的記憶體大小是如何計算Android記憶體
- 深度解讀昇騰CANN記憶體複用技術,降低網路記憶體佔用記憶體
- 一個Java物件到底佔用多大記憶體?Java物件記憶體
- 利用Windbg分析高記憶體佔用問題記憶體
- Redis 實戰 —— 12. 降低記憶體佔用Redis記憶體
- 計算機記憶體管理介紹計算機記憶體
- 適用於大型記憶體資料庫的 Amazon EC2 大記憶體 U7i 例項簡介記憶體資料庫
- win10如何降低chrome記憶體佔用_win10電腦chrome記憶體佔用過高怎麼辦Win10Chrome記憶體
- 計算機作業系統——虛擬記憶體與實體記憶體計算機作業系統記憶體