nacos集群模式部署unabletofindlocalpeer:122.123.68.4。。。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
nacos集群模式部署unabletofindlocalpeer:122.123.68.4。
错误原因:
nacos获取的ip是外⽹ip:122.123.68.456 ,⽽cluster.config中配置的是内⽹ip:192.168.10.53
解决办法,有三种:
1、java启动脚本中增加:-Dnacos.server.ip=192.168.10.53
2、(推荐⽅式)application.properties增加nacos.inetutils.ip-address=192.168.10.53
3、修改cluster.config中的192.168.10.53为外⽹地址:122.123.68.456
关于nacos ip获取的说明:
1、先看看Jvm属性配置了nacos.server.ip=IP地址没有;如果有就是它;
2、如果1中没有,则看看配置⽂件application.properties中有没有属性nacos.inetutils.ip-address=IP地址;如果有就是它
3、如果还没有,那判断是否优先使⽤hostname;preferHostnameOverIp 的判断逻辑是;先判断JVM属性有没有配置
nacos.preferHostnameOverIp=true/false;如果false,再去判断配置⽂件application.properties中有没有属性 nacos.inetutils.prefer-hostname-over-ip=true/false;如果有的话就优先获取hostname; inetAddress.getHostName();
4、否则的话就获取所有⽹卡中第⼀个⾮回环地址
selfIp = findFirstNonLoopbackAddress().getHostAddress();
就是不会找到 127.0.0.1这样的回环地址;
具体代码在类 InetUtils中;
selfIp = findFirstNonLoopbackAddress().getHostAddress();
附1:
附2:异常详细信息内容:
2020-05-09 10:50:30,000 ERROR Unexpected error occurred in scheduled task.
ng.IllegalStateException: unable to find local peer: 122.123.68.456:8848, all peers: [192.168.10.53:8848, 192.168.10.53:8849, 192.168.10.53:8850]
at com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeerSet.local(RaftPeerSet.java:224)
at com.alibaba.nacos.naming.monitor.PerformanceLoggerThread.collectMetrics(PerformanceLoggerThread.java:100)
at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at ng.reflect.Method.invoke(Method.java:498)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at ng.Thread.run(Thread.java:748)。