nacos-group / nacos-docker

This project contains a Docker image meant to facilitate the deployment of Nacos .
Apache License 2.0
1.45k stars 912 forks source link

从 docker hub 下载的 nacos-server:v2.2.3 启动报错: No DataSource set #354

Open syrm-ll opened 1 year ago

syrm-ll commented 1 year ago

启动命令:

docker run 
-p 28848:8848 
--env MODE=standalone 
--env MYSQL_SERVICE_HOST=<略>
--env MYSQL_SERVICE_PASSWORD=<略> 
--env MYSQL_SERVICE_PORT=20000 
--env MYSQL_SERVICE_USER=root 
--env SPRING_DATASOURCE_PLATFORM=mysql 
--env MYSQL_SERVICE_DB_NAME=nacos_config 
--name nacos-test 
--pull missing 
-d nacos/nacos-server:v2.2.3 

启动后稍等几秒出现的错误日志:


2023-06-19T12:13:34.243804660Z Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-06-19T12:13:34.243811676Z 
2023-06-19T12:13:34.293277170Z 2023-06-19 20:13:34,292 ERROR Application run failed
2023-06-19T12:13:34.293310204Z 
2023-06-19T12:13:34.293322195Z org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memoryMonitor' defined in URL [jar:file:/home/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-config-2.2.3.jar!/com/alibaba/nacos/config/server/monitor/MemoryMonitor.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'asyncNotifyService': Unsatisfied dependency expressed through field 'dumpService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalDumpService': Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :
2023-06-19T12:13:34.293332374Z No DataSource set
2023-06-19T12:13:34.293338514Z  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
2023-06-19T12:13:34.293344797Z  at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)
2023-06-19T12:13:34.293351363Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
2023-06-19T12:13:34.293371381Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
2023-06-19T12:13:34.293377849Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
2023-06-19T12:13:34.293383440Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
2023-06-19T12:13:34.293388855Z  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
2023-06-19T12:13:34.293394067Z  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
2023-06-19T12:13:34.293400574Z  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
2023-06-19T12:13:34.293405544Z  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
2023-06-19T12:13:34.293410874Z  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
2023-06-19T12:13:34.293416482Z  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
2023-06-19T12:13:34.293422058Z  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
2023-06-19T12:13:34.293427343Z  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
2023-06-19T12:13:34.293432594Z  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745)
2023-06-19T12:13:34.293437696Z  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:423)
2023-06-19T12:13:34.293443080Z  at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
2023-06-19T12:13:34.293448370Z  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317)
2023-06-19T12:13:34.293453825Z  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
2023-06-19T12:13:34.293459232Z  at com.alibaba.nacos.Nacos.main(Nacos.java:35)
2023-06-19T12:13:34.293464675Z  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-06-19T12:13:34.293469872Z  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2023-06-19T12:13:34.293475147Z  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2023-06-19T12:13:34.293480452Z  at java.lang.reflect.Method.invoke(Method.java:498)
2023-06-19T12:13:34.293485707Z  at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
2023-06-19T12:13:34.293492189Z  at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
2023-06-19T12:13:34.293504960Z  at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
2023-06-19T12:13:34.293511047Z  at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
2023-06-19T12:13:34.293516975Z Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'asyncNotifyService': Unsatisfied dependency expressed through field 'dumpService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalDumpService': Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :
2023-06-19T12:13:34.293523918Z No DataSource set
2023-06-19T12:13:34.293529006Z  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)
2023-06-19T12:13:34.293534591Z  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
2023-06-19T12:13:34.293539898Z  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
2023-06-19T12:13:34.293545279Z  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
2023-06-19T12:13:34.293550967Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
2023-06-19T12:13:34.293556429Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
2023-06-19T12:13:34.293562110Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
2023-06-19T12:13:34.293567770Z  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
2023-06-19T12:13:34.293572858Z  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
2023-06-19T12:13:34.293577988Z  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
2023-06-19T12:13:34.293583723Z  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
2023-06-19T12:13:34.293589250Z  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
2023-06-19T12:13:34.293594766Z  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)
2023-06-19T12:13:34.293609118Z  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
2023-06-19T12:13:34.293616724Z  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
2023-06-19T12:13:34.293623309Z  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
2023-06-19T12:13:34.293636903Z  ... 27 common frames omitted
2023-06-19T12:13:34.293642996Z Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalDumpService': Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :
2023-06-19T12:13:34.293649519Z No DataSource set
2023-06-19T12:13:34.293654957Z  at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160)
2023-06-19T12:13:34.293661308Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
2023-06-19T12:13:34.293667415Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
2023-06-19T12:13:34.293673036Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
2023-06-19T12:13:34.293678650Z  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
2023-06-19T12:13:34.293684374Z  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
2023-06-19T12:13:34.293689945Z  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
2023-06-19T12:13:34.293695858Z  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
2023-06-19T12:13:34.293701550Z  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
2023-06-19T12:13:34.293706991Z  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
2023-06-19T12:13:34.293712578Z  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)
2023-06-19T12:13:34.293719133Z  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
2023-06-19T12:13:34.293725125Z  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657)
2023-06-19T12:13:34.293731125Z  ... 42 common frames omitted
2023-06-19T12:13:34.293736260Z Caused by: com.alibaba.nacos.api.exception.NacosException: Nacos Server did not start because dumpservice bean construction failure :
2023-06-19T12:13:34.293741667Z No DataSource set
2023-06-19T12:13:34.293746632Z  at com.alibaba.nacos.config.server.service.dump.DumpService.dumpOperate(DumpService.java:260)
2023-06-19T12:13:34.293752151Z  at com.alibaba.nacos.config.server.service.dump.ExternalDumpService.init(ExternalDumpService.java:61)
2023-06-19T12:13:34.293763815Z  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-06-19T12:13:34.293770144Z  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2023-06-19T12:13:34.293775985Z  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2023-06-19T12:13:34.293781559Z  at java.lang.reflect.Method.invoke(Method.java:498)
2023-06-19T12:13:34.293786713Z  at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389)
2023-06-19T12:13:34.293792524Z  at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333)
2023-06-19T12:13:34.293798850Z  at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157)
2023-06-19T12:13:34.293804808Z  ... 54 common frames omitted
2023-06-19T12:13:34.293809959Z Caused by: java.lang.IllegalStateException: No DataSource set
2023-06-19T12:13:34.293815311Z  at org.springframework.util.Assert.state(Assert.java:76)
2023-06-19T12:13:34.293820809Z  at org.springframework.jdbc.support.JdbcAccessor.obtainDataSource(JdbcAccessor.java:86)
2023-06-19T12:13:34.293826661Z  at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:376)
2023-06-19T12:13:34.293832031Z  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:465)
2023-06-19T12:13:34.293837008Z  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:475)
2023-06-19T12:13:34.293842538Z  at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:508)
2023-06-19T12:13:34.293848804Z  at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:515)
2023-06-19T12:13:34.293854271Z  at com.alibaba.nacos.config.server.service.repository.extrnal.ExternalConfigInfoPersistServiceImpl.findConfigMaxId(ExternalConfigInfoPersistServiceImpl.java:632)
2023-06-19T12:13:34.293860267Z  at com.alibaba.nacos.config.server.service.dump.processor.DumpAllProcessor.process(DumpAllProcessor.java:51)
2023-06-19T12:13:34.293866507Z  at com.alibaba.nacos.config.server.service.dump.DumpService.dumpConfigInfo(DumpService.java:317)
2023-06-19T12:13:34.293872158Z  at com.alibaba.nacos.config.server.service.dump.DumpService.dumpOperate(DumpService.java:230)
2023-06-19T12:13:34.293877592Z  ... 62 common frames omitted
2023-06-19T12:13:34.304528406Z 2023-06-19 20:13:34,304 WARN [ThreadPoolManager] Start destroying ThreadPool
2023-06-19T12:13:34.304937695Z 
2023-06-19T12:13:34.305725824Z 2023-06-19 20:13:34,305 WARN [ThreadPoolManager] Destruction of the end
2023-06-19T12:13:34.306114622Z 
L2421800049 commented 1 year ago

