1. 问题:fail,noaddr
查看集群的节点信息
192.168.1.150:8007> cluster nodes
c23a3958115789474a2b056a5cc1e507b56578f3 :0@0 master,fail,noaddr - 1698141989085 1698141985076 13 disconnected
ea191d707d0f69c2dd520cb0548f3459185b88d2 :0@0 master,fail,noaddr - 1698142013042 1698142010134 15 disconnected
72999f45b138940d65692e8f9c9f52d75df64fff :0@0 master,fail,noaddr - 1698306487358 1698306484000 11 disconnected
fd4d8f622f8775debb3f5edf007f99971ab376ca 192.168.1.33:8005@18005 master - 0 1698306681044 18 connected 12288-16383
ae08442ba278f8ad62c8f82e0a25a9ca1efbe043 192.168.1.200:8004@18004 slave ed604208cf43e7b2490ff2640ae17e0ff590ef5e 0 1698306681000 12 connected
bf352d47f8c4559b3bf54aecc0f2f75687eac4e2 192.168.1.150:8008@18008 slave fd4d8f622f8775debb3f5edf007f99971ab376ca 0 1698306680000 18 connected
97213c070778004be59498f17ce4605b6147dacc 192.168.1.33:8006@18006 slave fd4d8f622f8775debb3f5edf007f99971ab376ca 0 1698306680042 18 connected
84d4bc3e46a829df205f645867468f5ec44682e9 192.168.1.150:8007@18007 myself,slave 96c7ce1ea3a57ad49a75e857c676aee8f2fb6011 0 1698306678000 10 connected
281bf9970db59d644caa5fc6b34d0040e36544ef 192.168.1.60:8002@18002 slave 96c7ce1ea3a57ad49a75e857c676aee8f2fb6011 0 1698306682047 16 connected
ed604208cf43e7b2490ff2640ae17e0ff590ef5e 192.168.1.200:8003@18003 master - 0 1698306678039 12 connected 5461-12287
96c7ce1ea3a57ad49a75e857c676aee8f2fb6011 192.168.1.60:8001@18001 master - 0 1698306680000 16 connected 0-5460
查看集群状态,发现其中三个节点异常(是fail状态),发现它已脱离集群。
2. cluster nodes节点信息解读
cluster nodes显示的每一行信息,由下面的字段组成。
ip:port …
2.1 每个字段的含义
-
id: 节点ID,一个40字节的随机字符串,节点创建时生成,且不会变化(除非使用CLUSTER RESET HARD命令)。
-
ip:port: 客户端访问的地址。
-
flags: 逗号分隔的标记位,可能值有:myself, master, slave, fail?, fail, handshake, noaddr, noflags。
-
master: 若是已知master节点的slave,这里出现的是master的节点ID,否则是"-"。
-
ping-sent: 最近一次发送ping的unix毫秒时间戳,0代表没有发送过。
-
pong-recv: 最近一次收到pong的unix毫秒时间戳。
-
config-epoch: 该节点或其master节点的epoch值。每次故障转移都会生成一个新的,唯一的,递增的epoch值。若多个节点竞争相同的slot,epoch值大的获胜。
-
link-state: 节点和集群总线间的连接状态,可以是connected或disconnected。
-
slot: 该节点负责的slot。
2.2 flags字段各标记含义
myself: 当前连接的节点。
master: 节点是master。
slave: 节点是slave。
fail?: 节点处于pfail状态,当前节点无法和其联系,但其它节点可以。
fail: 节点处于fail状态,大多数节点都无法和其联系,将其由pfail升级到fail状态。
handshake: 还没完全加入集群,正在握手阶段。
noaddr: 不知道节点地址。
noflags: 没有任何标记。
3. redis集群fail,noaddr问题解决
redis版本:
[root@hecs99567]$ redis-cli -v
redis-cli 5.0.8
解决方式:
登录集群并执行cluster forget 将故障节点id移除
[root@hecs99567]$ redis-cli -h 192.168.1.150 -p 8007 -a 123456 -c
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.1.150:8007>
192.168.1.150:8007> cluster forget 72999f45b138940d65692e8f9c9f52d75df64fff
OK
192.168.1.150:8007> cluster forget ea191d707d0f69c2dd520cb0548f3459185b88d2
OK
192.168.1.150:8007> cluster forget c23a3958115789474a2b056a5cc1e507b56578f3
OK
192.168.1.150:8007> cluster nodes
fd4d8f622f8775debb3f5edf007f99971ab376ca 192.168.1.33:8005@18005 master - 0 1698306681044 18 connected 12288-16383
ae08442ba278f8ad62c8f82e0a25a9ca1efbe043 192.168.1.200:8004@18004 slave ed604208cf43e7b2490ff2640ae17e0ff590ef5e 0 1698306681000 12 connected
bf352d47f8c4559b3bf54aecc0f2f75687eac4e2 192.168.1.150:8008@18008 slave fd4d8f622f8775debb3f5edf007f99971ab376ca 0 1698306680000 18 connected
97213c070778004be59498f17ce4605b6147dacc 192.168.1.33:8006@18006 slave fd4d8f622f8775debb3f5edf007f99971ab376ca 0 1698306680042 18 connected
84d4bc3e46a829df205f645867468f5ec44682e9 192.168.1.150:8007@18007 myself,slave 96c7ce1ea3a57ad49a75e857c676aee8f2fb6011 0 1698306678000 10 connected
281bf9970db59d644caa5fc6b34d0040e36544ef 192.168.1.60:8002@18002 slave 96c7ce1ea3a57ad49a75e857c676aee8f2fb6011 0 1698306682047 16 connected
ed604208cf43e7b2490ff2640ae17e0ff590ef5e 192.168.1.200:8003@18003 master - 0 1698306678039 12 connected 5461-12287
96c7ce1ea3a57ad49a75e857c676aee8f2fb6011 192.168.1.60:8001@18001 master - 0 1698306680000 16 connected 0-5460
4. cluster指令
# 先删除7003 节点
CLUSTER FORGET <node_id> 从集群中移除 node_id 指定的节点。
# 在将7003加入到集群中
CLUSTER MEET <ip> <port> 将 ip 和 port 所指定的节点添加到集群当中,让它成为集群的一份子。
全部指令通过cluster help查询
192.168.1.150:8007> cluster help
1) CLUSTER <subcommand> arg arg ... arg. Subcommands are:
2) ADDSLOTS <slot> [slot ...] -- Assign slots to current node.
3) BUMPEPOCH -- Advance the cluster config epoch.
4) COUNT-failure-reports <node-id> -- Return number of failure reports for <node-id>.
5) COUNTKEYSINSLOT <slot> - Return the number of keys in <slot>.
6) DELSLOTS <slot> [slot ...] -- Delete slots information from current node.
7) FAILOVER [force|takeover] -- Promote current replica node to being a master.
8) FORGET <node-id> -- Remove a node from the cluster.
9) GETKEYSINSLOT <slot> <count> -- Return key names stored by current node in a slot.
10) FLUSHSLOTS -- Delete current node own slots information.
11) INFO - Return onformation about the cluster.
12) KEYSLOT <key> -- Return the hash slot for <key>.
13) MEET <ip> <port> [bus-port] -- Connect nodes into a working cluster.
14) MYID -- Return the node id.
15) NODES -- Return cluster configuration seen by node. Output format:
16) <id> <ip:port> <flags> <master> <pings> <pongs> <epoch> <link> <slot> ... <slot>
17) REPLICATE <node-id> -- Configure current node as replica to <node-id>.
18) RESET [hard|soft] -- Reset current node (default: soft).
19) SET-config-epoch <epoch> - Set config epoch of current node.
20) SETSLOT <slot> (importing|migrating|stable|node <node-id>) -- Set slot state.
21) REPLICAS <node-id> -- Return <node-id> replicas.
22) SLOTS -- Return information about slots range mappings. Each range is made of:
23) start, end, master and replicas IP addresses, ports and ids
5. 相关文章
(1) redis集群搭建
(2) 华为云两台机器内网互联
(3) /etc/rc.d/init.d 详解|程序开机自启
(4) Redis5.0+ Redis集群水平扩容|节点删除
(5) 三台机器搭建redis集群过程及问题记录
(6) redis5.0集群搭建(两台服务器)
(7) Linux安装部署Redis
(8) 【redis】 windows环境下安装、配置、使用、卸载
(9) CentOS chkconfig的安装及使用
(10) 解决Linux局域网不能相互访问
(11) redis集群中节点fail,noaddr
6. 参考文献
https://blog.csdn.net/ximaiyao1984/article/details/130616598
https://blog.csdn.net/zzhongcy/article/details/119914677