概述
搭建个新服务,nacos做配置中心,运维帮忙部署时出了几个异常,记录下。
第一个异常:
[ERROR] c.a.n.c.c.impl.ClientWorker.getServerConfig:304 - [fixed-nacos2-xxx.xxx.com_80-tv-dev] [sub-server-error] no right, dataId=tm-xxx-server, group=TM_xxx_GROUP, tenant=tv-dev
[ERROR] c.a.c.n.c.NacosPropertySourceBuilder.loadNacosData:101 - get data from Nacos error,dataId:tm-xxx-server
com.alibaba.nacos.api.exception.NacosException: <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'>Thu Jan 13 15:07:22 CST 2022</div><div>There was an unexpected error (type=Forbidden, status=403).</div><div>authorization failed!</div></body></html>
at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:306)
at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:155)
at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:98)
at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:85)
at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:73)
at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:199)
at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:186)
at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadApplicationConfiguration(NacosPropertySourceLocator.java:141)
at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:103)
主要是抛出了一个【authorization failed】,检查配置信息。
PS:最开始的两行打印处了[ERROR]
fixed-nacos2-xxx.xxx.com_80-tv-dev
nacos的连接地址
dataId=tm-xxx-server
配置的yml名称
group=TM_xxx_GROUP
组名称
tenant=tv-dev
命名空间namespace
定位发现运维把namespace配错了,导致异常出现。
第二个异常:
ERROR [tm-simba-server,,,] 10 --- [ main] c.a.n.client.config.impl.ClientWorker : [fixed-nacos2-offline.ikunchi.com_80-mqk-dev] [sub-server-error] no right, dataId=tm-simba-server, group=TM_SIMBA_GROUP, tenant=mqk-dev
[main] ERROR c.a.n.c.c.i.ClientWorker - [getServerConfig,304] - [fixed-nacos2-offline.ikunchi.com_80-mqk-dev] [sub-server-error] no right, dataId=tm-simba-server, group=TM_SIMBA_GROUP, tenant=mqk-dev
WARN [tm-simba-server,,,] 10 --- [ main] io.sentry.dsn.Dsn : *** Couldn't find a suitable DSN, Sentry operations will do nothing! See documentation: https://docs.sentry.io/clients/java/ ***
[main] WARN io.sentry.dsn.Dsn - [dsnLookup,89] - *** Couldn't find a suitable DSN, Sentry operations will do nothing! See documentation: https://docs.sentry.io/clients/java/ ***
WARN [tm-simba-server,,,] 10 --- [ main] io.sentry.DefaultSentryClientFactory : No 'stacktrace.app.packages' was configured, this option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation: https://docs.sentry.io/clients/java/config/#in-application-stack-frames
[main] WARN i.s.DefaultSentryClientFactory - [getInAppFrames,524] - No 'stacktrace.app.packages' was configured, this option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation: https://docs.sentry.io/clients/java/config/#in-application-stack-frames
ERROR [tm-simba-server,,,] 10 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : get data from Nacos error,dataId:tm-simba-server
com.alibaba.nacos.api.exception.NacosException: <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 Jan 11 11:28:39 CST 2022</div><div>There was an unexpected error (type=Forbidden, status=403).</div><div>authorization failed!</div></body></html>
at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:306)
at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:155)
at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:98)
at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:85)
又抛出了【authorization failed!】,此时namespace已经匹配上了,为啥又报错?很是尴尬,经过复盘提出猜想。最初namespace是“AAA”,项目正常运行后经理过来要求把namespace改成“XXX”。运维更改后项目启动失败,猜测是更改namespace时用户权限分配的有问题。经过一系列修改后启动仍然失败,后来为了彻底验证是不是账号授权问题运维删除了账号和namespace,重新配置了一遍,项目启动成功。
总结:不要随便更改namespace和账号权限,运维在部署服务时自己也要检查一遍运维的配置。上述问题并不是很高深的问题,但是部署环境时稍不注意就会发生。
第三个异常(本地异常):
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.http.ServerHttpAgent.httpGet:112 - [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.http.ServerHttpAgent.httpGet:112 - [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.http.ServerHttpAgent.httpGet:112 - [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.http.ServerHttpAgent.httpGet:133 - no available server
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.impl.ClientWorker.getServerConfig:279 - [fixed-localhost_8848] [sub-server] get server config exception, dataId=null.properties, group=DEFAULT_GROUP, tenant=
java.net.ConnectException: no available server
at com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:134)
at com.alibaba.nacos.client.config.http.MetricsHttpAgent.httpGet(MetricsHttpAgent.java:51)
at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:274)
at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:155)
at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:98)
显示【connect timed out】,并且dataId、group、tenant都不正常。仔细检查了yml没啥问题,就是项目起不来,无语中。
后来发现是服务启动时nacos对读取yml文件的时机有要求,nacos作为配置中心要连接nacosServer获取服务的配置文件,所以服务启动时nacos的信息要配置在bootstrap.yml中被项目最先加载。
平时写了N行的代码,但也不是天天配置项目,初学nacos的时候也看到过这个点,但上一次看到的时候还是上一次,确实忘记了,挺尬的。
第四个异常:
另外一组的同事封装了下nacos,咱也没看到人家源码,咱也不懂。问题是我们组同事引入封装的依赖后项目运行异常,可怜人被分配到过来解决这个问题。
项目拉下来运行发现nacos源码中有个方法调用的构造方法有问题,构造方法定义的入参是两个,nacos调用该构造方法入参是三个,所以源码报异常了。问题到这这就简单了,上官网看了下nacos各个版本依赖的springCloud,又看了下服务当前依赖的springCloud版本,果然版本冲突。
PS:图是9月份处理这个问题时截得,公司网络有问题GitHub打不开,就这张意思下吧
最后
以上就是愉快羊为你收集整理的nacos启动异常的全部内容,希望文章能够帮你解决nacos启动异常所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复