• Consul安装


    一、Docker方式

    1.1 查找consul镜像

    使用docker search consul查看仓库中的consul镜像。

    [root@docker ~]# docker search consul
    NAME                                    DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    consul                                  Consul is a datacenter runtime that provides…   1323      [OK]
    progrium/consul                                                                         356                  [OK]
    hashicorp/consul                        Automatic build of consul based on the curre…   33                   [OK]
    hashicorp/consul-template               Consul Template is a template renderer, noti…   28
    gliderlabs/consul-agent                                                                 14                   [OK]
    jhipster/consul-config-loader           A small docker based tool to load Spring Boo…   9                    [OK]
    hashicorp/consul-k8s                    First-class integrations between Consul and …   9                    [OK]
    prom/consul-exporter                                                                    9                    [OK]
    bitnami/consul                          Bitnami Docker Image for Consul                 7                    [OK]
    edgexfoundry/docker-core-consul         ARCHIVED! The legacy Consul service for olde…   5
    consultent/azure-pipelines-vsts-agent   Containerized agent for Azure Pipelines Self…   5
    hashicorp/consul-enterprise             Consul is a datacenter runtime that provides…   4
    wdijkerman/consul                       Consul 1.8.2 running on Alpine 3.11             3                    [OK]
    myena/consul-backinator                 Command line Consul KV backup and restore ut…   3                    [OK]
    unifio/consul                           HashiCorp Consul                                1
    consult2016/ascdso-aws-hello-world                                                      0
    layer5/meshery-consul                   Meshery adapter for HashiCorp Consul            0
    newrelic/k8s-nri-consul                 New Relic Infrastructure Consul Integration     0
    ibmcom/consul-amd64                                                                     0
    ibmcom/consul                                                                           0
    ibmcom/consul-s390x                     Docker image for consul-s390x                   0
    ibmcom/consul-ppc64le                   Consul is a datacenter runtime that provides…   0
    hashicorp/consul-k8s-control-plane      First-class integrations between Consul and …   0
    bitnami/consul-exporter                                                                 0
    pdffiller/consul                        consul version - 0.8.1                          0
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    1.2 拉取consul镜像

    使用docker pull consul拉取consul镜像。

    [root@docker ~]# docker pull consul
    Using default tag: latest
    latest: Pulling from library/consul
    df9b9388f04a: Downloading
    7aa48d4bd8bb: Download complete
    fa3ef9b012a5: Download complete
    d239fc798a4c: Download complete
    199124be58be: Download complete
    5c3ccfe93b8b: Download complete
    latest: Pulling from library/consul
    df9b9388f04a: Pull complete
    7aa48d4bd8bb: Pull complete
    fa3ef9b012a5: Pull complete
    d239fc798a4c: Pull complete
    199124be58be: Pull complete
    5c3ccfe93b8b: Pull complete
    Digest: sha256:ee0735e34f80030c46002f71bc594f25e3f586202da8784b43b4050993ef2445
    Status: Downloaded newer image for consul:latest
    docker.io/library/consul:latest
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    1.3 启动Consul容器

    1.3.1 创建一个consul网络

    docker network create consul
    
    • 1

    1.3.2 启动Consul容器

    docker run --network consul --name consul -p 8500:8500 -p 8300:8300 -p 8301:8301 -p 8302:8302 -p 8600:8600 consul agent -server -bootstrap-expect 1 -ui -bind=0.0.0.0 -client=0.0.0.0
    
    • 1

    1.4 端口说明

    8500: http 端口,用于 http 接口和 web ui访问;
    
    8300: server rpc 端口,同一数据中心 consul server 之间通过该端口通信;
    
    8301: serf lan 端口,同一数据中心 consul client 通过该端口通信; 用于处理当前datacenter中LAN的gossip通信;
    
    8302: serf wan 端口,不同数据中心 consul server 通过该端口通信; agent Server使用,处理与其他datacenter的gossip通信;
    
    8600: dns 端口,用于已注册的服务发现;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    1.5 开放相关端口

    8500:

    firewall-cmd --zone=public --add-port=8500/tcp --permanent
    
    • 1

    8300:

    firewall-cmd --zone=public --add-port=8300/tcp --permanent
    
    • 1

    8301:

    firewall-cmd --zone=public --add-port=8301/tcp --permanent
    
    • 1

    8302:

    firewall-cmd --zone=public --add-port=8302/tcp --permanent
    
    • 1

    8600:

    firewall-cmd --zone=public --add-port=8600/tcp --permanent
    
    • 1

    重启防火墙:

    firewall-cmd --reload
    
    • 1

    查看开放的端口:

    firewall-cmd --list-port
    
    • 1

    1.6 验证

    因为已经开启了UI显示,打开地址如下:http://192.168.1.222:8500
    在这里插入图片描述

    二、二进制方式安装

    2.1 下载 consul

    下载地址:https://releases.hashicorp.com/consul
    在这里插入图片描述
    这里选择 consul_1.12.2 版本的下载:
    在这里插入图片描述
    将下载的consul_1.12.2_linux_amd64.zip上传到 /tmp/consul/下。

    2.2 解压

    解压命令:

    unzip consul_1.12.2_linux_amd64.zip
    
    • 1

    如果报:-bash: unzip: 未找到命令,则需要安装unzip,然后重试。

    yum -y install unzip
    
    • 1

    2.3 检查 Consul

    ./consul
    
    • 1

    看到如下界面说明安装成功。

    [root@docker consul]# ./consul
    Usage: consul [--version] [--help] <command> [<args>]
    
    Available commands are:
        acl            Interact with Consul's ACLs
        agent          Runs a Consul agent
        catalog        Interact with the catalog
        config         Interact with Consul's Centralized Configurations
        connect        Interact with Consul Connect
        debug          Records a debugging archive for operators
        event          Fire a new event
        exec           Executes a command on Consul nodes
        force-leave    Forces a member of the cluster to enter the "left" state
        info           Provides debugging information for operators.
        intention      Interact with Connect service intentions
        join           Tell Consul agent to join cluster
        keygen         Generates a new encryption key
        keyring        Manages gossip layer encryption keys
        kv             Interact with the key-value store
        leave          Gracefully leaves the Consul cluster and shuts down
        lock           Execute a command holding a lock
        login          Login to Consul using an auth method
        logout         Destroy a Consul token created with login
        maint          Controls node or service maintenance mode
        members        Lists the members of a Consul cluster
        monitor        Stream logs from a Consul agent
        operator       Provides cluster-level tools for Consul operators
        reload         Triggers the agent to reload configuration files
        rtt            Estimates network round trip time between nodes
        services       Interact with services
        snapshot       Saves, restores and inspects snapshots of Consul server state
        tls            Builtin helpers for creating CAs and certificates
        validate       Validate config files/directories
        version        Prints the Consul version
        watch          Watch for changes in Consul
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35

    2.4 启动 Consul

    我的linux Ip地址192.168.1.222

    ./consul agent -dev -ui -node=consul-dev -client=192.168.1.222
    #或
    nohup ./consul agent -dev -ui -node=consul-dev -client=192.168.1.222
    
    • 1
    • 2
    • 3

    2.5 验证

    因为已经开启了UI显示,打开地址如下:http://192.168.1.222:8500
    在这里插入图片描述

  • 相关阅读:
    漏洞深度分析|Apache MINA SSHD反序列化漏洞
    使用jxls excel模板填充生成Excel,多sheet页处理
    Anolis 8.6 安装 Drawio
    每天5分钟机器学习算法:支持向量机之硬间隔分类器以及SMO算法
    065:mapboxGL在一个图层中随机添加100个标记(marker)
    如何在远程服务器上部署纯静态网站,centos8使用nginx部署纯静态页面
    CMAK Kafka可视化管理工具
    98%的人都不会使用这6种地图可视化方法,学会直接涨薪5K
    解放工程师双手帮助网工做运维
    django填充pyechart的图到前端模版中(不使用Ajax,而是直接贴一个div)
  • 原文地址:https://blog.csdn.net/Mr_XiMu/article/details/125607855