starsliao / TenSunS

🦄后羿 - TenSunS(原ConsulManager):基于Consul的运维平台:更优雅的Consul管理UI&多云与自建ECS/MySQL/Redis同步Prometheus/JumpServer&ECS/MySQL/Redis云监控指标采集&Blackbox站点监控维护&漏洞通知/资源到期余额告警&各类资源Grafana看板展示
https://StarsL.cn
Do What The F*ck You Want To Public License
1.29k stars 238 forks source link

consul 起不来 #130

Open molixiaoge opened 2 weeks ago

molixiaoge commented 2 weeks ago

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 commented 6 days ago

这个问题我遇到过,是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 commented 5 days ago

哦,确实是这样的,虚拟机的网址和公司网址,都是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 commented 5 days ago

哦,确实是这样的,虚拟机的网址和公司网址,都是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 commented 3 days ago

好的