# Online Modify of TiDB Cluster Parameters

__*Online modify of TiDB cluster configuration*__
__*Online modify of TiDB cluster parameters*__

+ Online modify of TiKV configuration
  + Modify the entire TiKV instance configuration:
    + `set config tikv `split.qps-threshold`=1000`
 
  + To modify the configuration of a single TiKV instance:
    + `set config "127.0.0.1:20180" `split.qps-threshold`=1000`
  
+ Online modify of PD configuration
  + `set config pd `log.level`='info'`

-------------------------------------------------------------
Note: When you modify the TiKV configuration item online, the configuration file of TiKV will be automatically modify at the same time. However, you also need to use the tiup edit-config command to modify the corresponding configuration item. Otherwise, O&M operation and administer such as upgrade and reload will overwrite the results after modify the configuration online. To modify the configuration, please refer to modify the Configuration Using TiUP. You do not need to perform a tiup reload operation after executing tiup edit-config.

Execute the SQL statement set config to modify a single instance configuration or all instance configurations in combination with the instance address or component type, such as:

    Modify the entire TiKV instance configuration:
    (Note: It is recommended to wrap variable names in backticks.)
    set config tikv `split.qps-threshold`=1000

    To modify the configuration of a single TiKV instance:
    set config "127.0.0. 1:20180" `split.qps-threshold`=1000

If the setting is successful, Query OK will be return:
Query OK, 0 rows affected (0.01 sec)

If an error occurs during batch modify, it will be return as a warning:
set config tikv `log-level`='warn';
Query OK, 0 rows affected, 1 warning (0.04 sec)
show warnings;
+—+—+—+
| Level | Code | Message |
+—+—+—+
| Warning | 1105 | bad request to http://127.0.0.1:20180/config: fail to update, error: "config log-level can not be changed" |
+—+—+—+
1 row in set (0.00 sec)

batch configuration modify does not guarantee atomicity, and some instances may succeed and some fail. If you use the set tikv key=val command to modify the entire TiKV cluster configuration, some instances may fail. Execute show warnings to check.

If a part of the modify fails, you need to re-execute the corresponding modify statement, or complete the modification by modifying a single instance. If TiKV cannot be accessed due to network or machine failure, etc., it is necessary to wait until it is recover and then modify again.

configuration item that can be modify online for TiKV, if successfully modify, will be persisted in the configuration file, and the configuration in the configuration file will prevail. Some configuration item names may conflict with TiDB reserved keyword, such as limit, key, etc. For such configuration item, you need to use the backquote ` 包裹起来，如 `raftstore.raft-log-gc-size-limit`.

Online modify of PD configuration

PD does not support individual configurations for a single instance at this time. All instances share a single configuration. You can modify PD configuration item in the following ways:
set config pd `log.level`='info'

If the setting is successful, Query OK will be return:
Query OK, 0 rows affected (0.01 sec)

configuration item that can be modify online for PD will persist in etcd after successful modify. The configuration file will not be persisted. The configuration in etcd will prevail. Same as above, backticks ` 包裹此类配置项，例如 `schedule.leader-schedule-limit` are required if there is a conflict with the TiDB reserved keyword.

For a list of supported configuration item, please refer to: https://docs.pingcap.com/zh/tidb/stable/dynamic-config