要先建表 https://raw.githubusercontent.com/alibaba/nacos/develop/distribution/conf/mysql-schema.sql

syrm-ll commented 1 year ago

要先建表 https://raw.githubusercontent.com/alibaba/nacos/develop/distribution/conf/mysql-schema.sql

建过了, 没有用 图片

错误信息没啥有用的, 翻源码太疼头才尝试来这边问问

syrm-ll commented 1 year ago

mysql 8.0.26

guluwj commented 1 year ago

楼主解决了吗,没解决可以看看这个issues,跟你的差不多:https://github.com/nacos-group/nacos-docker/issues/355

hugiee commented 1 year ago

我有一种诡异的解决方法, 我是通过mysql的-h命令连接一次之后就修复了... 例如: mysql -h127.0.0.1 -uroot -p

marshalby2 commented 1 year ago

我也是遇到这个问题,无法解决,应该是容器启动的配置没生效

andotorg commented 1 year ago

添加环境变量 -e SPRING_DATASOURCE_PLATFORM=mysql 或者 -e SPRING_DATASOURCE_PLATFORM=embedded

jackieonway commented 1 year ago

将 MYSQL_SERVICE_PORT 这个配置改成 3306端口就能成功启动,没有找到具体的问题

DREARMING commented 7 months ago

