升级3.3.1后出现mysql连接异常,求教

Blade 未结 2 177
jma
jma 剑者 2023-12-27 13:17


是3.3.0 升级 3.3.1后出现的问题,之前运行正常


这边是将nacos部署在局域网的k8s中,mysql在局域网的一个linux系统中,test部署在k8s中,我本机dev正常连接局域网的nacos,mysql,服务也注册成功,但是在test环境下就显示mysql连接失败

10:13:06.658 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in PropertySource 'commandLineArgs' with value of type String
210:13:06.719 [main] DEBUG org.springframework.core.env.StandardEnvironment - Activating profiles [test]
3----启动中,读取到的环境变量:[test],jar地址:[file:/blade/log/app.jar]----
42023-12-27 10:13:12.140 INFO 1 --- [kground-preinit] o.h.validator.internal.util.Version : HV000001: Hibernate Validator 6.2.5.Final
5______ _ _ ___ ___
6| ___ \| | | | \ \ / /
7| |_/ /| | __ _ __| | ___ \ V /
8| ___ \| | / _` | / _` | / _ \ > <
9| |_/ /| || (_| || (_| || __/ / . \
10\____/ |_| \__,_| \__,_| \___|/__/ \__\
11
12:: BladeX 3.3.1.RELEASE :: blade-log:test :: Running SpringBoot 2.7.18 ::
13
142023-12-27 10:13:18.721 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade.yaml] & group[DEFAULT_GROUP]
152023-12-27 10:13:19.129 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-test.yaml] & group[DEFAULT_GROUP]
162023-12-27 10:13:19.536 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-log] & group[DEFAULT_GROUP]
172023-12-27 10:13:19.946 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-log.yaml] & group[DEFAULT_GROUP]
182023-12-27 10:13:20.354 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-log-test.yaml] & group[DEFAULT_GROUP]
192023-12-27 10:13:20.358 INFO 1 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-blade-log-test.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-log.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-log,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-test.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade.yaml,DEFAULT_GROUP'}]
202023-12-27 10:13:20.598 INFO 1 --- [ main] org.springblade.core.log.LogApplication : The following 1 profile is active: "test"
212023-12-27 10:13:26.522 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
222023-12-27 10:13:26.534 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
232023-12-27 10:13:26.631 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 39 ms. Found 0 Redis repository interfaces.
242023-12-27 10:13:27.308 WARN 1 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[org.springblade.core.log]' package. Please check your configuration.
252023-12-27 10:13:27.735 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=34ffe955-b404-329f-a25d-59a9e6cdc43d
262023-12-27 10:13:27.744 INFO 1 --- [ main] s.c.l.p.BladePropertySourcePostProcessor : BladePropertySourcePostProcessor init.
272023-12-27 10:13:28.072 INFO 1 --- [ main] s.c.l.p.BladePropertySourcePostProcessor : BladePropertySourcePostProcessor process @BladePropertySource bean.
282023-12-27 10:13:32.854 WARN 1 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
292023-12-27 10:13:32.949 INFO 1 --- [ main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext
302023-12-27 10:13:32.950 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 12257 ms
312023-12-27 10:13:33.793 INFO 1 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
322023-12-27 10:13:36.225 ERROR 1 --- [ main] com.alibaba.druid.pool.DruidDataSource : init datasource error, url: ${blade.datasource.test.url}
33
34java.sql.SQLException: connect error, url ${blade.datasource.test.url}, driverClass com.mysql.cj.jdbc.Driver


connect error, url ${blade.datasource.test.url}, driverClass com.mysql.cj.jdbc.Driver

是没有获取到nacos中的url配置?麻烦给指个方向到哪去调试。


2条回答
  • 2023-12-27 14:01

    发现好像在test环境下nacos服务并没有注册成功

    113:46:16.290 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in PropertySource 'commandLineArgs' with value of type String
    213:46:16.334 [main] DEBUG org.springframework.core.env.StandardEnvironment - Activating profiles [test]
    3----启动中,读取到的环境变量:[test],jar地址:[file:/blade/gateway/app.jar]----
    42023-12-27 13:46:22.638 INFO 1 --- [ main] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.impl.NacosClientAuthServiceImpl success.
    52023-12-27 13:46:22.640 INFO 1 --- [ main] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.ram.RamClientAuthServiceImpl success.
    6______ _ _ ___ ___
    7| ___ \| | | | \ \ / /
    8| |_/ /| | __ _ __| | ___ \ V /
    9| ___ \| | / _` | / _` | / _ \ > <
    10| |_/ /| || (_| || (_| || __/ / . \
    11\____/ |_| \__,_| \__,_| \___|/__/ \__\
    12
    13:: BladeX 3.3.1.RELEASE :: blade-gateway:test :: Running SpringBoot 2.7.18 ::
    14
    152023-12-27 13:46:26.042 INFO 1 --- [ main] c.a.n.c.a.AbstractAbilityControlManager : Ready to get current node abilities...
    162023-12-27 13:46:26.049 INFO 1 --- [ main] c.a.n.c.a.AbstractAbilityControlManager : Ready to initialize current node abilities, support modes: [SDK_CLIENT]
    172023-12-27 13:46:26.050 INFO 1 --- [ main] c.a.n.c.a.AbstractAbilityControlManager : Initialize current abilities finish...
    182023-12-27 13:46:26.053 INFO 1 --- [ main] c.a.n.c.a.d.NacosAbilityManagerHolder : [AbilityControlManager] Successfully initialize AbilityControlManager
    192023-12-27 13:46:26.252 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade.yaml] & group[DEFAULT_GROUP]
    202023-12-27 13:46:26.264 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-test.yaml] & group[DEFAULT_GROUP]
    212023-12-27 13:46:26.273 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-gateway] & group[DEFAULT_GROUP]
    222023-12-27 13:46:26.290 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-gateway.yaml] & group[DEFAULT_GROUP]
    232023-12-27 13:46:26.304 WARN 1 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[blade-gateway-test.yaml] & group[DEFAULT_GROUP]
    242023-12-27 13:46:26.306 INFO 1 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-blade-gateway-test.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-gateway.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-gateway,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade-test.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-blade.yaml,DEFAULT_GROUP'}]
    252023-12-27 13:46:26.433 INFO 1 --- [ main] o.s.gateway.GateWayApplication : The following 1 profile is active: "test"
    262023-12-27 13:46:30.295 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
    272023-12-27 13:46:30.310 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
    282023-12-27 13:46:30.381 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 25 ms. Found 0 Redis repository interfaces.
    292023-12-27 13:46:31.090 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=e3e1e6db-7685-341b-aa82-00f86f93e1e5
    302023-12-27 13:46:31.099 INFO 1 --- [ main] s.c.l.p.BladePropertySourcePostProcessor : BladePropertySourcePostProcessor init.
    312023-12-27 13:46:31.127 INFO 1 --- [ main] s.c.l.p.BladePropertySourcePostProcessor : BladePropertySourcePostProcessor process @BladePropertySource bean.
    322023-12-27 13:46:31.337 WARN 1 --- [ main] s.c.l.p.BladePropertySourcePostProcessor : Not found @BladePropertySource on spring bean class.
    332023-12-27 13:46:32.221 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    342023-12-27 13:46:32.225 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    352023-12-27 13:46:32.230 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'reactorDeferringLoadBalancerExchangeFilterFunction' of type [org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    362023-12-27 13:46:37.860 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [After]
    372023-12-27 13:46:37.860 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Before]
    382023-12-27 13:46:37.861 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Between]
    392023-12-27 13:46:37.861 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Cookie]
    402023-12-27 13:46:37.861 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Header]
    412023-12-27 13:46:37.862 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Host]
    422023-12-27 13:46:37.862 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Method]
    432023-12-27 13:46:37.862 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Path]
    442023-12-27 13:46:37.862 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Query]
    452023-12-27 13:46:37.863 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [ReadBody]
    462023-12-27 13:46:37.863 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [RemoteAddr]
    472023-12-27 13:46:37.863 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [XForwardedRemoteAddr]
    482023-12-27 13:46:37.864 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Weight]
    492023-12-27 13:46:37.864 INFO 1 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [CloudFoundryRouteService]
    502023-12-27 13:46:39.060 INFO 1 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
    512023-12-27 13:46:39.316 INFO 1 --- [ main] c.a.c.s.SentinelWebFluxAutoConfiguration : [Sentinel Starter] register Sentinel SentinelWebFluxFilter
    522023-12-27 13:46:39.550 INFO 1 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : Inconsistent constructor declaration on bean with name 'org.springblade.core.launch.server.ServerInfo': single autowire-marked constructor flagged as optional - this constructor is effectively required since there is no default constructor to fall back to: public org.springblade.core.launch.server.ServerInfo(org.springframework.boot.autoconfigure.web.ServerProperties)
    532023-12-27 13:46:40.618 WARN 1 --- [ main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. While this cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production.You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
    542023-12-27 13:46:41.056 INFO 1 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port 8080
    552023-12-27 13:46:41.107 INFO 1 --- [ main] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.impl.NacosClientAuthServiceImpl success.
    562023-12-27 13:46:41.107 INFO 1 --- [ main] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.ram.RamClientAuthServiceImpl success.
    572023-12-27 13:46:41.266 INFO 1 --- [ main] c.a.c.n.registry.NacosServiceRegistry : nacos registry, DEFAULT_GROUP blade-gateway 10.42.1.142:8080 register finished
    582023-12-27 13:46:41.468 INFO 1 --- [ main] o.s.core.launch.StartEventListener : ---[BLADE-GATEWAY]---启动完成,当前使用的端口:[8080],环境变量:[test]---
    592023-12-27 13:46:41.470 INFO 1 --- [ main] a.c.n.d.GatewayLocatorHeartBeatPublisher : Start nacos gateway locator heartBeat task scheduler.
    602023-12-27 13:46:41.497 INFO 1 --- [ main] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.impl.NacosClientAuthServiceImpl success.
    612023-12-27 13:46:41.498 INFO 1 --- [ main] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.ram.RamClientAuthServiceImpl success.
    622023-12-27 13:46:41.762 INFO 1 --- [ main] o.s.gateway.GateWayApplication : Started GateWayApplication in 24.839 seconds (JVM running for 27.87)
    632023-12-27 13:46:41.773 INFO 1 --- [ main] c.a.c.n.refresh.NacosContextRefresher : [Nacos Config] Listening config: dataId=blade-gateway.yaml, group=DEFAULT_GROUP
    642023-12-27 13:46:41.775 INFO 1 --- [ main] c.a.c.n.refresh.NacosContextRefresher : [Nacos Config] Listening config: dataId=blade.yaml, group=DEFAULT_GROUP
    652023-12-27 13:46:41.778 INFO 1 --- [ main] c.a.c.n.refresh.NacosContextRefresher : [Nacos Config] Listening config: dataId=blade-gateway, group=DEFAULT_GROUP
    662023-12-27 13:46:41.781 INFO 1 --- [ main] c.a.c.n.refresh.NacosContextRefresher : [Nacos Config] Listening config: dataId=blade-gateway-test.yaml, group=DEFAULT_GROUP
    672023-12-27 13:46:41.784 INFO 1 --- [ main] c.a.c.n.refresh.NacosContextRefresher : [Nacos Config] Listening config: dataId=blade-test.yaml, group=DEFAULT_GROUP
    68

    这个我的blade-gateway服务在test环境下启动正常,但是在nacos的服务列表并没有看到,我如果在dev下启动blade-gateway就能成功注册. 有什么思路吗?

    0 讨论(0)
  • 2023-12-27 14:04

    先排除掉k8s环境影响。本地直连部署nacos,用docker或者源码启动均可。看下本地环境是否能在test注册成功,3.3.1增加了nacos的认证模式,如果nacos账号密码是nacos、nacos则不用改动,否则需要修改,具体见:https://center.javablade.com/blade/BladeX-Doc/src/branch/master/%E7%AC%AC1%E7%AB%A0%20%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B/1.5%20%E5%B7%A5%E7%A8%8B%E8%BF%90%E8%A1%8C/1.5.1%20%E8%BF%90%E8%A1%8CCloud%E7%89%88%E6%9C%AC.md#%E5%90%AF%E5%8A%A8%E5%87%86%E5%A4%87


    你的这个错,是没读取到nacos配置,而gateway不需要数据库,所以就算读取不到也能启动成功。

    这个问题的排查思路见:https://sns.bladex.cn/q-41.html

    0 讨论(2)
提交回复