Nacos单机模式下注册服务返回503

错误日志:

request: /nacos/v1/ns/instance/beat failed, servers: [xxx.xxx.xx.xxxx:8848], code: 503, msg: server is DOWN now, please try again later!

[CLIENT-BEAT] failed to send beat: {"cluster":"DEFAULT","ip":"192.168.0.107","metadata":{"preserved.register.source":"SPRING_CLOUD"},"period":5000,"port":8080,"scheduled":false,"serviceName":"DEFAULT_GROUP@@ROUTEBASESERVICE","stopped":false,"weight":1.0}, code: 503, msg: failed to req API:/api//nacos/v1/ns/instance/beat after all servers([192.168.0.107:8848]) tried: server is DOWN now, please try again later!

protocol-raft.log中日志:

java.lang.IllegalArgumentException: Blank leader

at com.alipay.sofa.jraft.util.Requires.requireTrue(Requires.java:85)

at com.alipay.sofa.jraft.RouteTable.updateLeader(RouteTable.java:181)

at com.alipay.sofa.jraft.RouteTable.refreshLeader(RouteTable.java:264)

at com.alibaba.nacos.core.distributed.raft.JRaftServer.refreshRouteTable(JRaftServer.java:501)

at com.alibaba.nacos.core.distributed.raft.JRaftServer.lambda$createMultiRaftGroup$1(JRaftServer.java:276)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

2020-12-21 16:41:50,677 INFO shutdown jraft server

start.out输出正常

背景:

1、nacos版本:1.4;jdk8

2、单机模式下(非首次启动)config可以正确注册获取,discovery无法正常注册服务

错误原因:

nacos1.4.0使用了jraft, jraft会记录前一次启动的集群地址,如果重启机器ip变了的话,会导致jraft记录的地址失效,从而导致选主出问题。

解决办法:

删除{nacos.home}/nacos/data/protocol文件夹后重新启动

参考资料:

https://github.com/alibaba/nacos/issues/4210

你可能感兴趣的:(Nacos单机模式下注册服务返回503)