TiUPの一般的な操作
このドキュメントでは、TiUPを使用してTiDBクラスタを操作および保守する場合の次の一般的な操作について説明します。
- クラスタリストを表示する
 - クラスタを開始します
 - クラスタステータスを表示する
 - 構成を変更する
 - クラスタを停止します
 - クラスタを破壊する
 
クラスタリストを表示する
TiUPクラスタコンポーネントを使用して、複数のTiDBクラスターを管理できます。 TiDBクラスタがデプロイされると、クラスタはTiUPクラスタリストに表示されます。
リストを表示するには、次のコマンドを実行します。
tiup cluster list
クラスタを開始します
TiDBクラスタのコンポーネントは、次の順序で開始されます。
PD>TiKV>ポンプ>TiDB>TiFlash>ドレイナー>TiCDC>プロメテウス>Grafana>Alertmanager
クラスタを起動するには、次のコマンドを実行します。
tiup cluster start ${cluster-name}
ノート:
${cluster-name}をクラスタの名前に置き換えます。クラスタ名を忘れた場合は、tiup cluster listを実行して確認してください。
コマンドに-Rつまたは-Nのパラメーターを追加することにより、一部のコンポーネントのみを開始できます。例えば:
このコマンドは、PDコンポーネントのみを起動します。
tiup cluster start ${cluster-name} -R pdこのコマンドは、
1.2.3.4および1.2.3.5ホスト上のPDコンポーネントのみを開始します。tiup cluster start ${cluster-name} -N 1.2.3.4:2379,1.2.3.5:2379
ノート:
-Rつまたは-Nのパラメーターを使用して指定されたコンポーネントを開始する場合は、開始順序が正しいことを確認してください。たとえば、TiKVコンポーネントの前にPDコンポーネントを開始します。そうしないと、起動が失敗する可能性があります。
クラスタステータスを表示する
クラスタを起動した後、各コンポーネントのステータスをチェックして、正常に動作することを確認します。 TiUPはdisplayコマンドを提供するため、コンポーネントのステータスを表示するためにすべてのマシンにログインする必要はありません。
tiup cluster display ${cluster-name}
構成を変更する
クラスタが動作しているときに、コンポーネントのパラメータを変更する必要がある場合は、 edit-configコマンドを実行します。詳細な手順は次のとおりです。
クラスタの構成ファイルを編集モードで開きます。
tiup cluster edit-config ${cluster-name}パラメータを設定します。
構成がコンポーネントに対してグローバルに有効である場合は、
server_configsを編集します。server_configs: tidb: log.slow-threshold: 300構成が特定のノードで有効になる場合は、ノードの
configで構成を編集します。tidb_servers: - host: 10.0.1.11 port: 4000 config: log.slow-threshold: 300
パラメータの形式については、 TiUPパラメータテンプレートを参照してください。
を使用し
.構成アイテムの階層を表します。コンポーネントの構成パラメーターの詳細については、 TiDB
config.toml.example、およびTiKVconfig.toml.exampleを参照してPDconfig.toml.example。reloadコマンドを実行して、構成をローリング更新し、対応するコンポーネントを再起動します。tiup cluster reload ${cluster-name} [-N <nodes>] [-R <roles>]
例
tidb-serverでトランザクションサイズ制限パラメーター( パフォーマンスモジュールのtxn-total-size-limit )を1Gに設定する場合は、次のように構成を編集します。
server_configs:
  tidb:
    performance.txn-total-size-limit: 1073741824
次に、 tiup cluster reload ${cluster-name} -R tidbコマンドを実行して、TiDBコンポーネントをローリングリスタートします。
修正プログラムパッケージと交換してください
通常のアップグレードについては、 TiUPを使用してTiDBをアップグレードするを参照してください。ただし、デバッグなどの一部のシナリオでは、現在実行中のコンポーネントを一時パッケージに置き換える必要がある場合があります。これを実現するには、次のpatchのコマンドを使用します。
tiup cluster patch --help
Replace the remote package with a specified package and restart the service
Usage:
  cluster patch <cluster-name> <package-path> [flags]
