Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: swapping

Re: swapping

From: <Brian_P_MacLean_at_eFunds.Com>
Date: Thu, 6 Jan 2005 12:11:32 -0700
Message-ID: <OFBD440E5E.1C5BB6B5-ON07256F81.00690E38-07256F81.00696D1C@DeluxeData.Com>

This will give Oracle's numbers on Solaris. It's a cut from an old Oracle Solaris Admin Guide. Then just use top for the other's. Welcome to Solaris memory/swap hell. Ciao

#!/usr/bin/sh
# Copyright 2000 Oracle Corporation
#
# modification history:
# date by comments
# ---------- -------- ----------------
# 07/15/2000 rgulledg original program
#

 usage()
{

echo "Usage: $0 [ SB ]"
echo "Usage: $0 [ P <pid> ]"
echo "Usage: $0 [ h ]"
echo " "
echo "specify 'S' for Oracle shadow processes"
echo "specify 'B' for Oracle background processes (includes shared
memory SGA)"
echo "specify 'h' for help"
echo " "
}
 echo " "
 #
# check usage
#

if [ $# = "0" ];then
usage;exit 1
fi
if [ $1 = "h" ];then
echo "This script uses the Sun Solaris pmap command to determine memory usage"
echo "for Oracle server [B]ackground processes and/or [S]hadow processes."
echo "An individual [P]rocess can also be specified."
echo " "
echo "Although the Oracle server background processes memory usage
should"
echo "remain fairly constant, the memory used by any given shadow process"
echo "can vary greatly. This script shows only a snapshot of the current"
echo "memory usage for the processes specified."
echo " "
echo "The 'B' option shows the sum of memory usage for all Oracle server"
echo "background processes, including shared memory like the SGA."
echo " "
echo "The 'S' option shows the sum of private memory usage by all"
echo "shadow processes.  It does not include any shared memory like the"
echo "SGA since these are part of the Oracle server background processes."
echo " "
echo "The 'P' option shows memory usage for a specified process, broken"
echo "into two categories, private and shared.  If the same executable"
echo "for this process was invoked again, only the private memory"
echo "would be allocated, the rest is shared with the currently running"
echo "process."
echo " "

usage;exit 1
fi
echo $1|grep [SBP] > /dev/null
ParmFound=$?
if [ $ParmFound != "0" ];then
usage;exit 1
fi
echo $1|grep P > /dev/null
ParmFound=$?
if [ $ParmFound = "0" ];then
if [ $1 != "P" ];then
usage;exit 1
fi
if [ "X$2" = "X" ];then
usage;exit 1
fi
echo $2|grep [0-9] > /dev/null
ParmFound=$?
if [ $ParmFound != "0" ];then
usage;exit 1
fi
PidOwner=`ps -ef | grep -v grep | grep $2 | grep -v $0 | awk '{print \ $1}'`
CurOwner=`/usr/xpg4/bin/id -un`
if [ "X$PidOwner" != "X$CurOwner" ];then
echo "Not owner of pid $2, or pid $2 does not exist"
echo " "

usage;exit 1
fi
else
if [ "X${ORACLE_SID}" = "X" ];then
echo "You must set ORACLE_SID first"
usage;exit1
fi
fi
 #
# initialize variables
#
Pmap="/usr/proc/bin/pmap"
SharUse="/tmp/omemuseS$$"
PrivUse="/tmp/omemuseP$$"
ShadUse="/tmp/omemuseD$$"

PidPUse="/tmp/omemusePP$$"
PidSUse="/tmp/omemusePS$$"
TotalShad=0
TotalShar=0
TotalPriv=0

PidPriv=0
PidShar=0
 #
# shadow processes
#

echo $1|grep S > /dev/null
ParmFound=$?
if [ $ParmFound = "0" ];then
ShadPrc="`ps -ef|grep -v grep|grep oracle$ORACLE_SID|awk '{print $2}'`" echo "" > $ShadUse
for i in $ShadPrc;do
$Pmap $i | grep "read/write" | grep -v shared | \ awk '{print $2}' | awk -FK '{print $1}' >> $ShadUse done
for i in `cat $ShadUse`;do
TotalShad=`expr $TotalShad + $i`
done
TotalShad=`expr $TotalShad "*" 1024`
echo "Total Shadow (bytes) : $TotalShad" /bin/rm $ShadUse
fi
 #
# non-shared portion of background processes
#

echo $1|grep B > /dev/null
ParmFound=$?
if [ $ParmFound = "0" ];then
OrclPrc="`ps -ef|grep -v grep|grep ora_|grep $ORACLE_SID|awk '{print $2}'`" BkgdPrc="`echo $OrclPrc|awk '{print $1}'`" echo "" > $PrivUse
for i in $OrclPrc;do
$Pmap $i | grep "read/write" | grep -v shared | \ awk '{print $2}' | awk -FK '{print $1}' >> $PrivUse done
for i in `cat $PrivUse`;do
TotalPriv=`expr $TotalPriv + $i`
done
TotalPriv=`expr $TotalPriv "*" 1024`
echo "Total Private (bytes) : $TotalPriv"  #
# shared portion of background processes
#

echo "" > $SharUse
$Pmap $BkgdPrc | grep "read/exec" | \
awk '{print $2}' | awk -FK '{print $1}' >> $SharUse $Pmap $BkgdPrc | grep "shared" | \
awk '{print $2}' | awk -FK '{print $1}' >> $SharUse for i in `cat $SharUse`;do
TotalShar=`expr $TotalShar + $i`
done
TotalShar=`expr $TotalShar "*" 1024`
echo "Total Shared (bytes) : $TotalShar" /bin/rm $SharUse $PrivUse
fi
 #
# non-shared portion of pid
#

echo $1|grep P > /dev/null
ParmFound=$?
if [ $ParmFound = "0" ];then
echo "" > $PidPUse
$Pmap $2 | grep "read/write" | grep -v shared | \ awk '{print $2}' | awk -FK '{print $1}' >> $PidPUse for i in `cat $PidPUse`;do
PidPriv=`expr $PidPriv + $i`
done
PidPriv=`expr $PidPriv "*" 1024`
echo "Total Private (bytes) : $PidPriv"
 #
# shared portion of pid
#

echo "" > $PidSUse
$Pmap $2 | grep "read/exec" | awk '{print $2}' | \ awk -FK '{print $1}' >> $PidSUse
$Pmap $2 | grep "shared" | awk '{print $2}' | \ awk -FK '{print $1}' >> $PidSUse
for i in `cat $PidSUse`;do
PidShar=`expr $PidShar + $i`
done
PidShar=`expr $PidShar "*" 1024`
echo "Total Shared (bytes) : $PidShar"
/bin/rm $PidPUse $PidSUse
fi
 #
# Display grand total
#

Gtotal="`expr $TotalShad + $TotalPriv + $TotalShar + $PidPriv + \ $PidShar`"
echo "                  -----"

echo "Grand Total (bytes) : $Gtotal" echo " "
                                                                                                                                       
                      Jeremiah Wilton                                                                                                  
                      <jeremiah_at_ora-600.        To:       "Chen, Sarah" <Sarah_Chen_at_BUDCO.com>                                         
                      net>                      cc:       "'oracle-l_at_freelists.org'" <oracle-l_at_freelists.org>, (bcc: Brian P           
                      Sent by:                   MacLean/PHX/eFunds)                                                                   
                      oracle-l-bounce_at_fr        Subject:  Re: swapping                                                                 
                      eelists.org                                                                                                      
                                                                                                                                       
                                                                                                                                       
                      01/06/2005 11:39                                                                                                 
                      AM                                                                                                               
                      Please respond to                                                                                                
                      jeremiah                                                                                                         
                                                                                                                                       
                                                                                                                                       




On Thu, 6 Jan 2005, Chen, Sarah wrote:

> I am encountering high swapping problem on Oracle database 9.2.0.4 with 16G

> RAM on Sun Sol 2.8 platform.
>
> Can anyone provide good UNIX commands/tips? I would also like to know how
to
> find how much swap space for each running process?

A good place to start would be to find out which processes are using the most resident memory, and thus forcing swapping.

On Solaris 8, you can run 'top -o res' to have top sort by resident memory.

It could be one or just a few processes sucking up memory, or many processes. So also try 'ps -eo pid,rss,comm | sort -n +1' to display all processes and their resident set size.

You have to do the math. Add up all the resident memory being used by processes and see how that compares available memory and swap space. The sum of all frequently active processes has to fit into available memory if you want to avoid swapping.

You can have many inactive processes occupying swap space with little impact, so the math doesn't have to be perfect.

--
Jeremiah Wilton
ORA-600 Consulting
Emergencies - Seminars - Hiring
http://www.ora-600.net
--
http://www.freelists.org/webpage/oracle-l





--
http://www.freelists.org/webpage/oracle-l
Received on Thu Jan 06 2005 - 13:18:10 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US