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

    实验准备
    三台服务器
    etcd1: 192.168.70.93
    etcd2: 192.168.87.140
    etcd3: 192.168.66.23

    在etcd01 上运行如下

    useradd -M -s /bin/false etcd
    cd /usr/local/
    wget https://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz
    tar zxf etcd-v3.4.14-linux-amd64.tar.gz
    ln -s etcd-v3.4.14-linux-amd64 etcd
    cd etcd
    mkdir etc bin data
    mv etcd ./bin
    mv etcdctl ./bin
    ln -s ./bin/etcd /usr/bin/
    ln -s ./bin/etcdctl /usr/bin/
    cat > ./etc/etcd.json << EOF
    {
    "name":"etcd1",
    "data-dir":"/usr/local/etcd/data",
    "listen-peer-urls":"http://192.168.70.93:2380",
    "listen-client-urls":"http://192.168.70.93:2379,http://127.0.0.1:2379",
    "initial-advertise-peer-urls":"http://192.168.70.93:2380",
    "initial-cluster":"etcd1=http://192.168.70.93:2380,etcd2=http://192.168.87.140:2380,etcd3=http://192.168.66.23:2380",
    "initial-cluster-state":"new",
    "initial-cluster-token":"etcd-cluster-token",
    "advertise-client-urls":"http://192.168.70.93:2379"
    }
    EOF
    
    cat > /usr/lib/systemd/system/etcd.service << EOF
    [Unit]
    Description=Etcd Server
    After=network.target
    
    
    [Service]
    Type=simple
    Restart=on-failure
    LimitNOFILE=40000
    User=etcd
    WorkingDirectory=/usr/local/etcd/data/ 
    ExecStart=/usr/local/etcd/bin/etcd --config-file=/usr/local/etcd/etc/etcd.json
    
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    systemctl daemon-reload
    systemctl enable etcd
    systemctl start etcd
    systemctl restart etcd
    

    在etcd02上

    和etcd1上的区别是在etcd.json文件的配置

    cat > ./etc/etcd.json << EOF
    {
    "name":"etcd2",
    "data-dir":"/usr/local/etcd/data",
    "listen-peer-urls":"http://192.168.87.140:2380",
    "listen-client-urls":"http://192.168.87.140:2379,http://127.0.0.1:2379",
    "initial-advertise-peer-urls":"http://192.168.87.140:2380",
    "initial-cluster":"etcd1=http://192.168.70.93:2380,etcd2=http://192.168.87.140:2380,etcd3=http://192.168.66.23:2380",
    "initial-cluster-state":"new",
    "initial-cluster-token":"etcd-cluster-token",
    "advertise-client-urls":"http://192.168.87.140:2379"
    }
    EOF
    

    在etcd03上

    和etcd1上的区别是在etcd.json文件的配置

    cat > ./etc/etcd.json << EOF
    {
    "name":"etcd3",
    "data-dir":"/usr/local/etcd/data",
    "listen-peer-urls":"http://192.168.66.23:2380",
    "listen-client-urls":"http://192.168.66.23:2379,http://127.0.0.1:2379",
    "initial-advertise-peer-urls":"http://192.168.66.23:2380",
    "initial-cluster":"etcd1=http://192.168.70.93:2380,etcd2=http://192.168.87.140:2380,etcd3=http://192.168.66.23:2380",
    "initial-cluster-state":"new",
    "initial-cluster-token":"etcd-cluster-token",
    "advertise-client-urls":"http://192.168.66.23:2379"
    }
    EOF
    

    通过etcdctl member list 检查集群状态

    本人水平有限,还在不断学习中 难免有很多错误或者遗漏,望见谅
  • 相关阅读:
    1203正规式转换为有穷自动机
    访问本班同学的博客
    0312复利计算3
    操作系统
    0311复利计算2
    0309简单的复利计算
    0302IT行业虽吃香,能完全享受这块“香"的也很难
    12.30递归下降语义分析
    1203正规式转换为有穷自动机
    对10位同学的文法解释和语法树的评论
  • 原文地址:https://www.cnblogs.com/faberbeta/p/etcd001.html
Copyright © 2011-2022 走看看