1 瞭解一致性雜湊演算法
2 Redis-cluster的不足
配合keepalive會更好
1 準備6臺redis(至少3臺))
2 修改配置(6分)
bind 192.168.8.128
protected-mode yes
port 8601
daemonize yes
appendonly yes
3啟動
/usr/local/twemproxy-redis/redis01/bin/redis-server /usr/local/twemproxy-redis/redis01/etc/redis.conf
/usr/local/twemproxy-redis/redis02/bin/redis-server /usr/local/twemproxy-redis/redis02/etc/redis.conf
/usr/local/twemproxy-redis/redis03/bin/redis-server /usr/local/twemproxy-redis/redis03/etc/redis.conf
/usr/local/twemproxy-redis/redis04/bin/redis-server /usr/local/twemproxy-redis/redis04/etc/redis.conf
/usr/local/twemproxy-redis/redis05/bin/redis-server /usr/local/twemproxy-redis/redis05/etc/redis.conf
/usr/local/twemproxy-redis/redis06/bin/redis-server /usr/local/twemproxy-redis/redis06/etc/redis.conf
安裝 (參考 https://www.cnblogs.com/gomysql/p/4413922.html)
yum -y install autoconf automake libtool
unzip twemproxy-master.zip
cd twemproxy-master
autoreconf -fvi
./configure --prefix=/usr/local/twemproxy-redis
make
make install
建立資料夾
mkdir conf run
建立配置檔案
vim /usr/local/twemproxy-redis/conf/nutcracker.yml
alpha:
listen: 192.168.8.130:22121
hash: fnv1a_64
distribution: ketama
auto_eject_hosts: true
redis: true
server_retry_timeout: 2000
server_failure_limit: 1
servers:
- 192.168.8.130:8601:1
- 192.168.8.130:8602:1
- 192.168.8.130:8603:1
- 192.168.8.130:8604:1
- 192.168.8.130:8605:1
- 192.168.8.130:8606:1
測試配置檔案
[root@localhost twemproxy-redis]# ./sbin/nutcracker -t
nutcracker: configuration file 'conf/nutcracker.yml' syntax is ok
啟動twemproxy
./sbin/nutcracker -d -c /usr/local/twemproxy-redis/conf/nutcracker.yml -p /usr/local/twemproxy-redis/run/redisproxy.pid -o /usr/local/twemproxy-redis/run/redisproxy.log
ps -ef |grep nutcracker
root 21457 14891 0 21:12 pts/1 00:00:00 grep --color=auto nutcracker
測試連線
[root@localhost redis01]# ./bin/redis-cli -h 192.168.8.130 -p 22121
測試 B 和 QFF 在 8605 上面 關閉redis 8065測試 B 和 QFF 在 8605 上面 關閉redis 8065
2個pid
依然可以正常訪問
本作品採用《CC 協議》,轉載必須註明作者和本文連結