将 MYSQL_SERVICE_PORT 这个配置改成 3306端口就能成功启动,没有找到具体的问题

3306应该是nacos内部于mysql的通讯端口,大概是不能改,我将nacos集群和新开mysql的容器(为了不冲突原有的mysql)放在相同网络,他们本身内部处于一个网络,所以填3306完全没有问题,不对主机的3306进行映射(或者改成其他)就行了

OneCodeMonkey commented 7 months ago

对,我的也是 ,数据库连接都是对的,把 SQL 导入到 数据库 nacos 的表,后面就好了。 这种报错也太不友好了,其实是 缺失表信息,搞一个 “No datasource set”,还以为连接 账号有问题,mysql 连接不上呢!! 把账号连接不上的 报错,和 表 缺失的 报错 区分开,这样不好吗? 对一个 不熟悉 你产品的 用户来说,太不友好了!

MorrisCao commented 6 months ago

如果是docker image: nacos/nacos-server:v2.3.2 database:mysql 可以先执行db初始化:https://github.com/alibaba/nacos/blob/2.3.2/distribution/conf/mysql-schema.sql 然后执行下面的命令就可以了:

docker run -d --name nacos-standalone-mysql -p 8848:8848 -p 9848:9848 \ -e PREFER_HOST_MODE=hostname \ -e MODE=standalone \ -e SPRING_DATASOURCE_PLATFORM=mysql \ -e MYSQL_SERVICE_HOST=172.xx.0.1 \ -e MYSQL_SERVICE_DB_NAME=nacos \ -e MYSQL_SERVICE_PORT=9443 \ -e MYSQL_SERVICE_USER=nacos-user \ -e MYSQL_SERVICE_PASSWORD=nacos-passwd \ -e "MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true" \ -e "NACOS_AUTH_IDENTITY_KEY=2222" \ -e "NACOS_AUTH_IDENTITY_VALUE=2xxx" \ -e "NACOS_AUTH_TOKEN=SecretKeyxxx3456789" \ -v /Users/xxx/nacos-data:/home/nacos/logs \ nacos/nacos-server:v2.3.2

mozhu811 commented 5 months ago

报错信息太不友好了,要不是看到这个issue我要排查半天网络环境和数据库账号问题

AntiMoron commented 5 months ago

上手难度:⭐️⭐️⭐️⭐️⭐️ 职业选手点评:在赤石 docker镜像部署总结:答辩

qq253498229 commented 4 months ago

同样的错误,表也建完了,用户也insert了,url时区也改了,3个token也加上了,还是不好用

最恶心的是不知道什么错误

我这个问题似乎是把我的ipv4地址解析成了ipv6

ILLU510N commented 4 months ago

我也以为是自动建表的, 搞半天需要自己手动😅

littlemon95 commented 6 days ago

牛魔真的是没建表的问题,百度翻了半天,网络也检查了半天😓