• centos7部署etcd集群


    实验环境:centos7.4纯净版

    192.168.216.130 node1 master

    192.168.216.132 node2 slave

    192.168.216.134 node3 slave

    yum安装etcd

    yum install etcd 
    yum list installed |grep -i etcd
    

    node1 etcd 配置

    cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
    cd /etc/etcd/
    [root@localhost etcd]# egrep ^[A-Z] ./etcd.conf
    ETCD_DATA_DIR="/var/lib/etcd/node1.etcd"
    ETCD_LISTEN_PEER_URLS="http://192.168.216.130:2380"
    ETCD_LISTEN_CLIENT_URLS="http://192.168.216.130:2379,http://127.0.0.1:2379"
    ETCD_NAME="node1"
    ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.216.130:2380"
    ETCD_ADVERTISE_CLIENT_URLS="http://192.168.216.130:2379"
    ETCD_INITIAL_CLUSTER="node1=http://192.168.216.130:2380,node2=http://192.168.216.132:2380,node3=http://192.168.216.134:2380"
    ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
    ETCD_INITIAL_CLUSTER_STATE="new"
    

    node2 etcd 配置

    cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
    cd /etc/etcd/
    [root@localhost etcd]# egrep ^[A-Z] ./etcd.conf
    ETCD_DATA_DIR="/var/lib/etcd/node2.etcd"
    ETCD_LISTEN_PEER_URLS="http://192.168.216.132:2380"
    ETCD_LISTEN_CLIENT_URLS="http://192.168.216.132:2379,http://127.0.0.1:2379"
    ETCD_NAME="node2"
    ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.216.132:2380"
    ETCD_ADVERTISE_CLIENT_URLS="http://192.168.216.132:2379"
    ETCD_INITIAL_CLUSTER="node1=http://192.168.216.130:2380,node2=http://192.168.216.132:2380,node3=http://192.168.216.134:2380"
    ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
    ETCD_INITIAL_CLUSTER_STATE="new"
    

    node3 etcd 配置

    cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
    cd /etc/etcd/
    [root@localhost etcd]# egrep ^[A-Z] ./etcd.conf
    ETCD_DATA_DIR="/var/lib/etcd/node3.etcd"
    ETCD_LISTEN_PEER_URLS="http://192.168.216.134:2380"
    ETCD_LISTEN_CLIENT_URLS="http://192.168.216.134:2379,http://127.0.0.1:2379"
    ETCD_NAME="node3"
    ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.216.134:2380"
    ETCD_ADVERTISE_CLIENT_URLS="http://192.168.216.134:2379"
    ETCD_INITIAL_CLUSTER="node1=http://192.168.216.130:2380,node2=http://192.168.216.132:2380,node3=http://192.168.216.134:2380"
    ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
    ETCD_INITIAL_CLUSTER_STATE="new"
    

      

    修改 etcd.service

    [root@localhost etcd]# cat /usr/lib/systemd/system/etcd.service
    [Service]
    Type=notify
    WorkingDirectory=/var/lib/etcd/
    EnvironmentFile=-/etc/etcd/etcd.conf
    User=etcd
    # set GOMAXPROCS to number of processors
    ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd 
    --name="${ETCD_NAME}" 
    --data-dir="${ETCD_DATA_DIR}" 
    --listen-peer-urls="${ETCD_LISTEN_PEER_URLS}" 
    --listen-client-urls="${ETCD_LISTEN_CLIENT_URLS}" 
    --initial-advertise-peer-urls="${ETCD_INITIAL_ADVERTISE_PEER_URLS}" 
    --advertise-client-urls="${ETCD_ADVERTISE_CLIENT_URLS}" 
    --initial-cluster="${ETCD_INITIAL_CLUSTER}"  
    --initial-cluster-token="${ETCD_INITIAL_CLUSTER_TOKEN}" 
    --initial-cluster-state="${ETCD_INITIAL_CLUSTER_STATE}""
    Restart=on-failure
    LimitNOFILE=65536
    

    以上操作在 node1、node2、node3 节点上都需要操作,需要修改对应的ip

    启动 etcd

    依次启动 node1、node2、node3 节点的 etcd

    systemctl start etcd.service
    systemctl status etcd.service
    systemctl enable etcd.service
    

    验证 etcd

    etcdctl cluster-health

    etcdctl member list

    各个节点配置crontab 定时同步时间,否则可能会出现node1 etcd[1657]: the clock difference against peer f63afbe816fb463d is too hig问题

    yum install ntp
    crontab -e
    0 1 * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn >> /var/log/ntpdate.log 2>&1 &
    

      

  • 相关阅读:
    js面向对象编程-高级内容
    (转)js中的hasOwnProperty和isPrototypeOf方法
    Bootstrap_表单
    Bootstrap_表格
    Bootstrap_排版
    Bootstrap_网格系统
    Bootstrap_CSS概览
    redis的搜索组件 redis-search4j
    有哪些值得学习的spring boot开源项目?
    国内最火的10款Java开源项目,都是国人开发,CMS居多
  • 原文地址:https://www.cnblogs.com/caidingyu/p/11408389.html
Copyright © 2020-2023  润新知