nacos 2.0 GRPC SLB(nginx)如何配置

发布于 2022-09-12 23:01:06 字数 7183 浏览 97 评论 0

Nginx配置

upstream nacos-cluster-test{

server 172.22.1.82:8848 weight=1;
server 172.22.1.83:8848 weight=1;
server 172.22.1.84:8848 weight=1;

}
upstream nacos-grpc-9848{

  server 172.22.1.82:9848 weight=1;
  server 172.22.1.83:9848 weight=1;
  server 172.22.1.84:9848 weight=1;

}
upstream nacos-grpc-9849{

  server 172.22.1.82:9849 weight=1;
  server 172.22.1.83:9849 weight=1;
  server 172.22.1.84:9849 weight=1;

}

server {

    listen       8848;
    server_name  localhost;
    location / {
                   #请求转向taishan定义的服务器列表
                   proxy_pass http://nacos-cluster-test;
                   #将请求头转发给后端服务器
                   proxy_set_header Host $host:8848;
                   #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
                   proxy_set_header X-Forward-For $remote_addr;
                   root  /nacos/;
                   index index.php index.html index.htm;               
             }
}

# grpc 代理配置

server {

    listen 9848 http2; # grpc方式对外暴露端口
    # access_log logs/access.log main;
    location / {
        grpc_pass grpc://nacos-grpc-9848; # 此处配置grpc服务的ip和端口
    }
}
server {
    listen 9849 http2; # grpc方式对外暴露端口
    # access_log logs/access.log main;
    location / {
        grpc_pass grpc://nacos-grpc-9849; # 此处配置grpc服务的ip和端口
    }
}

## 报错

2021-03-30 08:46:12.567 ERROR 4804 --- [s.client.Worker] com.alibaba.nacos.common.remote.client   : Send request fail, request=ConfigBatchListenRequest{headers={}, requestId='null'}, retryTimes=2,errorMessage=java.util.concurrent.ExecutionException: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: Channel shutdownNow invoked

2021-03-30 08:46:12.579 ERROR 4804 --- [s.client.Worker] c.a.n.client.config.impl.ClientWorker : Async listen config change error

com.alibaba.nacos.api.exception.NacosException: java.util.concurrent.ExecutionException: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: Channel shutdownNow invoked

at com.alibaba.nacos.common.remote.client.grpc.GrpcConnection.request(GrpcConnection.java:78) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.common.remote.client.RpcClient.request(RpcClient.java:630) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.requestProxy(ClientWorker.java:965) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.requestProxy(ClientWorker.java:940) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.executeConfigListen(ClientWorker.java:753) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient$3.run(ClientWorker.java:676) [nacos-client-2.0.0.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_112]
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) [na:1.8.0_112]
at java.util.concurrent.FutureTask.run(FutureTask.java) [na:1.8.0_112]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_112]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_112]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_112]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_112]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_112]

Caused by: java.util.concurrent.ExecutionException: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: Channel shutdownNow invoked

at com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:528) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:425) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.common.remote.client.grpc.GrpcConnection.request(GrpcConnection.java:76) ~[nacos-client-2.0.0.jar:na]
... 13 common frames omitted

Caused by: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: Channel shutdownNow invoked

at com.alibaba.nacos.shaded.io.grpc.Status.asRuntimeException(Status.java:533) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:490) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:700) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:399) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:510) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:66) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:630) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:518) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:692) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:681) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[nacos-client-2.0.0.jar:na]
at com.alibaba.nacos.shaded.io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) ~[nacos-client-2.0.0.jar:na]
... 3 common frames omitted

## 求nginx正确配置?
在线等,谢谢!!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不是你的备胎 2022-09-19 23:01:06

官方文档仔细阅读 nginx的配置需要把Grpc 配置成tcp的。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文