CentOS Icon CentOS Logo
CentOS Text
   
  
www.centos.org Forum Index
   CentOS 4 - Server Support
  MemCached

 

 Bottom   Previous Topic   Next Topic
  •  Rate Thread
      Rate this Thread
      Excellent
      Good
      Average
      Bad
      Terrible
Poster Thread
  •  just1coder
      just1coder
MemCached
#1
Newbie
Joined: 2007/4/19
From
Posts: 4
I'm using MemCached with CentOS Server 4.4 with excellent results. However, I am not too sure how I can configure CentOS to automatically load MemCached after a server reboot. Any help would be most appriciated.
Posted on: 2007/4/19 13:00
Create PDF from Post Print
Top
  •  decals74
      decals74
Re: MemCached
#2
Newbie
Joined: 2007/4/29
From
Posts: 6
here's an init script for you:

############################################################################

#!/bin/bash
# init script for memcached
# chkconfig: 2345 70 11
# description: memcached
# processname: memcached
# pidfile: /var/run/memcached.pid

# Source function library.
. /etc/rc.d/init.d/functions

PATH=$PATH:/usr/local/bin
lockfile=/var/lock/subsys/memcached
logfile=/var/log/memcached
pidfile=/tmp/memcached.pid
prog=memcached
memcached=/usr/local/bin/memcached
RETVAL=0

start () {

# find IP address on specific subnet
ipaddr=`ifconfig | grep "192\.168\.0" | awk '{print $2}' | cut -d : -f 2`

size=6144 # total cache size in MB
port=11211 # port number to run on
user=nobody # run as user
opts="-d -m $size -l $ipaddr -p 11211 -u $user"

# quit if IP address doesn't exist
if [[ -z $ipaddr ]];then
echo "IP address not found. please fix. exiting
."
exit 1
fi

echo -n $"Starting $prog: "
daemon $memcached $opts
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}

stop () {
echo -n $"Stopping $prog: "
killproc memcached
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/memcached /var/run/memcached.pid
}

status () {
psline1=`ps auxwww|grep -P "^USER"|grep -v grep`
psline2=`ps auxwww|grep -P "^www\ .*memcached"|grep -v grep`
if [[ -z $psline2 ]];then
echo "memcached is not running"
else
echo "$psline1
$psline2"
fi
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
sleep 1
start
;;
*)
echo $"Usage: `basename $0` {start|stop|restart|status}"
exit 2
esac

############################################################################

change vars as necessary, you'll probably need to edit $ipaddr, $size, $port and $user. copy the script to /etc/init.d/memcached and then run `chkconfig --add memcached` and you should be set.

OR

do it a lil more ghetto and drop a one liner into /etc/rc.local like:
/path/to/memcached -d -m 2048 -l 10.10.10.1 -p 11211 -u nobody
Posted on: 2007/5/1 12:02
Create PDF from Post Print
Top
  •  just1coder
      just1coder
Re: MemCached
#3
Newbie
Joined: 2007/4/19
From
Posts: 4
I tried the 'gheto' method but it didn't seem to work.. i'll try the other now...
Posted on: 2007/5/10 15:40
Create PDF from Post Print
Top
  •  tbb9216
      tbb9216
Re: MemCached
#4
Newbie
Joined: 2007/7/11
From
Posts: 1
i too am trying to set up memcached on centos 4.4 (mediatemple dv base package). it has been a nightmare, first it was pecl issues (phpize to be exact), now its that php cant load the memcache.so file.

would it be too much to ask how you installed memcached + pecl/memcache? and also, did this autoload script end up working for you?

thanks,

tim garrison
Posted on: 2007/7/11 6:19
Create PDF from Post Print
Top
 Top   Previous Topic   Next Topic

 


 You cannot start a new topic.
 You can view topic.
 You cannot reply to posts.
 You cannot edit your posts.
 You cannot delete your posts.
 You cannot add new polls.
 You cannot vote in polls.
 You cannot attach files to posts.
 You cannot post without approval.




"Linux" is a registered trademark of Linus Torvalds. | All other trademarks are property of their respective owners. | All other content is Copyright @ 2004-2009 by the CentOS Project or "each individual contributor (forums, comments, etc.) unless otherwise assigned".| Theme based on a theme by 7dana.com