开发者社区 > 云原生 > 正文

Docker上的Nacos(2.0.3),未设置数据源

使用docker启动发现无法启动,数据库可以在外部连接,数据已经初始化。

/home/nacos/logs/nacos.log

Caused by: com.alibaba.nacos.api.exception.NacosException: Nacos Server did not start because dumpservice bean construction failure : No DataSource set at com.alibaba.nacos.config.server.service.dump.DumpService.dumpOperate(DumpService.java:236) at com.alibaba.nacos.config.server.service.dump.ExternalDumpService.init(ExternalDumpService.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136) ... 53 common frames omitted Caused by: java.lang.IllegalStateException: No DataSource set at org.springframework.util.Assert.state(Assert.java:73) at org.springframework.jdbc.support.JdbcAccessor.obtainDataSource(JdbcAccessor.java:77) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:371) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:452) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:462) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:473) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:480) at com.alibaba.nacos.config.server.service.repository.extrnal.ExternalStoragePersistServiceImpl.findConfigMaxId(ExternalStoragePersistServiceImpl.java:658) at com.alibaba.nacos.config.server.service.dump.processor.DumpAllProcessor.process(DumpAllProcessor.java:51) at com.alibaba.nacos.config.server.service.dump.DumpService.dumpConfigInfo(DumpService.java:293) at com.alibaba.nacos.config.server.service.dump.DumpService.dumpOperate(DumpService.java:205)

standalone-mysql-8.yaml

version: "2" services: nacos: image: nacos/nacos-server:${NACOS_VERSION} container_name: nacos-standalone-mysql env_file: - ../env/nacos-standlone-mysql.env volumes: - ./standalone-logs/:/home/nacos/logs - ./plugins/:/home/nacos/plugins - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8848:8848" - "9848:9848" - "9555:9555" depends_on: - mysql restart: always mysql: container_name: mysql image: nacos/nacos-mysql:8.0.16 env_file: - ../env/mysql.env volumes: - ./mysql:/var/lib/mysql ports: - "3306:3306"

尝试加载驱动文件并挂载到/home/nacos/plugins/mysql,没有解决

尝试修改配置文件

env/nacos-standlone-mysql.env

PREFER_HOST_MODE=hostname MODE=standalone SPRING_DATASOURCE_PLATFORM=mysql MYSQL_SERVICE_HOST=mysql MYSQL_SERVICE_DB_NAME=nacos_devtest MYSQL_SERVICE_PORT=3306 MYSQL_SERVICE_USER=nacos MYSQL_SERVICE_PASSWORD=nacos MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&useSSL=false&serverTimezone=UTC

加入serverTimezone=UTC配置,并且修改超时时间,同样没有修复

原提问者GitHub用户wangjiandev

展开
收起
学习娃 2023-05-22 16:15:15 206 0
1 条回答
写回答
取消 提交回答
  • 你检查一下你db和表是初始化好了。

    原回答者GitHub用户brotherlu-xcq

    2023-05-23 09:38:02
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
Docker 网络深度解读 立即下载
workshop专场-微服务专场-开发者动手实践营-微服务-使用Nacos进行服务的动态发现和流量调度 立即下载
Nacos 启航,发布第一个版本, 云原生时代助力用户微服务平台建设 立即下载