• 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 &
    

      

  • 相关阅读:
    HDU1852 Beijing 2008(快速幂+特殊公式)
    HihoCoder 1570 : 小Hi与法阵(简单几何)
    【转】反素数
    【整理】线段树30题
    SPOJcot2 Count on a tree II (树上莫队)
    【总结】曼哈顿距离转切比雪夫距离
    【初识】树上分块
    基于Tablestore Tunnel的数据复制实战
    【New Feature】阿里云快照服务技术解析
    基于日志服务的GrowthHacking(1):数据埋点和采集(APP、Web、邮件、短信、二维码埋点技术)
  • 原文地址:https://www.cnblogs.com/caidingyu/p/11408389.html
Copyright © 2020-2023  润新知