## Module 5: Modifying TiKV Configuration File Parameters

### Step 1. On `TiKV server 1`, view the contents of the `tikv.toml` file

- In [Terminal 1](ssh://monitor1-ssh#1), execute the following command.

  ```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
  ...
  ```

- In `vi` editor, press the `ESC` and type `:q!` to quit to the terminal.

### Step 2. On `Control Machine`, change `log.level` for `TiKV server`

+ In [Terminal 1](ssh://monitor1-ssh#1), use the `tiup cluster edit-config` command that starts an editor. Then, change the `log.level` to `warn` for `TiKV server`. Press the `ESC` and type `:wq` to quit to the terminal:

  ```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: {}
  ```

### Step 3. Reloading the `TiDB Cluster`

+ In [Terminal 1](ssh://monitor1-ssh#1), use the `tiup cluster reload` command to update the configuration. This step will restart all `TiKV server`.

  ```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
  ```

### Step 4. On `TiKV server 1`, view the contents of the `tikv.toml` again

+ On `TiKV server 1`, use a text editor to view the contents of the `tikv.toml` file again, and verify that `log.level = "warn"`. Type `:q!` to quit the editor.

  ```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"
  ...
  ```

### Step 5. On `Control Machine`, restore the value of `log.level` to default

+ On `Control Machine`, use the `tiup cluster edit-config` command that starts an editor. Change the `log.level` from `warn` to default for `TiKV server`. Press the `ESC` and type `:wq` to quit to the terminal:

  ```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: {}
  ```

### Step 6. Reloading the `TiDB Cluster`

  ```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
  ```

### Step 7. On `TiKV server 1`, view the contents of the `tikv.toml` again

+ On `TiKV server 1`, use a text editor to view the contents of the `tikv.toml` file again, and verify that `log.level` is back to default. Type `:q!` to quit the editor.

  ```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"
  ...
  ```
