今年の春に作った Oracle Database on Linux が使用しているメモリサイズを表示するシェルスクリプトをとりあえず github に push しました。かなりてきとーなシェルスクリプトです。精査してませんし、改善すべき点もたくさんあると思います。
ソースコード
#!/bin/bash export LANG=C # show shared memory pgrep -f ora_pmon|xargs -n1 pmap -q|\ perl -lane 'if($F[2] =~ /...s./){chop($F[1]);$s+=$F[1]};END{print "shared memory: ${s}KB"}' # show text pgrep -f ora_pmon|xargs -n1 pmap -q|\ perl -lane 'if($F[2] eq q/r-x--/){chop($F[1]);$s+=$F[1]};END{print "text: ${s}KB"}' # show data and stack echo 'data and stack:' echo 'PID NAME KB' echo '---- ------------- ------' pgrep -f '^ora_|^oracle'|while read LINE do echo ${LINE} `cat /proc/${LINE}/cmdline` `pmap -q ${LINE}|\ perl -lane 'if($F[2] eq q/rwx--/){chop($F[1]);$s+=$F[1]}END{print "$s"}'` done
実行してみる
- show_oracle_memory_size.sh を実行する。
[oracle@centos54 ~]$ ./show_oracle_memory_size.sh shared memory: 417796KB text: 147484KB data and stack: PID NAME KB ---- ------------- ------ 3133 ora_pmon_orcl 5012 3135 ora_vktm_orcl 4448 3139 ora_gen0_orcl 4448 3141 ora_diag_orcl 4448 3143 ora_dbrm_orcl 4456 3145 ora_psp0_orcl 4448 3147 ora_dia0_orcl 4960 3149 ora_mman_orcl 4448 3151 ora_dbw0_orcl 8348 3153 ora_lgwr_orcl 20000 3155 ora_ckpt_orcl 4448 3157 ora_smon_orcl 9148 3159 ora_reco_orcl 4964 3161 ora_mmon_orcl 7132 3163 ora_mmnl_orcl 4448 3165 ora_d000_orcl 4984 3167 ora_s000_orcl 4456 3201 ora_qmnc_orcl 4448 3215 ora_cjq0_orcl 9092 3218 ora_vkrm_orcl 4448 3234 ora_q000_orcl 4992 3238 ora_q001_orcl 4448 3643 ora_smco_orcl 4448 4099 ora_w000_orcl 4448
蛇足
- Oracle Database から見えている SGA のサイズを確認する。
[oracle@centos54 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Sun Nov 14 23:51:30 2010 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show sga Total System Global Area 422670336 bytes Fixed Size 1336960 bytes Variable Size 297798016 bytes Database Buffers 117440512 bytes Redo Buffers 6094848 bytes
SQL> set pagesize 50000 SQL> set linesize 200 SQL> col name for a50 SQL> select * from v$pgastat; NAME VALUE UNIT -------------------------------------------------- ---------- ------------ aggregate PGA target parameter 146800640 bytes aggregate PGA auto target 104297472 bytes global memory bound 29360128 bytes total PGA inuse 30912512 bytes total PGA allocated 44362752 bytes maximum PGA allocated 82887680 bytes total freeable PGA memory 8454144 bytes process count 26 max processes count 31 PGA memory freed back to OS 80347136 bytes total PGA used for auto workareas 0 bytes maximum PGA used for auto workareas 1316864 bytes total PGA used for manual workareas 0 bytes maximum PGA used for manual workareas 0 bytes over allocation count 0 bytes processed 105333760 bytes extra bytes read/written 0 bytes cache hit percentage 100 percent recompute count (total) 1075 19 rows selected.
- ps で見てみる。
[oracle@centos54 ~]$ ps -U oracle uxw USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND oracle 3133 0.0 1.5 570292 16372 ? Ss Nov14 0:00 ora_pmon_orcl oracle 3135 0.0 1.2 569700 13364 ? Ss Nov14 0:00 ora_vktm_orcl oracle 3139 0.0 1.3 569700 13500 ? Ss Nov14 0:00 ora_gen0_orcl oracle 3141 0.0 1.2 569700 13312 ? Ss Nov14 0:00 ora_diag_orcl oracle 3143 0.0 2.0 569708 21240 ? Ss Nov14 0:00 ora_dbrm_orcl oracle 3145 0.0 1.3 569700 13540 ? Ss Nov14 0:00 ora_psp0_orcl oracle 3147 0.0 1.6 570212 16756 ? Ss Nov14 0:01 ora_dia0_orcl oracle 3149 0.0 1.9 569700 20020 ? Ss Nov14 0:01 ora_mman_orcl oracle 3151 0.0 3.4 573600 35780 ? Ss Nov14 0:00 ora_dbw0_orcl oracle 3153 0.0 3.5 585252 36232 ? Ss Nov14 0:00 ora_lgwr_orcl oracle 3155 0.0 1.6 569700 17084 ? Ss Nov14 0:00 ora_ckpt_orcl oracle 3157 0.0 6.9 574400 72328 ? Ss Nov14 0:00 ora_smon_orcl oracle 3159 0.0 1.9 570216 19988 ? Ss Nov14 0:00 ora_reco_orcl oracle 3161 0.0 5.2 574460 54140 ? Ss Nov14 0:00 ora_mmon_orcl oracle 3163 0.0 1.9 569700 19828 ? Ss Nov14 0:00 ora_mmnl_orcl oracle 3165 0.0 1.3 570344 13508 ? Ss Nov14 0:00 ora_d000_orcl oracle 3167 0.0 1.2 569732 12860 ? Ss Nov14 0:00 ora_s000_orcl oracle 3201 0.0 1.4 569700 15084 ? Ss Nov14 0:00 ora_qmnc_orcl oracle 3215 0.0 4.5 574344 47508 ? Ss Nov14 0:00 ora_cjq0_orcl oracle 3218 0.0 1.2 569700 13420 ? Ss Nov14 0:00 ora_vkrm_orcl oracle 3234 0.0 2.5 570240 26660 ? Ss Nov14 0:00 ora_q000_orcl oracle 3238 0.0 1.5 569696 15744 ? Ss Nov14 0:00 ora_q001_orcl oracle 3643 0.0 1.3 569700 14012 ? Ss Nov14 0:00 ora_smco_orcl oracle 4099 0.0 1.4 569696 14752 ? Ss Nov14 0:00 ora_w000_orcl oracle 4284 0.0 0.1 9920 1580 ? S Nov14 0:00 sshd: oracle@pts/1 oracle 4285 0.0 0.1 4664 1460 pts/1 Ss Nov14 0:00 -bash oracle 5116 0.0 0.0 4256 940 pts/1 R+ 00:08 0:00 ps -U oracle uxw