nacos 2.0 GRPC SLB(nginx)如何配置

新手上路,请多包涵

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正确配置?
在线等,谢谢!!!!

阅读 10.2k
1 个回答
新手上路,请多包涵

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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