课程名称:2.3.1 How to Deploy TiDB Platform with TiUP(如何通过 TiUP 部署 TiDB)
学习时长:
120min
课程收获:
了解 TiUP 组件管理方式和集群管理方式
掌握 TiUP 部署本地测试环境
掌握 TiUP cluster 部署生产环境集群
课程内容:
本课程简要介绍了 TiUP 的设计目标,组件管理方式,以及如何使用 TiUP 管理 TiDB 集群。在各种系统软件和应用软件的安装管理中,包管理器均有着广泛的应用,包管理工具的出现大大简化了软件的安装和升级维护工作。在早期的 TiDB 生态中,没有专门的包管理工具,使用者只能通过相应的配置文件和文件夹命名来手动管理。从 TiDB 4.0 版本开始,TiUP 作为新的工具,承担着包管理器的角色,管理着 TiDB 生态下众多的组件,用户想要运行 TiDB 生态中任何组件时,只需要执行 TiUP 一行命令即可,相比以前,极大地降低了管理难度。
操作实践
思维导图
安装TiUP
[ec2-user@ip-172-31-14-99 ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 (Maipo)
# 安装TiUP
[root@ip-172-31-14-99 ~]# curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4412k 100 4412k 0 0 8027k 0 --:--:-- --:--:-- --:--:-- 8022k
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /root/.tiup/bin/7b8e153f2e2d0928.root.json
Set mirror to https://tiup-mirrors.pingcap.com success
Detected shell: bash
Shell profile: /root/.bash_profile
/root/.bash_profile has been modified to to add tiup to PATH
open a new terminal or source /root/.bash_profile to use it
Installed path: /root/.tiup/bin/tiup
===============================================
Have a try: tiup playground
===============================================
[root@ip-172-31-14-99 ~]# source /root/.bash_profile
# 查看版本
[root@ip-172-31-14-99 ~]# tiup --version
v1.0.8 tiup
Go Version: go1.13
Git Branch: master
GitHash: 4276089
# 查看帮助
[root@ip-172-31-14-99 ~]$ tiup help
TiUP is a command-line component management tool that can help to download and install
TiDB platform components to the local system. You can run a specific version of a component via
"tiup <component>[:version]". If no version number is specified, the latest version installed
locally will be used. If the specified component does not have any version installed locally,
the latest stable version will be downloaded from the repository.
Usage:
tiup [flags] <command> [args...]
tiup [flags] <component> [args...]
Available Commands:
install Install a specific version of a component
list List the available TiDB components or versions
uninstall Uninstall components or versions of a component
update Update tiup components to the latest version
status List the status of instantiated components
clean Clean the data of instantiated components
mirror Manage a repository mirror for TiUP components
telemetry Controls things about telemetry
help Help about any command or component
Components Manifest:
use "tiup list" to fetch the latest components manifest
Flags:
-B, --binary <component>[:version] Print binary path of a specific version of a component <component>[:version]
and the latest version installed will be selected if no version specified
--binpath string Specify the binary path of component instance
-h, --help help for tiup
--skip-version-check Skip the strict version check, by default a version must be a valid SemVer string
-T, --tag string Specify a tag for component instance
-v, --version Print the version of tiup
Component instances with the same "tag" will share a data directory ($TIUP_HOME/data/$tag):
$ tiup --tag mycluster playground
Examples:
$ tiup playground # Quick start
$ tiup playground nightly # Start a playground with the latest nightly version
$ tiup install <component>[:version] # Install a component of specific version
$ tiup update --all # Update all installed components to the latest version
$ tiup update --nightly # Update all installed components to the nightly version
$ tiup update --self # Update the "tiup" to the latest version
$ tiup list # Fetch the latest supported components list
$ tiup status # Display all running/terminated instances
$ tiup clean <name> # Clean the data of running/terminated instance (Kill process if it's running)
$ tiup clean --all # Clean the data of all running/terminated instances
Use "tiup [command] --help" for more information about a command.
TiUP部署本地测试环境-111
# 通过 list 命令先查看 playground 提供了哪些版本
[root@ip-172-31-14-99 ~]# tiup list playground
Available versions for playground:
Version Installed Release Platforms
------- --------- ------- ---------
v0.0.1 2020-02-27T10:10:10+08:00 darwin/amd64,linux/amd64
v0.0.2 2020-03-03T19:39:35+08:00 darwin/amd64,linux/amd64
v0.0.3 2020-03-03T19:39:35+08:00 darwin/amd64,linux/amd64
v0.0.4 2020-03-03T19:39:35+08:00 darwin/amd64,linux/amd64
v0.0.5 2020-03-03T19:39:35+08:00 darwin/amd64,linux/amd64
v0.0.6 2020-04-03T16:21:57+08:00 darwin/amd64,linux/amd64
v0.0.7 2020-04-16T10:37:27+08:00 darwin/amd64,linux/amd64
v0.0.8 2020-04-17T15:58:08+08:00 darwin/amd64,linux/amd64
v0.0.9 2020-04-17T17:45:49+08:00 darwin/amd64,linux/amd64
v1.0.0 2020-05-28T18:19:00+08:00 darwin/amd64,linux/amd64
v1.0.1 2020-06-02T00:24:24+08:00 darwin/amd64,linux/amd64
v1.0.2 2020-06-04T20:23:55+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.0.3 2020-06-05T20:09:57+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.0.4 2020-06-09T21:19:32+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.0.5 2020-06-18T15:02:33+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.0.6 2020-06-21T19:02:35+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.0.7 2020-06-24T22:07:54+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.0.8 2020-07-13T18:39:38+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.0.9 2020-08-03T20:16:56+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.1.0 2020-08-28T18:42:07+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.1.1 2020-09-01T21:35:33+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.1.2 2020-09-11T20:40:56+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.2.0 2020-09-29T17:33:05+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.2.1 2020-10-23T18:25:49+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.2.3 2020-10-30T19:18:08+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.2.4 2020-11-19T21:10:00+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.2.5 2020-11-27T18:10:44+08:00 darwin/amd64,linux/amd64,linux/arm64
v1.3.0 2020-12-18T19:06:29+08:00 darwin/amd64,linux/amd64,linux/arm64
# 安装最新版本的 playground
[root@ip-172-31-14-99 ~]$ tiup install playground
download https://tiup-mirrors.pingcap.com/playground-v1.3.0-linux-amd64.tar.gz 254.48 KiB / 8.49 MiB 2.93% ? pdownload https://tiup-mirrors.pingcap.com/playground-v1.3.0-linux-amd64.tar.gz 2.21 MiB / 8.49 MiB 26.00% ? p/download https://tiup-mirrors.pingcap.com/playground-v1.3.0-linux-amd64.tar.gz 8.49 MiB / 8.49 MiB 100.00% 27.19 MiB p/s
# 启动一个默认的集群
[root@ip-172-31-14-99 ~]$ tiup playground
Starting component `playground`:
Use the latest stable version: v4.0.8
Specify version manually: tiup playground <version>
The stable version: tiup playground v4.0.0
The nightly version: tiup playground nightly
Playground Bootstrapping...
...
TiUP部署测试Cluster-233
tiup install cluster
tiup cluster deploy prod-cluster v3.0.12 /tmp/topology.yaml
tiup cluster list
tiup cluster start prod-cluster
iup cluster display prod-cluster
tiup cluster scale-in prod-cluster -N 172.16.5.140:20160
tiup cluster scale-out prod-cluster /tmp/scale.yaml
tiup cluster upgrade prod-cluster v4.0.0-rc
tiup cluster edit-config prod-cluster
tiup cluster reload prod-cluster