3个独立的master 三台主机都需要如下操作
[root@server5 redis]# redis-cli
127.0.0.1:6379> SLAVEOF no one
OK
127.0.0.1:6379> info
# Replication
role:master
connected_slaves:0
master_replid:c43f6e8ed4f1509f3b03ef20dff6293d4b1d91bd
master_replid2:e78d78cd05f8108cde5a77ca78e1d10509113eae
在开一台主机作为twemproxy
下载twemproxy-master.zip的压缩包
yum install unzip -y //安装解压工具
unzip twemproxy-master.zip
cd twemproxy-master
[root@server4 ~]# cd twemproxy-master
[root@server4 twemproxy-master]# ls
aclocal.m4 conf config.h.i libtool Makefile man README.md stamp-h1
autom4te.cache config config.log configure.ac LICENSE Makefile.am notes scripts tests
ChangeLog config.h config.status contrib m4 Makefile.in NOTICE src travis.sh
//没有这个configure 所以我们根据twemproxy-master的文档 需要automake 和 libtool 两个工具 然后我们需要安装这两个工具
[root@server4 twemproxy-master]# yum install -y automake libtool autoconf //安装完成后
[root@server4 twemproxy-master]#autoreconf -fvi
[root@server4 twemproxy-master]# ls
aclocal.m4 conf config.h.in configure libtool Makefile man README.md stamp-h1
autom4te.cache config config.log configure.ac LICENSE Makefile.am notes scripts tests
ChangeLog config.h config.status contrib m4 Makefile.in NOTICE src travis.sh //configure 有了
[root@server4 twemproxy-master]# ./configure
[root@server4 twemproxy-master]# make
[root@server4 twemproxy-master]#make install
[root@server4 etc]# cat /etc/tweproxy.yml
alpha:
listen:172.25.16.4:22121
hash:fnv1a_64
distribution:ketama
auto_eject_hosts:true
redis:true
server_retry_timeout:20000
server_failure_limit:1
servers:
- 172.25.16.2:6379:1
- 172.25.16.5:6379:1
- 172.25.16.20:6379:1
//在此文件中写入如下配置
[root@server4 etc]# nutcracker -d -c /etc/tweproxy.yml//打入后台 文件读取 --help获取更多的用法
[root@server4 twemproxy-master]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 172.25.16.4:22121 0.0.0.0:* LISTEN 10231/nutcracker
tcp 0 0 0.0.0.0:22222 0.0.0.0:* LISTEN 10231/nutcracker
//运行成功
此时我们需要将server2中的/usr/local/bin/redis-cli,scp传输到server4中操作如下
[root@server2 bin]# scp ./redis-cli root@172.25.16.4:/usr/local/bin/
The authenticity of host '172.25.16.4 (172.25.16.4)' can't be established.
ECDSA key fingerprint is SHA256:7cZjIzA/ySKInCxnMhoDDxOB5FeCk1p2ZI33E8pylF4.
ECDSA key fingerprint is MD5:f5:56:81:55:a3:fd:6b:97:c0:7a:21:a3:c4:5d:eb:4b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.25.16.4' (ECDSA) to the list of known hosts.
root@172.25.16.4's password:
redis-cli 100% 4695KB 70.6MB/s 00:00
[root@server2 bin]# 在这个servr2中操作
回到server4上
redis-cli -p 22121 -h 172.25.16.2
/可以访问到其他的master上在 server4中进行代理操作