https://github.com/twitter/twemproxy
1. 按照Git主页的安装方法安装,需要安装automake和libtool
yum install automake libtool
2. 执行autoreconf和make
$ git clone git@github.com:twitter/twemproxy.git
$ cd twemproxy
$ autoreconf -fvi
$ ./configure --enable-debug=full
$ make
$ src/nutcracker -h
3. 如果执行autoreconf时报错autoconf版本低,需更新autoconf
[root@node01 twemproxy]# autoreconf -fvi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
configure.ac:8: error: Autoconf version 2.64 or higher is required
configure.ac:8: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
aclocal: autom4te failed with exit status: 63
autoreconf: aclocal failed with exit status: 63
[root@node01 twemproxy]# cd /etc/yum.repos.d
[root@node01 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
- 查找autoconf更新版本
[root@node01 twemproxy]# yum search autoconf
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* centos-sclo-rh: mirrors.bfsu.edu.cn
* centos-sclo-sclo: mirrors.neusoft.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
epel | 4.7 kB 00:00
epel/primary_db | 6.1 MB 00:01
============================================================================================= N/S Matched: autoconf =============================================================================================
php-horde-Horde-Mail-Autoconfig.noarch : Horde Mail Autoconfiguration
autoconf.noarch : A GNU tool for automatically configuring source code
autoconf213.noarch : A GNU tool for automatically configuring source code
autoconf268.noarch : A GNU tool for automatically configuring source code
Name and summary matches only, use "search all" for everything.
- 安装autoconf268
yum install autoconf268
- 回到第二步,完成安装
4. 启动配置
进入源码包中的scripts文件夹
[root@node01 scripts]# cp nutcracker.init /etc/init.d/twemproxy
[root@node01 scripts]# cd /etc/init.d
[root@node01 init.d]# chmod +x twemproxy
查看这个启动脚本里的相关配置,并按照其要求进行如下配置
[root@node01 init.d]# vi twemproxy
[root@node01 init.d]# mkdir /etc/nutcracker
[root@node01 init.d]# cp /root/GitRepository/twemproxy/conf/nutcracker.yml /etc/nutcracker/
[root@node01 init.d]# cp /root/GitRepository/twemproxy/src/nutcracker /usr/bin
5. 基本使用
- 修改配置文件,设置两个redis server
alpha:
listen: 127.0.0.1:22121
hash: fnv1a_64
distribution: ketama
auto_eject_hosts: true
redis: true
server_retry_timeout: 2000
server_failure_limit: 1
servers:
- 127.0.0.1:6379:1
- 127.0.0.1:6380:1
- 启动服务
[root@node01 init.d]# service twemproxy start
- 分别开启两个redis server
[root@node01 6380]# redis-server --port 6379
[root@node01 6380]# redis-server --port 6380
- 使用redis-cli连接配置的22121端口进行测试
[root@node01 ~]# redis-cli -p 22121