节点规划 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 查看恢复的数据已正常