问题描述
公司搭建了nacos集群,但是在微服务下线时会无法正常下线,点击下线提示
caused: errCode: 500, errMsg: do metadata operation failed ;caused: com.alibaba.nacos.consistency.exception.ConsistencyException: com.alibaba.nacos.core.distributed.raft.exception.NoLeaderException: The Raft Group [naming_instance_metadata] did not find the Leader node;caused: com.alibaba.nacos.core.distributed.raft.exception.NoLeaderException: The Raft Group [naming_instance_metadata] did not find the Leader node;
ERROR Fail to refresh route configuration for group : naming_instance_metadata, status is : Status[UNKNOWN<-1>: Fail to get leader of group naming_instance_metadata]
ERROR Fail to refresh route configuration for group : naming_service_metadata, status is : Status[UNKNOWN<-1>: Fail to get leader of group naming_service_metadata]
解决方案
单机情况下直接删除data/protocol文件夹重启就可以解决,但是我们使用的是集群部署的模式,尝试删除此文件夹重启后问题依旧存在。经过对比发现集群节点的元数据是不正常的
{
"lastRefreshTime": 1648556157101,
"raftMetaData": {
"metaDataMap": {
"naming_persistent_service": {
"leader": "192.168.96.77:7848",
"raftGroupMember": [
"192.168.96.77:7848",
"192.168.96.79:7848",
"192.168.96.82:7848"
],
"term": 5
}
}
},
"raftPort": "7848",
"version": "2.0.3"
}
下面才是正常的元数据
{
"lastRefreshTime": 1648604205057,
"raftMetaData": {
"metaDataMap": {
"naming_instance_metadata": {
"leader": "192.168.3.156:7852",
"raftGroupMember": [
"192.168.3.156:7852",
"192.168.3.156:7848",
"192.168.3.156:7850"
],
"term": 29
},
"naming_persistent_service": {},
"naming_persistent_service_v2": {
"leader": "192.168.3.156:7852",
"raftGroupMember": [
"192.168.3.156:7852",
"192.168.3.156:7848",
"192.168.3.156:7850"
],
"term": 29
},
"naming_service_metadata": {
"leader": "192.168.3.156:7852",
"raftGroupMember": [
"192.168.3.156:7852",
"192.168.3.156:7848",
"192.168.3.156:7850"
],
"term": 29
}
}
},
"raftPort": "7848",
"readyToUpgrade": true,
"version": "2.0.4"
}
虽然本地的版本和线上的版本不一致,但是可以看出来正常的nacos集群选举出来的元数据有naming_persistent_service、naming_service_metadata、naming_instance_metadata这三个字段同时出现的。所以大概可以猜到是我们线上的nacos选举出现了问题。
检查了线上的各个端口后并没有发现端口不通的问题,经过查找资料,我认为应该是多个网卡导致的nacos识别网卡不正确导致的问题。
参考资料
https://blog.csdn.net/xim00_/article/details/115326322