我刚在Ubuntu 11.04(这是我的开发服务器)上安装了memcached。 在安装过程中,脚本安排memcached在启动时自动启动。 太棒了,就是我所需要的。
除此之外,我需要2个(或者可能是3个)不同的memcached bin(换句话说,一个在端口11211上,一个在11212上),但是我找不到在哪里configurationubuntu来在启动时启动两个memcached实例。
我目前使用的是memcached 1.4.5
根据请求,我的/etc/init.d/memcached文件如下所示:
#! /bin/sh ### BEGIN INIT INFO # Provides: memcached # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: $local_fs # Should-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start memcached daemon # Description: Start up memcached, a high-performance memory caching daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/memcached DAEMONBOOTSTRAP=/usr/share/memcached/scripts/start-memcached NAME=memcached DESC=memcached PIDFILE=/var/run/$NAME.pid test -x $DAEMON || exit 0 test -x $DAEMONBOOTSTRAP || exit 0 set -e . /lib/lsb/init-functions # Edit /etc/default/memcached to change this. ENABLE_MEMCACHED=no test -r /etc/default/memcached && . /etc/default/memcached case "$1" in start) echo -n "Starting $DESC: " if [ $ENABLE_MEMCACHED = yes ]; then start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP echo "$NAME." else echo "$NAME disabled in /etc/default/memcached." fi ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON echo "$NAME." rm -f $PIDFILE ;; restart|force-reload) # # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # echo -n "Restarting $DESC: " start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE rm -f $PIDFILE sleep 1 start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP echo "$NAME." ;; status) status_of_proc $DAEMON $NAME ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac exit 0
所以,如果你读取/etc/init.d/memcached文件,你可以看到这个
FILES =(在/ etc /分布式caching_ *。CONF)。
所以,我相信如果你只是用这个设置创build一个memcached_1.conf文件,那么它将会用新的端口(在你创build的文件中给出)运行一个memcached进程。
您可以从/etc/memcached.conf中获取示例文件并将其复制到/etc/memcached_1.conf。
只需要replace默认的端口11211,就像11212一样。
并重新启动系统。 它应该用新的端口和configs运行一个memcached二进制文件。