PDA

View Full Version : Setting shmmax in /etc/rc to install Postgres




duggram
Jul 3, 2009, 08:37 AM
How do I set shmmax in /etc/rc? Literally what would the entry look like and where do I put it in the file?

I'm revisiting a problem I've had for a while now. I can't run Postres on my MBP, OS X 10.5.7, 4GB RAM, because I can't set shmmax.

Here are the sys requirements from the postgres readme:
On a MacBook Pro with 2GB of RAM, the author's sysctl.conf contains:

kern.sysv.shmmax=1610612736
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
kern.maxproc=2048

My current sysctl.conf file but the shmmax is never set:
kern.sysv.shmmax=4292870144
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
kern.maxproc=2048

Results from doing a sysctl -a show that I only have a fraction of the shmmax memory required by Postgres to run. In fact when I try to start Postgres it throws up an error message and quits.
kern.sysv.shmall: 393216
kern.sysv.shmseg: 8
kern.sysv.shmmni: 32
kern.sysv.shmmin: 1
kern.sysv.shmmax: 4194304
kern.sysv.semume: 10
kern.sysv.semmsl: 87381
kern.sysv.semmnu: 87381
kern.sysv.semmns: 87381
kern.sysv.semmni: 87381


There is this post from another thread:
http://joseph.randomnetworks.com/archives/2004/07/06/tweaking-mac-os-x-sysctl-values/

That post has a discussion about this. The sysctl command will change things for the current session, but you'll need to change the value in /etc/rc or all shmem values in sysctl.conf for this to survive a reboot. ...
-Lee

Here is my current rc.common file:
##
# Common setup for startup scripts.
##
# Copyright 1998-2002 Apple Computer, Inc.
##

#######################
# Configure the shell #
#######################

##
# Be strict
##
#set -e
set -u

##
# Set command search path
##
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices; export PATH

##
# Set the terminal mode
##
#if [ -x /usr/bin/tset ] && [ -f /usr/share/misc/termcap ]; then
# TERM=$(tset - -Q); export TERM
#fi

####################
# Useful functions #
####################

##
# Determine if the network is up by looking for any non-loopback
# internet network interfaces.
##
CheckForNetwork()
{
local test

if [ -z "${NETWORKUP:=}" ]; then
test=$(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l)
if [ "${test}" -gt 0 ]; then
NETWORKUP="-YES-"
else
NETWORKUP="-NO-"
fi
fi
}

alias ConsoleMessage=echo

##
# Process management
##
GetPID ()
{
local program="$1"
local pidfile="${PIDFILE:=/var/run/${program}.pid}"
local pid=""

if [ -f "${pidfile}" ]; then
pid=$(head -1 "${pidfile}")
if ! kill -0 "${pid}" 2> /dev/null; then
echo "Bad pid file $pidfile; deleting."
pid=""
rm -f "${pidfile}"
fi
fi

if [ -n "${pid}" ]; then
echo "${pid}"
return 0
else
return 1
fi
}

##
# Generic action handler
##
RunService ()
{
case $1 in
start ) StartService ;;
stop ) StopService ;;
restart) RestartService ;;
* ) echo "$0: unknown argument: $1";;
esac
}

##########################
# Get host configuration #
##########################
. /etc/hostconfig


Any suggestions would be greatly appreciated.

Thank you, Doug