zoukankan      html  css  js  c++  java
  • consul 集群搭建

    consul 集群搭建

    一、三台机器

    基本信息

    192.168.80.128
    192.168.80.129
    192.168.80.130
    

    二、下载consul

    wget https://releases.hashicorp.com/consul/1.9.5/consul_1.9.5_linux_amd64.zip
    # 解压出来就是一个二进制文件
    

    三、三台机器分别创建目录和文件

    mkdir /opt/consul/bin/
    # 拷贝解压的二进制文件至 /opt/consul/bin/
    mkdir /opt/consul/data/
    mkdir /opt/consul/logs/
    mkdir /opt/consul/conf/
    

    四、配置

    192.168.80.128 机器配置 consul.json

    {
        "datacenter": "djx-test",           
        "data_dir": "/opt/consul/data",     
        "log_level": "INFO",                
        "node_name": "192.168.80.128",        
        "server": true,                     
        "ui": true,                         
        "bootstrap_expect": 1,              
        "bind_addr": "192.168.80.128",        
        "client_addr": "0.0.0.0",           
        "retry_join": ["192.168.80.129","192.168.80.130"],  
        "retry_interval": "3s",             
        "raft_protocol": 3,                 
        "enable_debug": false,              
        "rejoin_after_leave": true,       
        "enable_syslog": false,
        "telemetry": {
          "statsite_address": "127.0.0.1:9125"
        } 
    }
    

    192.168.80.129 配置 consul.json

    {
        "datacenter": "djx-test",           
        "data_dir": "/opt/consul/data",     
        "log_level": "INFO",                
        "node_name": "192.168.80.129",        
        "server": true,                     
        "ui": true,                         
        "bootstrap_expect": 1,              
        "bind_addr": "192.168.80.129",        
        "client_addr": "0.0.0.0",           
        "retry_join": ["192.168.80.128","192.168.80.130"],  
        "retry_interval": "3s",             
        "raft_protocol": 3,                 
        "enable_debug": false,              
        "rejoin_after_leave": true,       
        "enable_syslog": false,
        "telemetry": {
          "statsite_address": "127.0.0.1:9125"
        } 
    }
    

    192.168.80.130 配置 consul.json

    {
        "datacenter": "djx-test",           
        "data_dir": "/opt/consul/data",     
        "log_level": "INFO",                
        "node_name": "192.168.80.130",        
        "server": true,                     
        "ui": true,                         
        "bootstrap_expect": 1,              
        "bind_addr": "192.168.80.130",        
        "client_addr": "0.0.0.0",           
        "retry_join": ["192.168.80.128","192.168.80.129"],  
        "retry_interval": "3s",             
        "raft_protocol": 3,                 
        "enable_debug": false,              
        "rejoin_after_leave": true,       
        "enable_syslog": false,
        "telemetry": {
          "statsite_address": "127.0.0.1:9125"
        } 
    }
    

    五、三台机器都配置成系统服务

    /usr/lib/systemd/system/consul.service

    [Unit]
    Description=consul
    After=network.target
    
    [Service]
    LimitNOFILE=32768
    Type=simple
    Restart=on-failure
    ExecStart=/opt/consul/bin/consul agent -config-dir /opt/consul/conf/ -http-port=8500 -log-file=/opt/consul/logs/consul.log
    
    [Install]
    WantedBy=multi-user.target
    

    六、启动服务并添加到系统服务

    systemctl start consul
    systemctl enable consul
    

    七、查看集群节点

    consul  members
    
    / # consul  members
    Node                     Address             Status  Type    Build  Protocol  DC     Segment
    192.168.80.130               192.168.80.130:8301     alive   server  1.3.1  2         djx-test  <all>
    192.168.80.129                192.168.80.129:8301     alive   server  1.3.1  2         djx-test  <all>
    192.168.80.128                192.168.80.128:8301     alive   server  1.3.1  2         djx-test <all>
    
    作者:理想三旬
    出处:
    如果觉得文章写得不错,或者帮助到您了,请点个赞,加个关注哦。运维学习交流群:544692191
    本文版权归作者所有,欢迎转载,如果文章有写的不足的地方,或者是写得错误的地方,请你一定要指出,因为这样不光是对我写文章的一种促进,也是一份对后面看此文章的人的责任。谢谢。
  • 相关阅读:
    c:forTokens标签循环输出
    jsp转long类型为date,并且格式化
    spring中@Param和mybatis中@Param使用区别(暂时还没接触)
    734. Sentence Similarity 有字典数组的相似句子
    246. Strobogrammatic Number 上下对称的数字
    720. Longest Word in Dictionary 能连续拼接出来的最长单词
    599. Minimum Index Sum of Two Lists两个餐厅列表的索引和最小
    594. Longest Harmonious Subsequence强制差距为1的最长连续
    645. Set Mismatch挑出不匹配的元素和应该真正存在的元素
    409. Longest Palindrome 最长对称串
  • 原文地址:https://www.cnblogs.com/operationhome/p/14830677.html
Copyright © 2011-2022 走看看