@@ -31,8 +31,6 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
31
31
32
32
1 . 执行如下命令安装 TiUP 工具:
33
33
34
- {{< copyable "shell-regular" >}}
35
-
36
34
``` shell
37
35
curl --proto ' =https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
38
36
```
@@ -41,41 +39,31 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
41
39
42
40
1. 重新声明全局环境变量:
43
41
44
- {{< copyable " shell-regular" > }}
45
-
46
42
` ` ` shell
47
43
source .bash_profile
48
44
` ` `
49
45
50
46
2. 确认 TiUP 工具是否安装:
51
47
52
- {{< copyable " shell-regular" > }}
53
-
54
48
` ` ` shell
55
49
which tiup
56
50
` ` `
57
51
58
- 3. 安装 TiUP cluster 组件:
59
-
60
- {{< copyable " shell-regular" > }}
52
+ 3. 安装 TiUP 集群组件:
61
53
62
54
` ` ` shell
63
55
tiup cluster
64
56
` ` `
65
57
66
- 4. 如果已经安装,则更新 TiUP cluster 组件至最新版本:
67
-
68
- {{< copyable " shell-regular" > }}
58
+ 4. 如果已经安装,则更新 TiUP 集群组件至最新版本:
69
59
70
60
` ` ` shell
71
61
tiup update --self && tiup update cluster
72
62
` ` `
73
63
74
64
预期输出 ` “Updated successfully! ”` 字样。
75
65
76
- 5. 验证当前 TiUP cluster 版本信息。执行如下命令查看 TiUP cluster 组件版本:
77
-
78
- {{< copyable " shell-regular" > }}
66
+ 5. 验证当前 TiUP 集群版本信息。执行如下命令查看 TiUP 集群组件版本:
79
67
80
68
` ` ` shell
81
69
tiup --binary cluster
@@ -95,24 +83,18 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
95
83
96
84
1. 执行如下命令安装 TiUP 工具:
97
85
98
- {{< copyable " shell-regular" > }}
99
-
100
86
` ` ` shell
101
87
curl --proto ' =https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
102
88
` ` `
103
89
104
90
2. 重新声明全局环境变量:
105
91
106
- {{< copyable " shell-regular" > }}
107
-
108
92
` ` ` shell
109
93
source .bash_profile
110
94
` ` `
111
95
112
96
3. 确认 TiUP 工具是否安装:
113
97
114
- {{< copyable " shell-regular" > }}
115
-
116
98
` ` ` shell
117
99
which tiup
118
100
` ` `
@@ -121,8 +103,6 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
121
103
122
104
1. 在一台和外网相通的机器上拉取需要的组件:
123
105
124
- {{< copyable " shell-regular" > }}
125
-
126
106
` ` ` bash
127
107
tiup mirror clone tidb-community-server-${version} -linux-amd64 ${version} --os=linux --arch=amd64
128
108
` ` `
@@ -131,8 +111,6 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
131
111
132
112
2. 通过 tar 命令将该组件包打包然后发送到隔离环境的中控机:
133
113
134
- {{< copyable " shell-regular" > }}
135
-
136
114
` ` ` bash
137
115
tar czvf tidb-community-server-${version} -linux-amd64.tar.gz tidb-community-server-${version} -linux-amd64
138
116
` ` `
@@ -145,8 +123,6 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
145
123
146
124
1. 在制作离线镜像时,可通过参数指定具体的组件和版本等信息,获得不完整的离线镜像。例如,要制作一个只包括 v1.12.3 版本 TiUP 和 TiUP Cluster 的离线镜像,可执行如下命令:
147
125
148
- {{< copyable " shell-regular" > }}
149
-
150
126
` ` ` bash
151
127
tiup mirror clone tiup-custom-mirror-v1.12.3 --tiup v1.12.3 --cluster v1.12.3
152
128
` ` `
@@ -157,8 +133,6 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
157
133
158
134
3. 在隔离环境的中控机上,查看当前使用的离线镜像路径。较新版本的 TiUP 可以直接通过命令获取当前的镜像地址:
159
135
160
- {{< copyable " shell-regular" > }}
161
-
162
136
` ` ` bash
163
137
tiup mirror show
164
138
` ` `
@@ -169,16 +143,12 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
169
143
170
144
首先将当前离线镜像中的 ` keys` 目录复制到 ` $HOME /.tiup` 目录中:
171
145
172
- {{< copyable " shell-regular" > }}
173
-
174
146
` ` ` bash
175
147
cp -r ${base_mirror} /keys $HOME /.tiup/
176
148
` ` `
177
149
178
150
然后使用 TiUP 命令将不完整的离线镜像合并到当前使用的镜像中:
179
151
180
- {{< copyable " shell-regular" > }}
181
-
182
152
` ` ` bash
183
153
tiup mirror merge tiup-custom-mirror-v1.12.3
184
154
` ` `
@@ -189,8 +159,6 @@ TiUP 还支持部署 TiDB、TiFlash、TiCDC 以及监控系统。本指南介绍
189
159
190
160
将离线包发送到目标集群的中控机后,执行以下命令安装 TiUP 组件:
191
161
192
- {{< copyable " shell-regular" > }}
193
-
194
162
` ` ` bash
195
163
tar xzvf tidb-community-server-${version} -linux-amd64.tar.gz && \
196
164
sh tidb-community-server-${version} -linux-amd64/local_install.sh && \
@@ -205,8 +173,6 @@ source /home/tidb/.bash_profile
205
173
206
174
执行以下命令合并离线组件到 server 目录下。
207
175
208
- {{< copyable " shell-regular" > }}
209
-
210
176
` ` ` bash
211
177
tar xf tidb-community-toolkit-${version} -linux-amd64.tar.gz
212
178
ls -ld tidb-community-server-${version} -linux-amd64 tidb-community-toolkit-${version} -linux-amd64
@@ -221,8 +187,6 @@ tiup mirror merge ../tidb-community-toolkit-${version}-linux-amd64
221
187
222
188
执行如下命令,生成集群初始化配置文件:
223
189
224
- {{< copyable " shell-regular" > }}
225
-
226
190
` ` ` shell
227
191
tiup cluster template > topology.yaml
228
192
` ` `
@@ -231,23 +195,17 @@ tiup cluster template > topology.yaml
231
195
232
196
- 混合部署场景:单台机器部署多个实例,详情参见[混合部署拓扑架构](/hybrid-deployment-topology.md)。
233
197
234
- {{< copyable " shell-regular" > }}
235
-
236
198
` ` ` shell
237
199
tiup cluster template --full > topology.yaml
238
200
` ` `
239
201
240
202
- 跨机房部署场景:跨机房部署 TiDB 集群,详情参见[跨机房部署拓扑架构](/geo-distributed-deployment-topology.md)。
241
203
242
- {{< copyable " shell-regular" > }}
243
-
244
204
` ` ` shell
245
205
tiup cluster template --multi-dc > topology.yaml
246
206
` ` `
247
207
248
- 执行 vi topology.yaml,查看配置文件的内容:
249
-
250
- {{< copyable " shell-regular" > }}
208
+ 执行 ` vi topology.yaml` ,查看配置文件的内容:
251
209
252
210
` ` ` shell
253
211
global:
@@ -276,7 +234,7 @@ alertmanager_servers:
276
234
- host: 10.0.1.4
277
235
` ` `
278
236
279
- 下表列出了常用的 7 种场景,请根据链接中的拓扑说明以及配置文件模板配置` topology.yaml` 。如果有其他组合场景的需求,请根据多个模板自行调整。
237
+ 下表列出了常用的 6 种场景,请根据链接中的拓扑说明以及配置文件模板配置 ` topology.yaml` 。如果有其他组合场景的需求,请根据多个模板自行调整。
280
238
281
239
| 场景 | 配置任务 | 配置文件模板 | 拓扑说明 |
282
240
| :-- | :-- | :-- | :-- |
@@ -290,11 +248,8 @@ alertmanager_servers:
290
248
> ** 注意:**
291
249
>
292
250
> - 对于需要全局生效的参数,请在配置文件中 ` server_configs` 的对应组件下配置。
293
- >
294
251
> - 对于需要某个节点生效的参数,请在具体节点的 ` config` 中配置。
295
- >
296
252
> - 配置的层次结构使用 ` .` 表示。如:` log.slow-threshold` 。更多格式参考 [TiUP 配置参数模版](https://github.com/pingcap/tiup/blob/master/embed/examples/cluster/topology.example.yaml)。
297
- >
298
253
> - 如果需要指定在目标机创建的用户组名,可以参考[这个例子](https://github.com/pingcap/tiup/blob/master/embed/examples/cluster/topology.example.yaml#L7)。
299
254
300
255
更多参数说明,请参考:
@@ -308,42 +263,35 @@ alertmanager_servers:
308
263
309
264
> ** 注意:**
310
265
>
311
- > 通过 TiUP 进行集群部署可以使用密钥或者交互密码方式来进行安全认证:
312
- >
313
- > - 如果是密钥方式,可以通过 -i 或者 --identity_file 来指定密钥的路径。
314
- >
315
- > - 如果是密码方式,可以通过 -p 进入密码交互窗口。
266
+ > 通过 TiUP 部署集群时用于初始化的用户(通过 ` --user` 指定),可以使用密钥或者交互密码的方式进行安全认证:
316
267
>
268
+ > - 如果使用密钥方式,可以通过 ` -i` 或者 ` --identity_file` 指定密钥的路径。
269
+ > - 如果使用密码方式,可以通过 ` -p` 进入密码交互窗口。
317
270
> - 如果已经配置免密登录目标机,则不需填写认证。
318
271
>
319
- > 一般情况下 TiUP 会在目标机器上创建 topology.yaml 中约定的用户和组,以下情况例外 :
272
+ > TiUP 用于实际执行相关进程的用户和组(通过 ` topology.yaml` 指定,默认值为 ` tidb ` ),一般情况下会在目标机器上自动创建,但以下情况例外 :
320
273
>
321
274
> - ` topology.yaml` 中设置的用户名在目标机器上已存在。
275
+ > - 在命令行上使用了参数 ` --skip-create-user` 明确指定跳过创建用户的步骤。
322
276
>
323
- > - 在命令行上使用了参数 --skip-create-user 明确指定跳过创建用户的步骤 。
277
+ > 无论 ` topology.yaml ` 中约定的用户和组是否被自动创建,TiUP 都会自动生成一对 ssh key,并为每台机器的该用户设置免密登录。在此后的操作中都会使用这个用户和 ssh key 去管理机器,而用于初始化的用户和密码在部属完成后不再被使用 。
324
278
325
279
执行部署命令前,先使用 ` check` 及 ` check --apply` 命令检查和自动修复集群存在的潜在风险:
326
280
327
281
1. 检查集群存在的潜在风险:
328
282
329
- {{< copyable " shell-regular" > }}
330
-
331
283
` ` ` shell
332
284
tiup cluster check ./topology.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]
333
285
` ` `
334
286
335
287
2. 自动修复集群存在的潜在风险:
336
288
337
- {{< copyable " shell-regular" > }}
338
-
339
289
` ` ` shell
340
290
tiup cluster check ./topology.yaml --apply --user root [-p] [-i /home/root/.ssh/gcp_rsa]
341
291
` ` `
342
292
343
293
3. 部署 TiDB 集群:
344
294
345
- {{< copyable " shell-regular" > }}
346
-
347
295
` ` ` shell
348
296
tiup cluster deploy tidb-test v8.5.0 ./topology.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]
349
297
` ` `
@@ -354,14 +302,12 @@ alertmanager_servers:
354
302
- ` v8.5.0` 为部署的集群版本,可以通过执行 ` tiup list tidb` 来查看 TiUP 支持的最新可用版本。
355
303
- 初始化配置文件为 ` topology.yaml` 。
356
304
- ` --user root` 表示通过 root 用户登录到目标主机完成集群部署,该用户需要有 ssh 到目标机器的权限,并且在目标机器有 sudo 权限。也可以用其他有 ssh 和 sudo 权限的用户完成部署。
357
- - [-i] 及 [-p] 为可选项,如果已经配置免密登录目标机,则不需填写。否则选择其一即可,[-i] 为可登录到目标机的 root 用户(或 --user 指定的其他用户)的私钥,也可使用 [-p] 交互式输入该用户的密码。
305
+ - [-i] 及 [-p] 为可选项,如果已经配置免密登录目标机,则不需填写。否则选择其一即可,[-i] 为可登录到目标机的 root 用户(或 ` --user` 指定的其他用户)的私钥,也可使用 [-p] 交互式输入该用户的密码。
358
306
359
307
预期日志结尾输出 ` ` ` Deployed cluster ` tidb-test` successfully` ` ` 关键词,表示部署成功。
360
308
361
309
# # 第 5 步:查看 TiUP 管理的集群情况
362
310
363
- {{< copyable " shell-regular" > }}
364
-
365
311
` ` ` shell
366
312
tiup cluster list
367
313
` ` `
@@ -372,8 +318,6 @@ TiUP 支持管理多个 TiDB 集群,该命令会输出当前通过 TiUP cluste
372
318
373
319
例如,执行如下命令检查 ` tidb-test` 集群情况:
374
320
375
- {{< copyable " shell-regular" > }}
376
-
377
321
` ` ` shell
378
322
tiup cluster display tidb-test
379
323
` ` `
@@ -389,21 +333,16 @@ tiup cluster display tidb-test
389
333
> ** 注意:**
390
334
>
391
335
> - 使用安全启动方式后,不能通过无密码的 root 用户登录数据库,你需要记录命令行返回的密码进行后续操作。
392
- >
393
336
> - 该自动生成的密码只会返回一次,如果没有记录或者忘记该密码,请参照[忘记 root 密码](/user-account-management.md#忘记-root-密码)修改密码。
394
337
395
338
方式一:安全启动
396
339
397
- {{< copyable " shell-regular" > }}
398
-
399
340
` ` ` shell
400
341
tiup cluster start tidb-test --init
401
342
` ` `
402
343
403
344
预期结果如下,表示启动成功。
404
345
405
- {{< copyable " shell-regular" > }}
406
-
407
346
` ` ` shell
408
347
Started cluster ` tidb-test` successfully.
409
348
The root password of TiDB database has been changed.
@@ -414,8 +353,6 @@ The generated password can NOT be got again in future.
414
353
415
354
方式二:普通启动
416
355
417
- {{< copyable " shell-regular" > }}
418
-
419
356
` ` ` shell
420
357
tiup cluster start tidb-test
421
358
` ` `
@@ -424,8 +361,6 @@ tiup cluster start tidb-test
424
361
425
362
# # 第 8 步:验证集群运行状态
426
363
427
- {{< copyable " shell-regular" > }}
428
-
429
364
` ` ` shell
430
365
tiup cluster display tidb-test
431
366
` ` `
0 commit comments