TiUP 简介

在各种系统软件和应用软件的安装管理中,包管理器均有着广泛的应用,包管理工具的出现大大简化了软件的安装和升级维护工作。例如,几乎所有使用 RPM 的 Linux 都会使用 Yum 来进行包管理,而 Anaconda 则可以非常方便地管理 python 的环境和相关软件包。

在早期的 TiDB 生态中,没有专门的包管理工具,使用者只能通过相应的配置文件和文件夹命名来手动管理,如 Prometheus 等第三方监控报表工具甚至需要额外的特殊管理,这样大大提升了运维管理难度。

从 TiDB 4.0 版本开始,TiUP 作为新的工具,承担着包管理器的角色,管理着 TiDB 生态下众多的组件,如 TiDB、PD、TiKV 等。用户想要运行 TiDB 生态中任何组件时,只需要执行 TiUP 一行命令即可,相比以前,极大地降低了管理难度。

安装 TiUP

TiUP 安装过程十分简洁,无论是 Darwin 还是 Linux 操作系统,执行一行命令即可安装成功:

curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

该命令将 TiUP 安装在 $HOME/.tiup 文件夹下,之后安装的组件以及组件运行产生的数据也会放在该文件夹下。同时,它还会自动将 $HOME/.tiup/bin 加入到 Shell Profile 文件的 PATH 环境变量中,这样你就可以直接使用 TiUP 了。

例如,你可以查看 TiUP 的版本:

tiup --version

TiUP 生态介绍

TiUP 的直接功能是作为 TiDB 生态中的包管理器,但这并不是它的最终使命。TiUP 的愿景是将 TiDB 生态中所有工具的使用门槛降到极致,这个仅仅靠包管理功能是做不到的,还需要引入一些额外的包来丰富这个系统,它们一起加入到 TiUP 生态中,让 TiDB 的世界变得更简单。

TiUP 系列文档的主要内容就是介绍 TiUP 及这些包的功能和使用方式。

在 TiUP 生态中,你可以通过在任何命令后加上 --help 的方式来获得帮助信息,比如通过以下命令获取 TiUP 本身的帮助信息:

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 [: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] [args...] tiup [flags] [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 help Help about any command or component Components Manifest: use "tiup list" to fetch the latest components manifest Flags: -B, --binary [:version] Print binary path of a specific version of a 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 version for 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 [: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 # 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.

输出的帮助信息较长,你可以只关注两部分:

  • 可用的命令
    • install:用于安装组件
    • list:查看可用组件列表
    • uninstall:卸载组件
    • update:更新组件版本
    • status:查看组件运行记录
    • clean:清除组件运行记录
    • mirror:从官方镜像克隆一个私有镜像
    • help:输出帮助信息
  • 可用的组件
    • playground:在本机启动集群
    • client:连接本机的集群
    • cluster:部署用于生产环境的集群
    • bench:对数据库进行压力测试

命令和组件的区别在于,命令是 TiUP 自带的,用于进行包管理的操作。而组件是 TiUP 通过包管理操作安装的独立组件包。比如执行 tiup list 命令,TiUP 会直接运行自己内部的代码,而执行 tiup playground 命令则会先检查本地有没有叫做 playground 的组件包,若没有则先从镜像上下载过来,然后运行这个组件包。

文档内容是否有帮助?

下载 PDF文档反馈社区交流
产品
TiDB
TiDB Cloud
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.