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

consul 起不来 #130

Open
molixiaoge opened this issue Oct 17, 2024 · 4 comments
Open

consul 起不来 #130

molixiaoge opened this issue Oct 17, 2024 · 4 comments

Comments

@molixiaoge
Copy link

1.按照官方文档执行all_install.sh脚本,生成compose文件,这里需要root权限
2.进入/opt/tensuns 执行 docker compose up
3.发现consul启动不了日志如下

consul        | ==> No private IPv4 address found
consul        | ==> No private IPv4 address found
consul        | ==> No private IPv4 address found
consul        | ==> No private IPv4 address found

4./opt/tensuns/docker-compose.yaml如下

version: '3.6'
services:
  consul:
    image: swr.cn-south-1.myhuaweicloud.com/starsl.cn/consul:latest
    container_name: consul
    hostname: consul
    restart: always
    ports:
      - "8500:8500"
    volumes:
     - /opt/tensuns/consul/data:/consul/data
     - /opt/tensuns/consul/config:/consul/config
     - /usr/share/zoneinfo/PRC:/etc/localtime
    command: "agent"
    networks:
      - TenSunS

  flask-consul:
    image: swr.cn-south-1.myhuaweicloud.com/starsl.cn/flask-consul:latest
    container_name: flask-consul
    hostname: flask-consul
    restart: always
    volumes:
      - /usr/share/zoneinfo/PRC:/etc/localtime
    environment:
      consul_token: 1c7b7526-dd5f-4b3a-98de-6b6435c6e21d
      consul_url: http://consul:8500/v1
      admin_passwd: bba7b9ca
      log_level: INFO
    depends_on:
      - consul
    networks:
      - TenSunS

  nginx-consul:
    image: swr.cn-south-1.myhuaweicloud.com/starsl.cn/nginx-consul:latest
    container_name: nginx-consul
    hostname: nginx-consul
    restart: always
    ports:
      - "1026:1026"
    volumes:
      - /usr/share/zoneinfo/PRC:/etc/localtime
    depends_on:
      - flask-consul
    networks:
      - TenSunS

networks:
  TenSunS:
    name: TenSunS
    driver: bridge
    ipam:
      driver: default

5./opt/tensuns/consul/config/consul.hcl 如下

log_level = "error"
data_dir = "/consul/data"
client_addr = "0.0.0.0"
ui_config{
  enabled = true
}
ports = {
  grpc = -1
  https = -1
  dns = -1
  grpc_tls = -1
  serf_wan = -1
}
peering {
  enabled = false
}
connect {
  enabled = false
}
server = true
bootstrap_expect=1
acl = {
  enabled = true
  default_policy = "deny"
  enable_token_persistence = true
  tokens {
    initial_management = "1c7b7526-dd5f-4b3a-98de-6b6435c6e21d"
    agent = "1c7b7526-dd5f-4b3a-98de-6b6435c6e21d"
  }
}

@Leif160519
Copy link
Contributor

Leif160519 commented Oct 25, 2024

这个问题我遇到过,是docker-daemon.json中设置的docker私网地址不是172这种私网地址了,你改成172.18.0.0然后docker-compose down之后再docker-compose up -d 重新生成consul容器就可以起来了@molixiaoge

    "default-address-pools":
        [
            {
                "base": "172.18.0.0/16",
                "size": 24
            }
        ],

@molixiaoge
Copy link
Author

哦,确实是这样的,虚拟机的网址和公司网址,都是192导致内网ip无法反问,所有我改了子网址。
你的意思改成172.18.0.0 就好了?为什么会有这个奇怪的问题。
我的配置如下

	"default-address-pools": [
		{
			"base": "70.0.0.0/16",
			"size": 24
		},
		{
			"base": "70.1.0.0/16",
			"size": 24
		},
		{
			"base": "70.2.0.0/16",
			"size": 24
		},
		{
			"base": "70.3.0.0/16",
			"size": 24
		}
	]

@Leif160519
Copy link
Contributor

哦,确实是这样的,虚拟机的网址和公司网址,都是192导致内网ip无法反问,所有我改了子网址。 你的意思改成172.18.0.0 就好了?为什么会有这个奇怪的问题。 我的配置如下

	"default-address-pools": [
		{
			"base": "70.0.0.0/16",
			"size": 24
		},
		{
			"base": "70.1.0.0/16",
			"size": 24
		},
		{
			"base": "70.2.0.0/16",
			"size": 24
		},
		{
			"base": "70.3.0.0/16",
			"size": 24
		}
	]

consul识别到docker网段为非私网地址就会起不来,应该设计上就是这样的,改成172.18,172.16这种私网地址就可以,我之前出问题的时候,docker网段设置的是198.18网址,结果查了一下是保留网段,所以也同样起不来

@molixiaoge
Copy link
Author

好的

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

2 participants