forked from pingcap/tidb-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unsafe_cleanup_data.yml
158 lines (130 loc) · 4.11 KB
/
unsafe_cleanup_data.yml
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
# Copyright 2016 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
# The playbook of TiDB
- name: check config locally
hosts: localhost
tags:
- always
roles:
- check_config_static
- name: gather all facts, and check dest
hosts: all
tags:
- always
roles:
- check_config_dynamic
- name: TiDB cluster
hosts: tidb_servers
tags:
- tidb
tasks:
- name: stop TiDB by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when: process_supervision == 'supervise'
with_items:
- tidb
- name: stop TiDB by systemd
systemd: name=tidb-{{ tidb_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the TiDB port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ tidb_port }}"
state: stopped
msg: "the TiDB port {{ tidb_port }} is not down"
- name: pump cluster
hosts: pump_servers
tags:
- pump
tasks:
- name: stop pump by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
with_items:
- pump
when:
- enable_binlog|default(false)
- process_supervision == 'supervise'
- name: stop pump by systemd
systemd: name=pump-{{ pump_port }}.service state=stopped
become: true
when:
- enable_binlog|default(false)
- process_supervision == 'systemd'
- name: wait until the pump port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ pump_port }}"
state: stopped
msg: "the pump port {{ pump_port }} is not down"
when: enable_binlog|default(false)
- name: clean pump data
file: path={{ pump_data_dir }} state=absent
when: enable_binlog|default(false)
- name: TiKV cluster
hosts: tikv_servers
tasks:
- name: stop TiKV by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when: process_supervision == 'supervise'
with_items:
- tikv
- name: stop TiKV by systemd
systemd: name=tikv-{{ tikv_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the TiKV port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ tikv_port }}"
state: stopped
msg: "the TiKV port {{ tikv_port }} is not down"
- name: clean TiKV data
file: path={{ tikv_data_dir }} state=absent
- name: create new TiKV data dir
file: path={{ tikv_data_dir }} state=directory mode=0755
- name: clean TiKV wal data
file: path={{ wal_dir }} state=absent
when: wal_dir is defined
- name: create new TiKV wal data dir
file: path={{ wal_dir }} state=directory mode=0755
when: wal_dir is defined
- name: clean TiKV raftdb data
file: path={{ raftdb_path }} state=absent
when: raftdb_path is defined
- name: create new TiKV raftdb data dir
file: path={{ raftdb_path }} state=directory mode=0755
when: raftdb_path is defined
- name: PD cluster
hosts: pd_servers
tasks:
- name: stop PD by supervise
shell: cd {{ deploy_dir }}/scripts && ./stop_{{ item }}.sh
when: process_supervision == 'supervise'
with_items:
- pd
- name: stop PD by systemd
systemd: name=pd-{{ pd_client_port }}.service state=stopped
become: true
when: process_supervision == 'systemd'
- name: wait until the PD port is down
wait_for:
host: "{{ ansible_host }}"
port: "{{ pd_client_port }}"
state: stopped
msg: "the PD port {{ pd_client_port }} is not down"
- name: clean PD data
file: path={{ pd_data_dir }} state=absent
- name: create new PD data dir
file: path={{ pd_data_dir }} state=directory mode=0755