首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jhipster,无法连接集装箱化mongodb

Jhipster,无法连接集装箱化mongodb
EN

Stack Overflow用户
提问于 2017-04-17 08:03:08
回答 1查看 898关注 0票数 0

我正试着用码头来管理我的小丑微型服务。

我在没有码头工人的情况下跑步没有问题。但现在,当我尝试用码头运行我的微型服务时,我面临着一些问题。

每次我执行

码头工人-撰写-f app.yml up

命令,它在运行UAA服务器时显示此错误。

代码语言:javascript
复制
uaa-app_1            | 2017-04-17 07:38:59.725 DEBUG 6 --- [           main] i.c.f.uaa.config.CacheConfiguration      : No cache
uaa-app_1            | 2017-04-17 07:39:06.897 DEBUG 6 --- [           main] i.c.f.u.c.apidoc.SwaggerConfiguration    : Starting Swagger
uaa-app_1            | 2017-04-17 07:39:06.914 DEBUG 6 --- [           main] i.c.f.u.c.apidoc.SwaggerConfiguration    : Started Swagger in 16 ms
uaa-app_1            | 2017-04-17 07:39:07.004 DEBUG 6 --- [           main] i.c.f.uaa.config.DatabaseConfiguration   : Configuring Mongobee
uaa-app_1            | 2017-04-17 07:39:07.020  INFO 6 --- [           main] com.github.mongobee.Mongobee             : Mongobee has started the data migration sequence..
uaa-app_1            | 2017-04-17 07:39:37.056  WARN 6 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongobee' defined in class path resource [id/co/fifgroup/uaa/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
uaa-app_1            | 2017-04-17 07:39:37.074  INFO 6 --- [           main] i.c.f.uaa.config.CacheConfiguration      : Closing Cache Manager
uaa-app_1            | 2017-04-17 07:39:37.129 ERROR 6 --- [           main] o.s.boot.SpringApplication               : Application startup failed
uaa-app_1            |
uaa-app_1            | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongobee' defined in class path resource [id/co/fifgroup/uaa/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]

这是我的UAA服务器app.yml在docker目录中。

代码语言:javascript
复制
version: '2'
services:
uaa-app:
    image: uaa
    external_links:
        - uaa-mongodb:mongodb
        - jhipster-registry:registry
    environment:
        - SPRING_PROFILES_ACTIVE=dev,swagger
        - SPRING_CLOUD_CONFIG_URI=http://admin:admin@registry:8761/config
        - SPRING_DATA_MONGODB_URI=mongodb://mongodb:27017
        - SPRING_DATA_MONGODB_DATABASE=uaa
        - JHIPSTER_SLEEP=15 # gives time for the database to boot before the application 
uaa-mongodb:
    extends:
        file: mongodb.yml
        service: uaa-mongodb
jhipster-registry:
    extends:
        file: jhipster-registry.yml
        service: jhipster-registry
    environment:
        - SPRING_CLOUD_CONFIG_SERVER_NATIVE_SEARCH_LOCATIONS=file:./central-config/docker-config/

uaa-mongodb和jhipster注册表可以很好地工作,但我的UAA服务器无法连接到uaa-mongodb。

以及为什么错误总是说我使用localhost:27017,尽管我试图将应用程序-dev.yml和application-prod.yml中的SPRING_DATA_MONGODB_URIspring.data.mongodb.uri更改为不同的值。

有人能帮我解决这个问题吗。

EN

回答 1

Stack Overflow用户

发布于 2017-04-17 10:46:44

为了回答我自己的问题,我对我的剧本所做的一切。

我将app.yml文件更改为

代码语言:javascript
复制
version: '2'
services:
    uaa:
        image: uaa:latest
        external_links:
            - uaa-mongodb:mongodb
            - jhipster-registry:registry
        links : 
            - uaa-mongodb:mongodb
        environment:
            - SPRING_PROFILES_ACTIVE=prod,swagger,test
            - SPRING_CLOUD_CONFIG_URI=http://admin:admin@registry:8761/config
            - EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://admin:admin@registry:8761/config 
            - SPRING_DATA_MONGODB_HOST=mongodb
            - SPRING_DATA_MONGODB_PORT=27017
            - SPRING_DATA_MONGODB_DATABASE=uaa
            - JHIPSTER_SLEEP=15 # gives time for the database to boot before the application
    jhipster-registry:
        extends:
            file: jhipster-registry.yml
            service: jhipster-registry
        environment:
            - SPRING_CLOUD_CONFIG_SERVER_NATIVE_SEARCH_LOCATIONS=file:./central-config/docker-config/
    uaa-mongodb:
        extends:
            file: mongodb.yml
            service: uaa-mongodb

我的申请-pro.yml

代码语言:javascript
复制
eureka:
    instance:
        prefer-ip-address: true
    client:
        enabled: true
        healthcheck:
            enabled: true
        registerWithEureka: true
        fetchRegistry: true
        serviceUrl:
            defaultZone: ${EUREKA_CLIENT_SERVICEURL_DEFAULTZONE}

spring:
    devtools:
        restart:
            enabled: false
        livereload:
            enabled: false
    data:
        mongodb:
            host: ${SPRING_DATA_MONGODB_HOST}
            port: ${SPRING_DATA_MONGODB_PORT}
            database: ${SPRING_DATA_MONGODB_DATABASE}

现在,我的UAA服务器成功地连接到容器化的mongodb数据库。但现在我有了新的错误..。

代码语言:javascript
复制
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
uaa_1                |  at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111)
uaa_1                |  at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
uaa_1                |  at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
uaa_1                |  at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
uaa_1                |  at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
uaa_1                |  at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:815)
uaa_1                |  at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104)
uaa_1                |  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
uaa_1                |  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
uaa_1                |  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
uaa_1                |  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
uaa_1                |  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
uaa_1                |  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
uaa_1                |  at java.lang.Thread.run(Thread.java:745)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43447586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档