• etcd 集群部署与数据恢复


    节点规划
    172.25.102.10  node1
    172.25.102.39  node2
    172.25.102.17  node3
    
    部署过程
    三个节点都执行
    yum install etcd -y
    mkdir /data/etcd 
    
    
    node1:
    配置文件
    $ cat /etc/etcd/etcd.conf
    #[Member]
    ETCD_NAME="node1" 
    ETCD_DATA_DIR="/data/etcd/node1.etcd/" 
    ETCD_LISTEN_PEER_URLS="http://172.25.102.10:2380"
    ETCD_LISTEN_CLIENT_URLS="http://172.25.102.10:2379,http://127.0.0.1:2379"
       
    #[Clustering]
    ETCD_INITIAL_ADVERTISE_PEER_URLS="http://172.25.102.10:2380"
    ETCD_ADVERTISE_CLIENT_URLS="http://172.25.102.10:2379" 
    ETCD_INITIAL_CLUSTER="node1=http://172.25.102.10:2380,node2=http://172.25.102.39:2380,node3=http://172.25.102.17:2380" 
    ETCD_INITIAL_CLUSTER_TOKEN="token001"
    ETCD_INITIAL_CLUSTER_STATE="new"
    
    
    node1 启动文件
    $ cat /usr/lib/systemd/system/etcd.service 
    [Unit]
    Description=Etcd Server
    After=network.target
    [Service]
    Type=simple
    WorkingDirectory=/data/etcd/
    EnvironmentFile=-/etc/etcd/etcd.conf
    ExecStart=/usr/bin/etcd  --auto-compaction-retention=1 --quota-backend-bytes=8589934592
    [Install]
    WantedBy=multi-user.target
    
    启动 node1
    systemctl start etcd
    
    
    
    node2 
    配置文件
    $ cat /etc/etcd/etcd.conf
    #[Member]
    ETCD_NAME="node2" 
    ETCD_DATA_DIR="/data/etcd/node2.etcd/" 
    ETCD_LISTEN_PEER_URLS="http://172.25.102.39:2380"
    ETCD_LISTEN_CLIENT_URLS="http://172.25.102.39:2379,http://127.0.0.1:2379"
       
    #[Clustering]
    ETCD_INITIAL_ADVERTISE_PEER_URLS="http://172.25.102.39:2380"
    ETCD_ADVERTISE_CLIENT_URLS="http://172.25.102.39:2379" 
    ETCD_INITIAL_CLUSTER="node1=http://172.25.102.10:2380,node2=http://172.25.102.39:2380,node3=http://172.25.102.17:2380" 
    ETCD_INITIAL_CLUSTER_TOKEN="token001"
    ETCD_INITIAL_CLUSTER_STATE="new"
    
    
    node2 
    启动文件
    $  cat /usr/lib/systemd/system/etcd.service 
    [Unit]
    Description=Etcd Server
    After=network.target
    [Service]
    Type=simple
    WorkingDirectory=/data/etcd/
    EnvironmentFile=-/etc/etcd/etcd.conf
    ExecStart=/usr/bin/etcd --auto-compaction-retention=1 --quota-backend-bytes=8589934592
    [Install]
    WantedBy=multi-user.target
    
    启动 node2
    systemctl start etcd
    
    node3
    配置文件
    $ cat /etc/etcd/etcd.conf 
    #[Member]
    ETCD_NAME="node3" 
    ETCD_DATA_DIR="/data/etcd/node3.etcd/" 
    ETCD_LISTEN_PEER_URLS="http://172.25.102.17:2380"
    ETCD_LISTEN_CLIENT_URLS="http://172.25.102.17:2379,http://127.0.0.1:2379"
       
    #[Clustering]
    ETCD_INITIAL_ADVERTISE_PEER_URLS="http://172.25.102.17:2380"
    ETCD_ADVERTISE_CLIENT_URLS="http://172.25.102.17:2379" 
    ETCD_INITIAL_CLUSTER="node1=http://172.25.102.10:2380,node2=http://172.25.102.39:2380,node3=http://172.25.102.17:2380" 
    ETCD_INITIAL_CLUSTER_TOKEN="token001"
    ETCD_INITIAL_CLUSTER_STATE="new"
    
    
    node3 启动文件
    $  cat /usr/lib/systemd/system/etcd.service 
    [Unit]
    Description=Etcd Server
    After=network.target
    [Service]
    Type=simple
    WorkingDirectory=/data/etcd/
    EnvironmentFile=-/etc/etcd/etcd.conf
    ExecStart=/usr/bin/etcd --auto-compaction-retention=1 --quota-backend-bytes=8589934592
    [Install]
    WantedBy=multi-user.target
    
    启动 node3
    systemctl start etcd
    
    
    
    
    
    etcd 数据恢复
    
    etcd 获取备份数据172.24.119.41-snapshot-2019-09-24.db 后,分别将改备份数据分发至三个节点
    分别停止etcd 三个节点
    
    
    systemctl stop etcd
    确认停掉三个节点后依次执行恢复操作
    
    
    node1 恢复操作
    mv /data/etcd/node1.etcd /data/etcd/node1.etcd_bak
    cd /data/etcd/
    etcdctl snapshot  restore   /data/172.24.119.41-snapshot-2019-09-24.db            --name node1   --initial-cluster node1=http://172.25.102.10:2380,node2=http://172.25.102.39:2380,node3=http://172.25.102.17:2380   --initial-advertise-peer-urls http://172.25.102.10:2380
    
    
    node2 恢复操作
    mv /data/etcd/node2.etcd /data/etcd/node2.etcd_bak
    cd /data/etcd/
    etcdctl snapshot  restore   /data/172.24.119.41-snapshot-2019-09-24.db            --name node2   --initial-cluster node1=http://172.25.102.10:2380,node2=http://172.25.102.39:2380,node3=http://172.25.102.17:2380   --initial-advertise-peer-urls http://172.25.102.39:2380
    
    
    node3 恢复操作
    
    mv /data/etcd/node3.etcd /data/etcd/node3.etcd_bak
    cd /data/etcd/
    etcdctl snapshot  restore   /data/172.24.119.41-snapshot-2019-09-24.db            --name node3   --initial-cluster node1=http://172.25.102.10:2380,node2=http://172.25.102.39:2380,node3=http://172.25.102.17:2380   --initial-advertise-peer-urls http://172.25.102.17:2380
    
    
    node1 node2 node3 依次启动 etcd
    systemctl start etcd
    
    etcdctl get /ad/media  查看恢复的数据已正常
    

      

  • 相关阅读:
    0302思考并回答一些问题
    1231 实验四 递归下降语法分析程序设计
    1118 实验三 有限自动机的构造与识别
    1112对他人的博客评论及建议
    1029c语言文法
    1022词法分析实验总结
    词法分析
    0330 复利计算——单元测试
    0321 读《构建之法》第一,二,三章有感
    0316 复利计算总结(0330 更新)
  • 原文地址:https://www.cnblogs.com/lixinliang/p/13644321.html
Copyright © 2020-2023  润新知