标签:twemproxy
1、安装memcached
yum install memcached python-memcached -y
sed -i ‘/MAXCONN/s/"1024"/"8192"/‘ /etc/sysconfig/memcached
sed -i ‘/CACHESIZE/s/"64"/"2048"/‘ /etc/sysconfig/memcached
sed -i "/OPTIONS/s/\"\"/\"-l $first_net_if_ip\"/" /etc/sysconfig/memcached
systemctl enable memcached.service
systemctl start memcached.service
2、安装twemproxy代理
cd /packet/
wget http://$yum_repo_server:8080/os-kilo-1/nutcracker-0.3.0.tar.gz
sleep 2
tar zxvf nutcracker-0.3.0.tar.gz
sleep 5
cd nutcracker-0.3.0/
./configure --prefix=/usr/local/twemproxy
sleep 30
make
sleep 10
make install
sleep 20
mkdir /usr/local/twemproxy/run /usr/local/twemproxy/conf/
cd /usr/local/twemproxy/conf/
cat >/usr/local/twemproxy/conf/nutcracker.yum << EOF
delta:
listen: $control_vip:11211
hash: fnv1a_64
distribution: ketama
timeout: 100
auto_eject_hosts: true
server_retry_timeout: 2000
server_failure_limit: 1
servers:
- $control_first_ip:11211:1
- $control_second_ip:11211:1
- $control_third_ip:11211:1
EOF
3、启动twemproxy服务
/usr/local/twemproxy/sbin/nutcracker -d -c /usr/local/twemproxy/conf/nutcracker.yum -p /usr/local/twemproxy/run/memproxy.pid -o /usr/local/twemproxy/run/memproxy.log
4、配置twemproxy的启动项及设置开机自启动
cat >/etc/rc.d/init.d/twemproxy <<EOF
#! /bin/sh
# chkconfig: 2345 10 90
# description: myservice ....
set -e
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/haproxy/sbin
PROGDIR=/usr/local/twemproxy/
PROGNAME=twemproxy
DAEMON=/usr/local/twemproxy/sbin/nutcracker
CONFIG=/usr/local/twemproxy/conf/nutcracker.yum
PIDFILE=/usr/local/twemproxy/run/memproxy.pid
DESC="Twemproxy daemon"
SCRIPTNAME=/etc/init.d/twemproxy
PROGLOG=/usr/local/twemproxy/run/memproxy.log
# Gracefully exit if the package has been removed.
test -x \$DAEMON || exit 0
start()
{
echo -n "Starting \$DESC: \$PROGNAME"
\$DAEMON -d -c \$CONFIG -p \$PIDFILE -o \$PROGLOG
echo "."
}
stop()
{
echo -n "Stopping \$DESC: \$PROGNAME"
haproxy_pid=`cat \$PIDFILE`
kill \$haproxy_pid
echo "."
}
restart()
{
echo -n "Restarting \$DESC: \$PROGNAME"
haproxy_pid=`cat \$PIDFILE`
kill \$haproxy_pid
\$DAEMON -d -c \$CONFIG -p \$PIDFILE -o \$PROGLOG
echo "."
}
case "\$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: \$SCRIPTNAME {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
EOF
chmod +x /etc/rc.d/init.d/twemproxy
chkconfig twemproxy on
本文出自 “zhanguo1110” 博客,请务必保留此出处http://zhanguo1110.blog.51cto.com/5750817/1693885
标签:twemproxy
原文地址:http://zhanguo1110.blog.51cto.com/5750817/1693885