0
点赞
收藏
分享

微信扫一扫

nacos配置本地集群,反向代理之后报错,并且输入端口找不到本地Nacos服务

桑二小姐 1天前 阅读 1
微服务
04-16 15:02:59:674  WARN 21992 --- [           main] c.a.n.client.config.NacosConfigService   : [fixed-localhost_80] [get-config] get from server error, dataId=userservice.yaml, group=DEFAULT_GROUP, tenant=, msg=ErrCode:500, ErrMsg:[NACOS HTTP-GET] The maximum number of tolerable server reconnection errors has been reached
04-16 15:02:59:674  WARN 21992 --- [           main] c.a.n.client.config.NacosConfigService   : [fixed-localhost_80] [get-config] get snapshot ok, dataId=userservice.yaml, group=DEFAULT_GROUP, tenant=, config=
04-16 15:02:59:674  WARN 21992 --- [           main] c.a.c.n.c.NacosPropertySourceBuilder     : Ignore the empty nacos configuration and get it based on dataId[userservice.yaml] & group[DEFAULT_GROUP]
04-16 15:02:59:675 ERROR 21992 --- [           main] c.a.n.c.config.http.ServerHttpAgent      : [NACOS ConnectException httpGet] currentServerAddr:http://localhost:80, err : Connection refused: connect
04-16 15:02:59:874 ERROR 21992 --- [           main] c.a.n.c.config.http.ServerHttpAgent      : [NACOS ConnectException httpGet] currentServerAddr:http://localhost:80, err : Connection refused: connect
04-16 15:03:00:075 ERROR 21992 --- [           main] c.a.n.c.config.http.ServerHttpAgent      : [NACOS ConnectException httpGet] currentServerAddr:http://localhost:80, err : Connection refused: connect
04-16 15:03:00:274 ERROR 21992 --- [           main] c.a.n.c.config.http.ServerHttpAgent      : [NACOS ConnectException httpGet] currentServerAddr:http://localhost:80, err : Connection refused: connect
04-16 15:03:00:275 ERROR 21992 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-localhost_80] [sub-server] get server config exception, dataId=userservice-dev.yaml, group=DEFAULT_GROUP, tenant=

java.net.ConnectException: [NACOS HTTP-GET] The maximum number of tolerable server reconnection errors has been reached
	at com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:125) ~[nacos-client-1.4.1.jar:na]
	at com.alibaba.nacos.client.config.http.MetricsHttpAgent.httpGet(MetricsHttpAgent.java:51) ~[nacos-client-1.4.1.jar:na]
	at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:274) ~[nacos-client-1.4.1.jar:na]
	at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:155) ~[nacos-client-1.4.1.jar:na]
	at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:98) ~[nacos-client-1.4.1.jar:na]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:85) ~[spring-cloud-starter-alibaba-nacos-config-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:73) ~[spring-cloud-starter-alibaba-nacos-config-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:199) ~[spring-cloud-starter-alibaba-nacos-config-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:186) ~[spring-cloud-starter-alibaba-nacos-config-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadApplicationConfiguration(NacosPropertySourceLocator.java:149) ~[spring-cloud-starter-alibaba-nacos-config-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:103) ~[spring-cloud-starter-alibaba-nacos-config-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:52) ~[spring-cloud-context-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:47) ~[spring-cloud-context-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:98) ~[spring-cloud-context-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:626) ~[spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:370) ~[spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at cn.itcast.user.UserApplication.main(UserApplication.java:11) ~[classes/:na]

我看黑马的课,配置Nacos集群和反向代理之后输入端口无法访问nacos 搜了很多才发现因为nginx反向代理配置的有问题 这几行没有放到http函数里导致的。 

解决:把nginx配置文件里边的集群配置放到http函数里边。

(如果还没跑起来 则又可能是端口被占 试着改一下端口)

upstream nacos-cluster {
    server 127.0.0.1:8845;
	server 127.0.0.1:8846;
	server 127.0.0.1:8847;
}

server {
    listen       80;
    server_name  localhost;

    location /nacos {
        proxy_pass http://nacos-cluster;
    }
}
举报

相关推荐

0 条评论