修改上一篇的memcached启动脚本的相关配置参数就得到magent的启动脚本了,跟memcached的启动脚本一样,只修改如下的相关参数即可:
MAGENT_CONF=" -u root -n 51200 -l 192.168.10.11 -p 12000 -s 192.168.10.12:11211 192.168.10.13:11211 -b 192.168.101.11:11211 "
magent相关参数参考:
memcached agent v0.4 Build-Date: Mar 28 2012 06:20:51
Usage:
-h this message
-u uid
-g gid
-p port, default is 11211. (0 to disable tcp support)
-s ip:port, set memcached server ip and port
-b ip:port, set backup memcached server ip and port
-l ip, local bind ip address, default is 0.0.0.0
-n number, set max connections, default is 4096
-D don't go to background
-k use ketama key allocation algorithm
-f file, unix socket path to listen on. default is off
-i number, set max keep alive connections for one memcached server, default is 20
-v verbose
完整脚本如下:
#!/bin/sh # # And add me to system start # chmod +x magent # chkconfig --add magent # chkconfig --level 35 magent on # # Written by jason.kou # Last updated: 2012-08-17 # # chkconfig: - 85 15 # description: Distributed memory caching daemon # processname: magent # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 memcached="/usr/local/magent/magent" prog=$(basename $memcached) MAGENT_CONF=" -u root -n 51200 -l 192.168.10.11 -p 12000 -s 192.168.10.12:11211 192.168.10.13:11211 -b 192.168.10.11:11211 " lockfile=/var/lock/subsys/magent start() { [ -x $memcached ] || exit 5 echo -n $"Starting $prog: " daemon $memcached $MAGENT_CONF retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { stop start } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) $1 rh_status_q || exit 0 $1 ;; stop) stop ;; restart|configtest) $1 ;; status) rh_status ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 2 esac
本文出自 “Centi.Linux” 博客,请务必保留此出处http://centilinux.blog.51cto.com/1454781/965937