TiUPのインストール

実際の運用環境で利用するインストール方法である。

TiUPとは

  • TiUPは、TiDB 4.0で導入されたクラスタ運用保守ツールである。
  • TiUPは、Golangで書かれたクラスタ管理コンポーネントであるTiUP Clusterを提供する。
  • TiUP Clusterを使用すると、TiDBクラスタのデプロイ、開始、停止、削除、スケーリング、アップグレードを含む日常的なデータベース作業を簡単に実行し、TiDBクラスタのパラメータを管理できる。

Linux環境でのTiUPインストール

1. TiUPツールをダウンロードしてインストールする

まず、オンライン環境で次のコマンドを実行し、TiUPをダウンロードしてインストールする。

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

次のような「Successfully」メッセージが表示されれば、TiUPは正常にインストールされている。

[kimkc@localhost ~]$ 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 7085k  100 7085k    0     0  3326k      0  0:00:02  0:00:02 --:--:-- 3328k
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /home/kimkc/.tiup/bin/7b8e153f2e2d0928.root.json
Successfully set mirror to https://tiup-mirrors.pingcap.com
Detected shell: bash
Shell profile:  /home/kimkc/.bash_profile
/home/kimkc/.bash_profile has been modified to add tiup to PATH
open a new terminal or source /home/kimkc/.bash_profile to use it
Installed path: /home/kimkc/.tiup/bin/tiup
===============================================
Have a try:     tiup playground
===============================================
[kimkc@localhost ~]$

上の出力に表示されたインストール済みシェルプロファイルのパスを覚えておこう。次の手順でこのパスを使用する。

Installed path: /home/kimkc/.tiup/bin/tiup

2. 変更された環境変数を反映する

インストール後、次のようにhomeディレクトリを確認すると、.pki.tiupディレクトリが作成されていることが分かる。

[kimkc@localhost ~]$ ls -al
total 16
drwx------. 4 kimkc kimkc 108 Oct 31 11:08 .
drwxr-xr-x. 3 root  root   19 Oct 31  2022 ..
-rw-------. 1 kimkc kimkc 282 Oct 31 10:51 .bash_history
-rw-r--r--. 1 kimkc kimkc  18 Mar 31  2020 .bash_logout
-rw-r--r--. 1 kimkc kimkc 234 Oct 31 11:08 .bash_profile
-rw-r--r--. 1 kimkc kimkc 231 Mar 31  2020 .bashrc
drwxrw----. 3 kimkc kimkc  19 Oct 31 11:07 .pki
drwxrwxr-x. 3 kimkc kimkc  34 Oct 31 11:08 .tiup
[kimkc@localhost ~]$

そして、シェルプロファイルファイルである.bash_profileを確認すると、次の部分に.tiup/binパスがPATHへ登録されていることが分かる。

[kimkc@localhost ~]$ cat .bash_profile
# .bash_profile

# ... 中略 ...

export PATH=/home/kimkc/.tiup/bin:$PATH

この変更された環境変数をsourceコマンドで反映する。

$ source .bash_profile

macOS環境でのTiUPインストール

1. TiUPツールをダウンロードしてインストールする

まず、オンライン環境で次のコマンドを実行し、TiUPをダウンロードしてインストールする。

curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
% 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 6988k  100 6988k    0     0  3433k      0  0:00:02  0:00:02 --:--:-- 3442k
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /Users/user/.tiup/bin/7b8e153f2e2d0928.root.json
Successfully set mirror to https://tiup-mirrors.pingcap.com
Detected shell: zsh
Shell profile:  /Users/user/.zshrc
/Users/user/.zshrc has been modified to add tiup to PATH
open a new terminal or source /Users/user/.zshrc to use it
Installed path: /Users/user/.tiup/bin/tiup
===============================================
Have a try:     tiup playground
===============================================

2. グローバル環境変数を再宣言する

インストール後、TiUPは該当するシェルプロファイルファイルの絶対パスを表示する。パスに応じて、次のsourceコマンドの${your_shell_profile}を変更する必要がある。この場合、手順1の出力で${your_shell_profile}/Users/user/.zshrcである。

source ${your_shell_profile}
% source .zshrc

3. TiUPがインストールされているか確認する

which tiup
% which tiup
/Users/user/.tiup/bin/tiup
  1. グローバル環境変数を宣言する。