## モジュール 5: TiKV設定ファイルパラメータの変更

### 手順 1. `TiKV サーバー 1` で `tikv.toml` ファイルの内容を表示します

- [ターミナル 1](ssh://monitor1-ssh#1) で、次のコマンドを実行します。

  ```bash
  ssh -i ~/.ssh/pe-class-key-${LAB:REGION_NAME}.pem ec2-user@${HOST_KV1_PRIVATE_IP} vi /tidb-deploy/tikv-20160/conf/tikv.toml
  ```

  ```output
  # WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten!
  # You can use 'tiup cluster edit-config' and 'tiup cluster reload' to update the configuration
  # All configuration items you want to change can be added to:
  # server_configs:
  #   tikv:
  #     aa.b1.c3: value
  #     aa.b2.c4: value
  ...
  ```

- `vi`エディタで、`ESC`キーを押してから`:q!`と入力し、ターミナルに戻ります。

### 手順 2. `Control Machine` で `TiKV server` の `log.level` を変更する

+ [ターミナル 1](ssh://monitor1-ssh#1)で、エディタを起動する`tiup cluster edit-config`コマンドを使用します。その後、`TiKV server`の`log.level`を`warn`に変更します。`ESC`キーを押した後、`:wq`と入力してターミナルに戻ります。

  ```bash
  tiup cluster edit-config tidb-test
  ```

  ```output
  ...
  server_configs:
  tidb: {}
  tikv:
     log.level: warn
  pd:
     replication.location-labels:
     - region
     - zone
     - storage-performance
     replication.max-replicas: 3
  tidb_dashboard: {}
  tiflash: {}
  tiproxy: {}
  tiflash-learner: {}
  pump: {}
  drainer: {}
  ```

### 手順 3. `TiDB クラスタ`のリロード

+ [ターミナル 1](ssh://monitor1-ssh#1)で、`tiup cluster reload`コマンドを使用して設定を更新します。この段階では全ての`TiKVサーバー`が再起動されます。

  ```bash
  tiup cluster reload tidb-test
  ```

  ```output
  Will reload the cluster tidb-test with restart policy is true, nodes: , roles: .
  Do you want to continue? [y/N]:(default=N) y
  + [ Serial ] - SSHKeySet: privateKey=/home/ec2-user/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa, publicKey=/home/ec2-user/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa.pub
  + [Parallel] - UserSSH: user=ec2-user, host=10.90.2.99
  + [Parallel] - UserSSH: user=ec2-user, host=10.90.2.92
  ...
  Reloaded cluster `tidb-test` successfully
  ```

### 手順 4. `TiKV サーバー 1`で、再度 `tikv.toml` の内容を確認します

+ `TiKV サーバー 1`上で、テキストエディタを使用して`tikv.toml`ファイルの内容を再度確認し、`log.level = "warn"`であることを確認します。エディタを終了するには、`:q!`と入力します。

  ```bash
  ssh -i ~/.ssh/pe-class-key-${LAB:REGION_NAME}.pem ec2-user@${HOST_KV1_PRIVATE_IP} vi -m /tidb-deploy/tikv-20160/conf/tikv.toml
  ```

  ```output
  # WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten!
  # You can use 'tiup cluster edit-config' and 'tiup cluster reload' to update the configuration
  # All configuration items you want to change can be added to:
  # server_configs:
  #   tikv:
  #     aa.b1.c3: value
  #     aa.b2.c4: value
  [log]
  level = "warn"
  ...
  ```

### 手順 5. `Control Machine` で、`log.level` の値をデフォルトに戻します

+ `Control Machine`で、エディタを起動する`tiup cluster edit-config`コマンドを使用します。`TiKV server`の`log.level`を`warn`からデフォルトに変更します。`ESC`キーを押して、`:wq`と入力してターミナルに戻ります。

  ```bash
  tiup cluster edit-config tidb-test
  ```

  ```output
  ...
  server_configs:
  tidb: {}
  tikv: {}
  pd:
     replication.location-labels:
     - region
     - zone
     - storage-performance
     replication.max-replicas: 3
  tidb_dashboard: {}
  tiflash: {}
  tiproxy: {}
  tiflash-learner: {}
  pump: {}
  drainer: {}
  ```

### 手順 6. TiDB クラスタの再読み込み

  ```bash
  tiup cluster reload tidb-test
  ```

  ```output
  Will reload the cluster tidb-test with restart policy is true, nodes: , roles: .
  Do you want to continue? [y/N]:(default=N) y
  + [ Serial ] - SSHKeySet: privateKey=/home/ec2-user/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa, publicKey=/home/ec2-user/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa.pub
  + [Parallel] - UserSSH: user=ec2-user, host=10.90.2.99
  + [Parallel] - UserSSH: user=ec2-user, host=10.90.2.191
  ...
  Reloaded cluster `tidb-test` successfully
  ```

### 手順 7. `TiKV サーバー 1` で、`tikv.toml` の内容を再度確認します

+ `TiKV server 1`で、テキストエディタを使用して`tikv.toml`ファイルの内容を再度確認し、`log.level`がデフォルトに戻っていることを確認します。`:q!`と入力してエディタを終了します。

  ```bash
  ssh -i ~/.ssh/pe-class-key-${LAB:REGION_NAME}.pem ec2-user@${HOST_KV1_PRIVATE_IP} vi -m /tidb-deploy/tikv-20160/conf/tikv.toml
  ```

  ```output
  # WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten!
  # You can use 'tiup cluster edit-config' and 'tiup cluster reload' to update the configuration
  # All configuration items you want to change can be added to:
  # server_configs:
  #   tikv:
  #     aa.b1.c3: value
  #     aa.b2.c4: value
  [server]
  [server.labels]
  region = "seattle"
  storage-performance = "high"
  zone = "az1"
  ...
  ```
