TiDB-TiUP使用

314 阅读2分钟

TiDB4.0生态中,TiUP作为包管理器,管理着TiDB下的不同组件,如TiDB,PD,TiKV等,可以快速下载和安装不同版本的组件。

安装tiup

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

查看tiup版本


tiup -version

tiup的其他使用

tiup --help

tiup查看可以安装的组件

tiup list 

查看组件对应的版本

tiup list tidb

查看已经安装的组件

tiup list --installed

tiup安装组件

安装最新版本的组件

tiup install tidb

安装对应版本的组件

tiup install tidb:v6.0.0

tiup 运行组件

tiup tidb:v6.0.0

指定tag运行组件,如果不指定tag,TiDB会随时生成一个tag,停止后会删除相关数据。指定后,再次启动可以指定--tag运作之前数据。

tiup --tag=tidbflag tidb:v6.0.0

查看TiDB运行状态

tiup status

清理TiDB组件

清理tag为tidbtag的组件,如果组件在运行中,会先kill掉,然后清理相关数据文件

tiup clean tidbtag

清理所有组件

tiup clean --all

卸载组件

卸载tidb:v6.0.0

tiup uninstall tidb:v6.0.0

卸载所有版本的tikv

tiup uninstall tikv --all

卸载所有已安装的组件

tiup uninstall --all

playground本地集群

  • 查看playground版本
tiup list playground
  • 安装playground
tiup install playground
  • 使用playground启动
tiup playground

默认会使用最新版本进行启动,如最新版本是v1.19.3,则相当于运行tiup playground:v1.19.3

如果没指定各个组件的版本,会使用最新的版本,如tidb,tikv等的最新版本是v6.0.0,则相当于运行tiup playground:v1.19.3 v6.0.0

如果没指定组件的个数,会启动1个TiDB,1个TiKV和1个PD构成最小集群

  • 指定tag来启动
tiup --tag=playtag playground
  • 启动对应集群
tiup playground v6.0.0
  • 指定组件个数,指定TiKV的个数为3
tiup playground --kv=3 --monitor
  • 使用对外的IP提供服务
tiup playground --host xx.xx.xx.xx

本地测试集群

tiup playground --db=2 --kv=3 --pd=3 --monitor

  • 使用client连接
tiup client
  • 连接指定tag的集群
tiup client tagtest