etcd搭建和备份

etcd搭建和备份

九月 04, 2018
  1. Download etcd.tar.gz
  2. 编写etcd的supervisor启动脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@ip conf.d]# cat etcd_viewer.conf
[program:etcd_viewer]
directory=/opt/etcd-viewer/
command=/usr/local/apache-maven-3.3.3/bin/mvn jetty:run
stdout_logfile=/opt/supervisor/log/etcd-viewer.log
user=root
redirect_stderr=true


[root@ip conf.d]# cat skydns.conf
[program:skydns]
directory=/opt/supervisor/
#command=/usr/bin/skydns
# -addr=0.0.0.0:53
# -machines=http://127.0.0.1:2379
# -nameservers="":53
# -discover=true
# -domain="xxx.net."
command=/usr/local/bin/skydns
# -discover=true
-machines="http://10.xx.xx.xx:2379,http://10.xx.xx.xx"
-verbose=true
stdout_logfile=/opt/supervisor/log/skydns.log
user=root
redirect_stderr=true
  1. 备份
1
# etcdctl backup --data-dir=/opt/etcd/etcd-data --backup-dir=/tmp/etcd-backup-`date +%y%m%d%H`
  1. 还原
1
停止etcd,将备份数据拷贝到data-dir下,启动配置需加上--force-new-cluster参数,启动etcd