Page 1 of 1

Set the shared memory to half of the installed

Posted: Fri Mar 25, 2005 3:01 am
by voronwe
Hello guys

I needed a quick way the change the Shared memory size on my ZM Machine, so i decided to build a script to do it for me, and ended up with the following, need someone to go it thru and tell me if iam all off or what, have tested it on my RedHat FC 3 and it seems to work.

Code: Select all

#!/bin/bash
#used for test purpose
#ZMDIR=`pwd`
#SYSCTL="$ZMDIR/etc/sysctl.conf"

# To change the Shared memory to half of the memory size of that u have installed in ur machine entehr the path for ur sysctl.conf
# below, on a RedHat Fedora Core 3 it is /etc/sysctl.conf
SYSCTL="/etc/sysctl.conf"

######################################################################################
# This line i found on the INet, not exactly sure what it does past the              #
# ($1 / 2) * 1024, but my end result is half the size of the installed memory        #
# into my variable SIZE, with that done i can now set my shared memory to that       #
# size in sysctl.conf.                                                               #
SIZE=`dmesg | egrep 'Memory.*available' | perl -ne '/\/(\d+)/; $_ = ($1 / 2) * 1024; print $_ > 268435456 ? $_ : 268435456'`
######################################################################################

######################################################################################
# The 2 following variables wil bet set to the new shared mem limits                 #
KSHMAX="kernel.shmmax=$SIZE"
KSHMALL="kernel.shmall=$SIZE"
######################################################################################

######################################################################################
# Find the original shared memory lines in sysctl.conf file,                         #
# this i used in the find command                                                    #
KSHMAX_ORG=$(grep "kernel.shmmax=" $SYSCTL)
KSHMALL_ORG=$(grep "kernel.shmall=" $SYSCTL)
######################################################################################

# Display what we found
echo "KSHMAX is = $KSHMAX"
echo "KSHMALL is = $KSHMALL"
echo "KSHMAX_ORG is = $KSHMAX_ORG"
echo "KSHMALL_ORG is = $KSHMALL_ORG"

# Make a backup of the or sysctl.conf
cp $SYSCTL $SYSCTL.org

# Do the changes in the file and remove the blank lines in it
if [ "$KSHMAX_ORG" == "" ] && [ "$KSHMALL_ORG" == "" ]; then
	echo "+++++++ ERROR : KSHMAX_ORG is empty and KSHMALL_ORG is empty"
	perl -i -ne "print if /\S/" $SYSCTL
	echo $KSHMAX >> $SYSCTL
	echo $KSHMALL >> $SYSCTL
else
	perl -i -ne "print if /\S/" $SYSCTL
	perl -i -pe 's/'$KSHMAX_ORG'/'$KSHMAX'/g' $SYSCTL
	perl -i -pe 's/'$KSHMALL_ORG'/'$KSHMALL'/g' $SYSCTL
fi
The script can be downloaded here. http://dvss.voronwe.dk/zm/shared.sh

Any changes are welcome, and if u find it usefull then good. :)

Posted: Tue Apr 19, 2005 11:31 am
by voronwe
Hey All

A new version is now on my website, the script will do the same as before, but this time i have changed it so the minimum amount of ram installed in the server have to be 256MB of ram, this will result in a shared memory size of 128MB witch is half of the installed, the previous script needed 512MB of ram installed in the server.

Use the link in the above post to get the script.

Posted: Wed May 18, 2005 8:21 pm
by voronwe
Hey all

Within the next few days the link to this script wil change to the following. :

http://www.dvos.dk/zm/shared.sh

Posted: Tue Jul 26, 2005 3:16 pm
by jameswilson
whats all this about proxies apearing in several posts?

Posted: Tue Jul 26, 2005 3:28 pm
by SyRenity
Forum spam? Hope it's not a robot, otherwise we will have all the forum full of these.

Posted: Tue Jul 26, 2005 8:02 pm
by Ruler
This *exact* same thing appeared on a hunting/fishing site I'm also a member of.