ablog

不器用で落着きのない技術者のメモ

Oracleが使っている共有メモリサイズを調べる

[24時間365日] サーバ/インフラを支える技術 ?スケーラビリティ、ハイパフォーマンス、省力運用 (WEB+DB PRESS plusシリーズ) P.201 にのっている共有メモリサイズを調べる Perl スクリプトにヒントを得て、Oracle が使っている共有メモリサイズを調べるスクリプトを作ってみた。これであってるのかどうかわからないけどとりあえずメモっておく。

  • shared_memory_size.sh
#!/bin/bash
export LANG=C
sqlplus / as sysdba @process.sql > /dev/null
cat _process.log | while read LINE
do
        pmap -x $LINE 2>&1 | perl -lane '/shmid/ and print "$F[8] $F[2]";'
done | sort | uniq | \
perl -lane 'BEGIN{$size=0;} $size+=$F[1]; END{$kb=$size/1000;$mb=$kb/1000; 
        print "Shared memory used by Oracle is $kb KB ($mb MB)";}'
set echo off
set pagesize 0
set linesize 10000
set trimout on
set trimspool on
set heading off
set feedback off
set long 102400
set underline off
set verify off
spool _process.log
select spid from v$process where spid is not null;
spool off
quit
  • 実行結果
$ ./shared_memory_size.sh 
Shared memory used by Oracle is 282.628 KB (0.282628 MB)