微服务 nacos 启动可访问,服务启动报 #
nacos registry, e-commerce-authority-center register failed...NacosRegistration{nacosDiscoveryProperties=NacosDiscoveryProperties{serverAddr='127.0.0.1:8848', endpoint='', namespace='69a4f30-38fe-424d-', watchDelay=30000, logName='', service='e-commerce-authority-center', weight=1.0, clusterName='DEFAULT', group='DEFAULT_GROUP', namingLoadCacheAtStart='false', metadata={preserved.register.source=SPRING_CLOUD, management.context-path=/ecommerce-authority-center/actuator}, registerEnabled=true, ip='192.168.2.1', networkInterface='', port=7000, secure=false, accessKey='', secretKey='', heartBeatInterval=null, heartBeatTimeout=null, ipDeleteTimeout=null}},
com.alibaba.nacos.api.exception.NacosException: failed to req API:/nacos/v1/ns/instance after all servers([127.0.0.1:8848]) 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'>Tue Mar 01 17:09:44 CST 2022</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>
1.nacos本地部署,正常启动正常访问,代码是git上拉下来应该是没问题得; 2.排除nacos配置,本地使用集群模式,检查cluster.conf 文件配置,配置集群使用127.0.0.1;正常启动后会增自动增加本机ip加端口得配置;
3.查看application.properties 文件配置,配置正常;
4.使用单机模式启动 startup.cmd -m standalone 这时候启动应用不再报错;说明是nacos 集群配置问题了;
5.为什么有这个问题,是因为在Nacos2.0以后,相对于之前的版本增加了gRPC的通信方式,简单来说 8801端口占用的偏移量是9801端口和9802端口、8802端口占用的偏移量是9802端口和9803端口、8803端口占用的偏移量是9803端口和9804端口,端口冲突了。
因此8802节点没启动成功,但是8803节点启动成功修改端口 预留两个偏移量的值,就可以启动了。我把端口换成 8837,8848,8859再次尝试,启动成功,登录Nacos控制台。记得修改集群ip和application.properties 中的配置
启动成功,自己坑还得自己填啊!