Commit 6693340 1 parent 608b0bc commit 6693340 Copy full SHA for 6693340
File tree 3 files changed +27
-14
lines changed
roles/cluster-restore/tasks
3 files changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,14 @@ for ip in ${NODE_IPS}; do
102
102
--cert=/etc/kubernetes/ssl/etcd.pem \
103
103
--key=/etc/kubernetes/ssl/etcd-key.pem \
104
104
endpoint health; done
105
+
106
+ for ip in ${NODE_IPS} ; do
107
+ ETCDCTL_API=3 etcdctl \
108
+ --endpoints=https://${ip} :2379 \
109
+ --cacert=/etc/kubernetes/ssl/ca.pem \
110
+ --cert=/etc/kubernetes/ssl/etcd.pem \
111
+ --key=/etc/kubernetes/ssl/etcd-key.pem \
112
+ --write-out=table endpoint status; done
105
113
` ` `
106
114
预期结果:
107
115
Original file line number Diff line number Diff line change 43
43
--cert={{ cluster_dir }}/ssl/etcd.pem \
44
44
--key={{ cluster_dir }}/ssl/etcd-key.pem \
45
45
snapshot save snapshot_{{ timestamp.stdout }}.db"
46
- args :
47
- warn : false
48
46
49
47
- name : update the latest backup
50
48
shell : ' cd {{ cluster_dir }}/backup/ && /bin/cp -f snapshot_{{ timestamp.stdout }}.db snapshot.db'
Original file line number Diff line number Diff line change 4
4
- name: 清除etcd 数据目录
5
5
file: name={{ ETCD_DATA_DIR }}/member state=absent
6
6
7
- - name : 清除 etcd 备份目录
8
- file : name={{ cluster_dir }}/backup/etcd-restore state=absent
9
- delegate_to : 127.0.0.1
10
- run_once : true
7
+ - name: 清理上次备份恢复数据
8
+ file: name=/etcd_backup state=absent
9
+
10
+ - name: 生成备份目录
11
+ file: name=/etcd_backup state=directory
12
+
13
+ - name: 准备指定的备份etcd 数据
14
+ copy:
15
+ src: "{{ cluster_dir }}/backup/{{ db_to_restore }}"
16
+ dest: "/etcd_backup/snapshot.db"
11
17
12
18
- name: etcd 数据恢复
13
- shell : " cd {{ cluster_dir }}/backup && \
14
- ETCDCTL_API=3 {{ base_dir }}/bin/etcdctl snapshot restore snapshot.db \
15
- --data-dir={{ cluster_dir }}/backup/etcd-restore"
16
- delegate_to : 127.0.0.1
17
- run_once : true
18
-
19
- - name : 分发恢复文件到 etcd 各个节点
20
- copy : src={{ cluster_dir }}/backup/etcd-restore/member dest={{ ETCD_DATA_DIR }}
19
+ shell: "cd /etcd_backup && \
20
+ ETCDCTL_API=3 {{ bin_dir }}/etcdctl snapshot restore snapshot.db \
21
+ --name etcd-{{ inventory_hostname }} \
22
+ --initial-cluster {{ ETCD_NODES }} \
23
+ --initial-cluster-token etcd-cluster-0 \
24
+ --initial-advertise-peer-urls https://{{ inventory_hostname }}:2380"
25
+
26
+ - name: 恢复数据至etcd 数据目录
27
+ shell: "cp -rf /etcd_backup/etcd-{{ inventory_hostname }}.etcd/member {{ ETCD_DATA_DIR }}/"
21
28
22
29
- name: 重启etcd 服务
23
30
service: name=etcd state=restarted
You can’t perform that action at this time.
0 commit comments