Flags:
  -h, --help                   help for patch
  -N, --node strings           Specify the nodes
      --overwrite              Use this package in the future scale-out operations
  -R, --role strings           Specify the role
      --transfer-timeout int   Timeout in seconds when transferring PD and TiKV store leaders (default 300)
Global Flags:
      --native-ssh        Use the system's native SSH client
      --wait-timeout int  Timeout of waiting the operation
      --ssh-timeout int   Timeout in seconds to connect host via SSH, ignored for operations that don't need an SSH connection. (default 5)
  -y, --yes               Skip all confirmations and assumes 'yes'
TiDBホットフィックスパッケージが/tmp/tidb-hotfix.tar.gzに含まれていて、クラスタのすべてのTiDBパッケージを置き換える場合は、次のコマンドを実行します。
tiup cluster patch test-cluster /tmp/tidb-hotfix.tar.gz -R tidb
クラスタの1つのTiDBパッケージのみを置き換えることもできます。
tiup cluster patch test-cluster /tmp/tidb-hotfix.tar.gz -N 172.16.4.5:4000
クラスタの名前を変更します
クラスタをデプロイして開始した後、 tiup cluster renameコマンドを使用してクラスタの名前を変更できます。
tiup cluster rename ${cluster-name} ${new-name}
ノート:
- クラスタの名前を変更する操作により、監視システム(PrometheusおよびGrafana)が再起動します。
 - クラスタクラスタの一部のパネルがGrafanaに残る場合があります。手動で削除する必要があります。
 
クラスタを停止します
TiDBクラスタのコンポーネントは、次の順序で停止します(監視コンポーネントも停止します)。
Alertmanager> Grafana> Prometheus> TiCDC> Drainer> TiFlash> TiDB> Pump> TiKV> PD
クラスタを停止するには、次のコマンドを実行します。
tiup cluster stop ${cluster-name}
startコマンドと同様に、 stopコマンドは、 -Rまたは-N個のパラメーターを追加することにより、一部のコンポーネントの停止をサポートします。例えば:
このコマンドは、TiDBコンポーネントのみを停止します。
tiup cluster stop ${cluster-name} -R tidbこのコマンドは、
1.2.3.4および1.2.3.5ホスト上のTiDBコンポーネントのみを停止します。tiup cluster stop ${cluster-name} -N 1.2.3.4:4000,1.2.3.5:4000
クラスタデータをクリーンアップする
クラスタデータをクリーンアップする操作は、すべてのサービスを停止し、データディレクトリまたはログディレクトリ、あるいはその両方をクリーンアップします。操作を元に戻すことはできませんので、注意して進めてください。
クラスタのすべてのサービスのデータをクリーンアップしますが、ログは保持します。
tiup cluster clean ${cluster-name} --dataクラスタのすべてのサービスのログをクリーンアップしますが、データは保持します。
tiup cluster clean ${cluster-name} --logクラスタのすべてのサービスのデータとログをクリーンアップします。
tiup cluster clean ${cluster-name} --allPrometheusを除くすべてのサービスのログとデータをクリーンアップします。
tiup cluster clean ${cluster-name} --all --ignore-role prometheus172.16.13.11:9000つのインスタンスを除くすべてのサービスのログとデータをクリーンアップします。tiup cluster clean ${cluster-name} --all --ignore-node 172.16.13.11:9000172.16.13.12のノードを除くすべてのサービスのログとデータをクリーンアップします。tiup cluster clean ${cluster-name} --all --ignore-node 172.16.13.12
クラスタを破壊する
破棄操作はサービスを停止し、データディレクトリとデプロイメントディレクトリをクリアします。操作を元に戻すことはできませんので、注意して進めてください。
tiup cluster destroy ${cluster-name}