Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose 中启动nacos和seata,nacos仅仅作为seata的注册中心,启动抛异常 #2706

Closed
1 task
orange-form opened this issue May 20, 2020 · 7 comments

Comments

@orange-form
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Ⅰ. Issue Description

下面是我的docker-compose 文件。
version: '3.2'

services:
nacos:
image: nacos/nacos-server:latest
container_name: nacos-standalone
environment:
- PREFER_HOST_MODE=hostname
- MODE=standalone
volumes:
- ./logs/nacos/:/home/nacos/logs
- ./data/nacos/:/home/nacos/data
ports:
- "8848:8848"
networks:
- zz-test

seata-server:
image: seataio/seata-server:1.2.0
hostname: seata-server
ports:
- "8091:8091"
environment:
- SEATA_PORT=8091
- STORE_MODE=file
- SEATA_CONFIG_NAME=file:/root/seata-config/registry
- SEATA_IP=localhost
volumes:
- ./services/seata/:/root/seata-config
- ./logs/seata:/root/logs
links:
- nacos
depends_on:
- nacos
networks:
- zz-test

networks:
zz-test:
driver: bridge

下面是registry.conf

registry {
type = "nacos"

nacos {
application = "my-seata-server"
serverAddr = "nacos"
namespace = ""
cluster = "default"
username = ""
password = ""
}
}

config {
type = "file"

file {
name = "file:/root/seata-config/file.conf"
}
}

附件文件seata-startup-exception.txt是seata启动抛出的异常。
naming.log是nacos的日志。
BTW,这些配置的缩进都是正确的,只是提交issue之后的显示问题。
seata-startup-exception.txt
naming.log

@zjinlei
Copy link
Contributor

zjinlei commented May 20, 2020

username = ""
password = ""
应该是nacos 1.2.0的权限控制

@orange-form
Copy link
Author

@zjinlei 已经改为下面的应用配置了还是不行。另外,相同的配置如果我不用docker,而是命令行启动,注册nacos是没有问题的。
nacos {
application = "my-seata-server"
serverAddr = "nacos"
namespace = ""
cluster = "default"
username = "nacos"
password = "nacos"
}

@cmonkey
Copy link
Contributor

cmonkey commented May 21, 2020

看日志,看起来是你网络配置的问题,serverAddr = "nacos", nacos 这个别名在容器里面有指向一个具体的ip 吗?

@orange-form
Copy link
Author

@cmonkey
没有指向具体的ip,但是我在docker-compose中,用links引用了nacos 容器了。举个例子,我把seata的服务中心改为file,这样就能docker启动了,然后我进入docker容器,是可以ping到nacos这个服务名的。

@helloworlde
Copy link
Contributor

@orange-form
seata启动的时候 nacos 启动没有完成,注册失败后直接关闭了,需要等nacos启动完成后再启动

version: '2.1'

services:
  nacos:
    image: nacos/nacos-server:latest
    container_name: nacos-server
    healthcheck:
      test: curl localhost:8848/nacos
      interval: 10s
      timeout: 3s
      retries: 3
    environment:
      - PREFER_HOST_MODE=hostname
      - MODE=standalone
    ports:
      - "8848:8848"
    networks:
      - seata_network

  seata-server:
    image: seataio/seata-server:1.2.0
    container_name: seata-server
    hostname: seata-server
    ports:
      - "8091:8091"
    environment:
      - SEATA_PORT=8091
      - SEATA_CONFIG_NAME=file:/root/seata-config/registry
    volumes:
      - ./seata/:/root/seata-config
    links:
      - nacos
    depends_on:
      nacos:
        condition: service_healthy
    networks:
      - seata_network

networks:
  seata_network:
    driver: bridge

docker-compose 延迟启动参考 docker/compose#374

@orange-form
Copy link
Author

@helloworlde
非常感谢您的建议。我后来又仔细想了一下,确实如您所说。

@hermitcai
Copy link

害 就是启动先后顺序的问题了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants