Etcd搭建备份及还原

  1. Download etcd.tar.gz
  2. 编写etcd的supervisor启动脚本
etcd1
[root@VM_7_centos opt]# cat /etc/supervisord/conf.d/etcd.conf
[program:etcd]
directory=/opt/etcd/etcd-data
command=/usr/local/bin/etcd
  -name ip-xx-xx-xx-7
  --data-dir /opt/etcd/etcd-data
  -initial-advertise-peer-urls http://xx.xx.xx.7:2380
  -listen-peer-urls http://xx.xx.xx.7:2380
  -listen-client-urls http://xx.xx.xx.7:2379,http://127.0.0.1:2379
  -advertise-client-urls http://xx.xx.xx.7:2379
  -initial-cluster-token etcd-cluster-wpys
  -initial-cluster ip-xx-xx-xx-7=http://xx.xx.xx.7:2380,ip-xx-xx-xx-9=http://xx.xx.xx.9:2380
stdout_logfile=/opt/supervisor/log/etcd.log
user=root
redirect_stderr=true
etcd2
[root@VM_9_centos opt]# cat /etc/supervisord/conf.d/etcd.conf
[program:etcd]
directory=/opt/etcd/etcd-data
command=/usr/local/bin/etcd
  -name ip-xx-xx-xx-9
  --data-dir /opt/etcd/etcd-data
  -initial-advertise-peer-urls http://xx.xx.xx.9:2380
  -listen-peer-urls http://xx.xx.xx.9:2380
  -listen-client-urls http://xx.xx.xx.9:2379,http://127.0.0.1:2379
  -advertise-client-urls http://xx.xx.xx.9:2379
  -initial-cluster-token etcd-cluster-wpys
  -initial-cluster ip-xx-xx-xx-7=http://xx.xx.xx.7:2380,ip-xx-xx-xx-9=http://xx.xx.xx.9:2380
stdout_logfile=/opt/supervisor/log/etcd.log
user=root
redirect_stderr=true
  1. 备份
# etcdctl backup --data-dir=/opt/etcd/etcd-data --backup-dir=/tmp/etcd-backup-`date +%y%m%d%H`
  1. 还原
停止etcd,将备份数据拷贝到data-dir下,启动配置需加上--force-new-cluster参数,启动etcd

你可能感兴趣的:(Etcd搭建备份及还原)