问题:
2023-03-06 00:28:13.284 ERROR 329700 --- [t.remote.worker] c.a.n.c.remote.client.grpc.GrpcClient :99 - Server check fail, please check server 180.76.172.65 ,port 9848 is available , error ={}java.util.concurrent.ExecutionException: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: io exceptionat com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:566)at com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:445)at com.alibaba.nacos.common.remote.client.grpc.GrpcClient.serverCheck(GrpcClient.java:195)at com.alibaba.nacos.common.remote.client.grpc.GrpcClient.connectToServer(GrpcClient.java:306)at com.alibaba.nacos.common.remote.client.RpcClient.reconnect(RpcClient.java:521)at com.alibaba.nacos.common.remote.client.RpcClient.lambda$start$2(RpcClient.java:369)at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)at java.base/java.lang.Thread.run(Thread.java:834)Caused by: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
分析:
nacos服务端升级为2.x版本后,新增了gRPC 的通信方式(用于客户端向服务端发起连接请求),新增了两个端口。这两个端口在nacos原先的端口上(默认8848),进行一定偏移量自动生成
解决:
方式一:当服务端端升级为2.x版本,客户端也需要进行相应的版本升级(最好版本一致)
方式二:有 bootstrap 的时候会采用 nacos 的默认配置,所以一直读取本地的端口。把配置中心里写在 application.yml 的配置内容转移到 bootstrap.yml 中就行了
方式三:
【1】更改服务器的hosts
【2】在文件/etc/hosts,添加一行,localhost和主机名对应起来,如下:
[root@10-100-0-19 ~]# vim /etc/hosts127.0.0.1 localhost ***** # 添加这一行127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
方式四(暂推荐):
【1】如果使用docker安装的nacos服务,2.x版本后增加了 grpc 通信并且增加nacos的集群端口上下偏移1000,创建容器时除了8848还需要把7848、9848都暴露出来。如:-p 7848:7848 -p 8848:8848 -p 9848:9848
【2】7848 用于节点选举来确定集群领袖 Leader
【3】9848 用于客户端向服务端发送心跳、保持请求连接
来源地址:https://blog.csdn.net/hkl_Forever/article/details/129353742