Solution to the problem of failure to elect leaders when offline service is reported in Nacos

Problem description

When there are multiple instances of a micro service in the Nacos registry, click an instance to go offline and report an error

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;

Solution

Nacos uses the raft algorithm to calculate the leader and will record the cluster address started last time. Therefore, when the IP address of our own server changes (especially the students started locally when we study, because sometimes our network environment will change… WiFi, so the IP address often changes), the cluster address recorded by raft will become invalid, If there is a problem with the selected leader, just delete the protocol folder under the data folder under the root directory of Nacos.

Read More: