redis cluster


环境和版本

centos 7 + redis 5.0.3


Q&A

(1)、ConnectionError: Error 113 connecting to **. No route to host ?
          centos7 的防火墙限制问题,需要对iptables做权限解禁,具体可以网上search,本文较为简单,只是测试所以使用命令暂时关闭iptables
        iptables -X;  iptables -F
        还可以关闭SELinux
        setenforce 0

    (2)、Error 111 connecting to ***. Connection refused.
        1 检查目标机器是否开启了集群,端口号是否一致,具体使用 ps ,grep

ps -ef | grep redis
netstat -tnlp | grep redis

        2 查验集群的node实例配置文件

#这里绑定了机器的IP,只有该ip的机器才能链接redis,默认绑定127.0.0.1,可以注释掉
 bind 127.0.0.1

(3)、CLUSTERDOWN Hash slot not served
      开启了redis实例但未开启cluster服务,可以链接实例查看

redis-cli -c -h 172.16.74.100 -p 7005
172.16.74.100:7005> ping
PONG

172.16.74.100:7005> cluster nodes
2e11102c38d6a9bcb1a5febbc159473dd380f25f :7005@17005 myself,master - 0 0 0 connected

(4)、 172.16.74.100:7000> get foo
-> Redirected to slot [12182] located at 127.0.0.1:7002
Could not connect to Redis at 127.0.0.1:7002: Connection refused
        开启cluster时node节点ip使用了local地址,造成remote端使用时重定向到集群其他的node地址错误

# 创建集群时 127.0.0.1地址只能在本机可以正确重定向
./redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1    

# remote端查看cluster nodes
172.16.74.100:7000> cluster nodes

2e11102c38d6a9bcb1a5febbc159473dd380f25f 127.0.0.1:7005@17005 slave 2abdd853242075a44b3cf21b3a591e6e3fe495d4 0 1547194471000 6 connected7ebe512dc236d4fd71a516cb81acd2859512e185 127.0.0.1:7001@17001 master - 0 1547194471000 2 connected 5461-10922f5db76edd7c7417ff15115d56cb436913ca3a921 127.0.0.1:7002@17002 master - 0 1547194471905 3 connected 10923-16383e99275397d3628618f21a393036556d792c6eea2 127.0.0.1:7003@17003 slave 7ebe512dc236d4fd71a516cb81acd2859512e185 0 1547194472000 4 connected64540d116daf30c204428b323f6b62afe6fef731 127.0.0.1:7004@17004 slave f5db76edd7c7417ff15115d56cb436913ca3a921 0 1547194472507 5 connected2abdd853242075a44b3cf21b3a591e6e3fe495d4 127.0.0.1:7000@17000 myself,master - 0 1547194471000 1 connected 0-5460

# 需要使用本机的ip地址创建集群
./redis-cli --cluster create 172.16.74.100:7000 172.16.74.100:7001 172.16.74.100:7002 172.16.74.100:7003 172.16.74.100:7004 172.16.74.100:7005 --cluster-replicas 1


管理cluster启动停止


安装

参见: https://redis.io/topics/cluster-tutorial    
            

你可能感兴趣的:(redis cluster)