• 搭建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 检查集群状态

    本人水平有限,还在不断学习中 难免有很多错误或者遗漏,望见谅
  • 相关阅读:
    MySQL数据库命令行界面不支持中文
    mysqldump使用方法(MySQL数据库的备份与恢复)
    MySQL性能测试初试(1)--sysbench
    composer安装
    Java关键字[static].md
    Docker容器
    Docker概述及安装
    Docker镜像
    定时任务[crontab]
    Linux下的curl工具
  • 原文地址:https://www.cnblogs.com/faberbeta/p/etcd001.html
Copyright © 2020-2023  润新知