4 Redis Servers
172.16.1.37:6379-1
172.16.1.36:6379-2
172.16.1.35:6379-3
172.16.1.34:6379-4
Installing autoconf
CentOS 7 Yum installation is available, autoconf version must be more than 2.64 versions
Yum-y Install autoconf
Installing Twemproxy
git clone https://github.com/twitter/twemproxy.git
Autoreconf-fvi #生成configure文件
./configure--prefix=/opt/local/twemproxy/--enable-debug=log
Make && make install
Mkdir-p/opt/local/twemproxy/{run,conf,logs}
Ln-s/opt/local/twemproxy/sbin/nutcracker/usr/bin/
cd/opt/local/twemproxy/conf/
VI nutcracker.yml #编辑配置文件
---------------------------------------------------------------------------------------
Alpha
listen:172.16.1.37:6380 #监听端口
hash:fnv1a_64 #key值hash算法, default fnv1a_64
Distribution:ketama #分布算法
#ketama一致性hash算法; Modula is very simple, is based on the key value of the hash value of the modulo; random randomly distributed
Auto_eject_hosts:true #摘除后端故障节点
Redis:true #是否是redis缓存, default is False
timeout:400 #代理与后端超时时间, MS
server_retry_timeout:200000 #摘除故障节点后重新连接的时间, MS
Server_failure_limit:1 #故障多少次摘除
Servers
-172.16.1.34:6379:1
-172.16.1.35:6379:1
-172.16.1.36:6379:1
-172.16.1.37:6379:1
---------------------------------------------------------------------------------------
Nutcracker-t-c/opt/local/twemproxy/conf/nutcracker.yml #检查配置文件是否正确
nutcracker-d-c/opt/local/twemproxy/conf/nutcracker.yml-p/opt/local/twemproxy/run/redisproxy.pid-o/opt/local/ Twemproxy/logs/redisproxy.log #启动
Redis Cache Proxy Twemproxy