zoukankan      html  css  js  c++  java
  • 提问:Nacos部署No DataSource set问题

    先跑起mysql数据库主从,并有nacos_config数据库。

    有nacos-standalone-mysql.yaml 文件

    [root@localhost example]# cat nacos-standalone-mysql.yaml 
    version: "2"
    services:
      nacos:
        image: nacos/nacos-server:latest
        container_name: nacos-standalone-mysql
        environment:
          - PREFER_HOST_MODE=hostname
          - MODE=standalone
          - SPRING_DATASOURCE_PLATFORM=mysql
          - MYSQL_MASTER_SERVICE_HOST=192.168.0.88
          - MYSQL_MASTER_SERVICE_DB_NAME=nacos_config
          - MYSQL_MASTER_SERVICE_PORT=3306
          - MYSQL_SLAVE_SERVICE_HOST=192.168.0.88
          - MYSQL_SLAVE_SERVICE_PORT=3307
          - MYSQL_MASTER_SERVICE_USER=root
          - MYSQL_MASTER_SERVICE_PASSWORD=root
        volumes:
          - ./standalone-logs/:/home/nacos/logs
          - ./init.d/custom.properties:/home/nacos/init.d/custom.properties
        ports:
          - "8848:8848"
          - "9555:9555"
        restart: on-failure
      prometheus:
        container_name: prometheus
        image: prom/prometheus:latest
        volumes:
          - ./prometheus/prometheus-standalone.yaml:/etc/prometheus/prometheus.yml
        ports:
          - "9090:9090"
        depends_on:
          - nacos
        restart: on-failure
      grafana:
        container_name: grafana
        image: grafana/grafana:latest
        ports:
          - 3000:3000
        restart: on-failure

    启动命令 :docker-compose -f nacos-standalone-mysql.yaml start 

    查看日志:nacos.log

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'opsController' defined in URL [jar:file:/home/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-config-1.1.3.jar!/com/alibaba/nacos/config/server/controller/OpsController.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dumpService': Invocation of init method failed; nested exception is java.lang.RuntimeException: Nacos Server did not start because dumpservice bean construction failure :
    No DataSource set
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:218)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1308)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1154)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
        at com.alibaba.nacos.Nacos.main(Nacos.java:33)
        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.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:593)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dumpService': Invocation of init method failed; nested exception is java.lang.RuntimeException: Nacos Server did not start because dumpservice bean construction failure :
    No DataSource set
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:139)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:419)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1737)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:273)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1237)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
        ... 27 common frames omitted
    Caused by: java.lang.RuntimeException: Nacos Server did not start because dumpservice bean construction failure :
    No DataSource set
        at com.alibaba.nacos.config.server.service.dump.DumpService.init(DumpService.java:155)
        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)
        ... 40 common frames omitted

    此时提示:未设置数据源

    当前防火墙是开启状态

    [root@localhost ~]# systemctl status firewalld
    ● firewalld.service - firewalld - dynamic firewall daemon
       Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
       Active: active (running) since 六 2019-10-05 22:01:28 CST; 12min ago
         Docs: man:firewalld(1)
     Main PID: 9561 (firewalld)
        Tasks: 2
       Memory: 22.0M
       CGroup: /system.slice/firewalld.service
               └─9561 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
    
    10月 05 22:01:28 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
    10月 05 22:01:28 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
    10月 05 22:01:29 localhost.localdomain firewalld[9561]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching ...that chain?).
    10月 05 22:01:29 localhost.localdomain firewalld[9561]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i br-f43a2f3c90e1 -o br-f43a2f3c90e1 -j DROP' failed: iptables: Bad rule (...that chain?).
    10月 05 22:01:29 localhost.localdomain firewalld[9561]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching ...that chain?).
    Hint: Some lines were ellipsized, use -l to show in full.

    当关闭防火墙systemctl stop firewalld

    关闭nacos  : docker-compose -f nacos-standalone-mysql.yaml stop

    再启动nacos :docker-compose -f nacos-standalone-mysql.yaml start

    此时的提示信息如下:

    [root@localhost example]# docker-compose -f nacos-standalone-mysql.yaml start
    Starting nacos ... error
    Starting prometheus ... error
    Starting grafana ... error
    
    ERROR: for nacos  Cannot start service nacos: driver failed programming external connectivity on endpoint nacos-standalone-mysql (84f0c6a2500462d6476feef183de51cf348b21000cafd96f0d0f65b5a853e73f):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 9555 -j DNAT --to-destination 172.18.0.2:9555 ! -i br-f43a2f3c90e1: iptables: No chain/target/match by that name.
     (exit status 1))
    
    ERROR: for grafana  Cannot start service grafana: driver failed programming external connectivity on endpoint grafana (d66fa5b085965d19866aa531bea5a21e5bdeb5a9c3cc5ffdac03dd6f6c91c088):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3000 -j DNAT --to-destination 172.18.0.3:3000 ! -i br-f43a2f3c90e1: iptables: No chain/target/match by that name.
     (exit status 1))
    ERROR: No containers to start

    查看日志: tail -f nacos.log  ,没有新增内容。

    然后,重启docker  。命令: systemctl restart docker 

    从头再来执行一遍。

    再启动mysql ,再启动 nacos ,如此可以启动nacos成功。

    nacos.log如下:

    2019-10-05 22:26:32,289 INFO Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@366c4480, org.springframework.security.web.context.SecurityContextPersistenceFilter@77a7cf58, org.springframework.security.web.header.HeaderWriterFilter@2320fa6f, org.springframework.security.web.authentication.logout.LogoutFilter@293a5f75, com.alibaba.nacos.console.filter.JwtAuthenticationTokenFilter@2c7b5824, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@616fe72b, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@7e5d9a50, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@302a07d, org.springframework.security.web.session.SessionManagementFilter@4d722ac9, org.springframework.security.web.access.ExceptionTranslationFilter@424ebba3, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@61c9c3fd]
    
    2019-10-05 22:26:32,358 INFO Exposing 16 endpoint(s) beneath base path '/actuator'
    
    2019-10-05 22:26:32,447 INFO Initializing ExecutorService 'taskScheduler'
    
    2019-10-05 22:26:32,774 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'
    
    2019-10-05 22:26:32,791 INFO Started Nacos in 14.459 seconds (JVM running for 16.144)
    
    2019-10-05 22:26:32,792 INFO Nacos Log files: /home/nacos/logs/
    
    2019-10-05 22:26:32,792 INFO Nacos Conf files: /home/nacos/conf/
    
    2019-10-05 22:26:32,792 INFO Nacos Data files: /home/nacos/data/
    
    2019-10-05 22:26:32,792 INFO Nacos started successfully in stand alone mode.
    
    2019-10-05 22:26:34,968 INFO Initializing Spring DispatcherServlet 'dispatcherServlet'
    
    2019-10-05 22:26:34,968 INFO Initializing Servlet 'dispatcherServlet'
    
    2019-10-05 22:26:34,991 INFO Completed initialization in 23 ms
    
    2019-10-05 22:27:22,324 INFO Expired JWT token.
    
    2019-10-05 22:27:22,357 ERROR Responding with unauthorized error. Message - Full authentication is required to access this resource

     

    请问这是为什么。。。如何解决不关闭防火墙也可以部署nacos ?

    已解决。

    办法:把docker-compose启动配置文件 nacos-standalone-mysql.yaml 中的所有端口,全部开放,就可以了。

  • 相关阅读:
    图数据库的选择与对比(Neo4j)
    pip install ahocorasick报错以及Requirement already satisfied问题
    从知识图谱到认知图谱: 历史、发展与展望
    kafka(一)—— kafka安装简单使用
    python管理docker
    Javaweb前后端分离项目docker部署
    django + uwsgi + nginx部署(前后端不分离)
    坑(八)—— LayUI框架中append新的元素的问题
    docker(三)—— 避免一直输入sudo
    坑(七)—— 表单提交方式
  • 原文地址:https://www.cnblogs.com/itbac/p/11625984.html
Copyright © 2011-2022 走看看