请教下nacos集群,cloud项目无法注册是怎么回事啊?

nacos是2.2.3

2023-08-27 09:52:23.153 ERROR 6492 --- [ main] c.a.c.n.registry.NacosServiceRegistry : nacos registry, userp_ppservice register failed...NacosRegistration{nacosDiscoveryProperties=NacosDiscoveryProperties{serverAddr='localhost:81', endpoint='', namespace='', watchDelay=30000, logName='', service='userp_ppservice', weight=1.0, clusterName='BJ', group='DEFAULT_GROUP', namingLoadCacheAtStart='false', metadata={preserved.register.source=SPRING_CLOUD}, registerEnabled=true, ip='192.168.199.137', networkInterface='', port=8083, secure=false, accessKey='', secretKey='', heartBeatInterval=null, heartBeatTimeout=null, ipDeleteTimeout=null, failFast=true}},

com.alibaba.nacos.api.exception.NacosException: failed to req API:/nacos/v1/ns/instance after all servers([localhost:81]) tried: ErrCode:400, ErrMsg:<html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Sun Aug 27 09:52:23 CST 2023</div><div>There was an unexpected error (type=Bad Request, status=400).</div><div>receive invalid redirect request from peer 127.0.0.1</div></body></html>

cluster里这样配置的

127.0.0.1:8838
127.0.0.1:8848
127.0.0.1:8858

nginx里反向代理这样配置的


回答:

如果是连接nacos集群,可以不用在nginx上配置负载均衡。
nacos客户端连接的时候,可以配置多个naocs服务端的地址,客户端自己会判断使用那个地址,当有某个节点不能访问时,会切换到其他节点。所以这里加nginx做负载均衡的意义不大,反而还增加了一个nginx单点故障的风险。

nginx http 81 端口的配置,看上去好像没问题。贴出来的错误提示,是收到了无效的redirect请求。这个可以先尝试不连接负载均衡,直接连接8848试试,看看还有没有一样的错误,验证一下是不是nginx的配置的问题。

这里应该有一个问题

  1. 如果要使用nginx做负载均衡的话,还需要配置一个1081端口的4层负载均衡,也就是81+1000偏移。因为2.x的nacos还会用到一个grpc协议的端口。

update. 检查一下你的 client 版本号,nacos server 2.x 对应 nacos java client 2.x 。 nacos server 1.x 对应 nacos java client 1.x

以上是 请教下nacos集群,cloud项目无法注册是怎么回事啊? 的全部内容, 来源链接: utcz.com/p/945321.html

回到顶部