安装与配置
线上部署与安装, twenproxy 部署到170上,安装目录/opt/module/twenproxy
apt-get install automake
apt-get install libtool
git clone git://github.com/twitter/twemproxy.git
cd twemproxy
autoreconf -fvi
./configure --enable-debug=log
make
src/nutcracker -h
输入src/nutcracker -h 在命令行可以显示帮助信息,那么就证明安装成功
假如192.168.30.170的redis跟192.168.30.171的redis安装成功
现在通过twenproxy代理集群
直接看/opt/module/twenproxy/conf/nutcracker.xrk.yml配置文件,还有很多配置参数详细请看https://github.com/twitter/twemproxy
redis:
listen: 192.168.30.170:55555 #twenproxy部署在192.168.30.170:55555 上
hash: fnv1a_64
distribution: ketama
auto_eject_hosts: true
preconnect: true
server_connections: 50
redis: true
server_retry_timeout: 2000
server_failure_limit: 1
servers:
- 192.168.30.170:6379:1 #部署170的redis
- 192.168.30.171:6380:1 #部署171的redis
启动服务
cd /opt/module/twenproxy
#查看命令信息
./src/nutcracker -h
Usage: nutcracker [-?hVdDt] [-v verbosity level] [-o output file]
[-c conf file] [-s stats port] [-a stats addr]
[-i stats interval] [-p pid file] [-m mbuf size]
Options:
-h, --help : this help #帮助
-V, --version : show version and exit #版本
-t, --test-conf : test configuration for syntax errors and exit #测试配置文件是否有语法错误
-d, --daemonize : run as a daemon #是否守护进程启动
-D, --describe-stats : print stats description and exit #描述
-v, --verbosity=N : set logging level (default: 5, min: 0, max: 11)
-o, --output=S : set logging file (default: stderr)
-c, --conf-file=S : set configuration file (default: conf/nutcracker.yml) #指定配置文件
-s, --stats-port=N : set stats monitoring port (default: 22222) #端口
-a, --stats-addr=S : set stats monitoring ip (default: 0.0.0.0) #设置地址
-i, --stats-interval=N : set stats aggregation interval in msec (default: 30000 msec)
-p, --pid-file=S : set pid file (default: off)
-m, --mbuf-size=N : set size of mbuf chunk in bytes (default: 16384 bytes)
#查看命令信息
#启动命令
1. 为了方便调试启动
./src/nutcracker -c /opt/module/twenproxy/conf/nutcracker.xrk.yml
2.守护进程启动
./src/nutcracker -d -c /opt/module/twenproxy/conf/nutcracker.xrk.yml
连接并测试是否成功
redis-cli -h 192.168.30.170 -p 55555
连接失败:
提示信息:Could not connect to Redis at 192.168.30.170:55555: Connection refused
连接成功:
提示信息:redis 192.168.30.170:55555>
set key1 1
get key1
以上是twenproxy安装配置与测试连接