系统配置:
auto_increment_increment
autocommit
auto_increment_offset
hostname
max_execution_time
....
集群配置:
存储到各个节点配置文件上,需要重启才生效
normal-concurrency
index-limit
...
high-concurrency
...
client-urls
...
系统配置
集群配置
set @@global.tidb_distsql_scan_concurrency=10;
set global tidb_distsql_scan_concurrency=10;
set tidb_distsql_scan_concurrency=10;
set SESSION tidb_distsql_scan_concurrency=10;
集群参数都是全局的,修改后需要reload并重启集群
tiup cluster edit-config ${cluster-name}
tidb_servers:
- host: 10.0.1.11
port: 4000
config:
log.slow-threshold: 300
tiup cluster reload ${cluster-name} [-N <nodes>] [-R <roles>]
可以通过SQL语句 show config 来直接查看集群所有实例的配置信息
show config
show config like 'tikv'
show config where name = 'raftstore.capacity';
session 级别参数的修改只影响当前会话,对于其他会话是不受影响的
[root@tidb ~]# mysql --host 192.168.16.12 --port 4000 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 407
Server version: 5.7.25-TiDB-v6.1.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test;
Database changed
mysql> create table t1( a int not null primary key auto_increment);
Query OK, 0 rows affected (0.14 sec)
mysql> show variables like 'auto_increment_increment';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 1 |
+--------------------------+-------+
1 row in set (0.00 sec)
mysql> insert into t1 values();
Query OK, 1 row affected (0.03 sec)
mysql> insert into t1 values();
Query OK, 1 row affected (0.01 sec)
mysql> select * from t1;
+---+
| a |
+---+
| 1 |
| 2 |
+---+
2 rows in set (0.00 sec)
mysql> set auto_increment_increment=10;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into t1 values();
Query OK, 1 row affected (0.01 sec)
mysql> insert into t1 values();
Query OK, 1 row affected (0.01 sec)
mysql> select * from t1;
+----+
| a |
+----+
| 1 |
| 2 |
| 11 |
| 21 |
+----+
4 rows in set (0.00 sec)
另外一个会话,打开其他终端
session 级别参数的修改只影响当前会话,对于其他会话是不受影响的
[root@tidb ~]# mysql --host 192.168.16.12 --port 4000 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 409
Server version: 5.7.25-TiDB-v6.1.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show variables like 'auto_increment_increment';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 1 |
+--------------------------+-------+
1 row in set (0.08 sec)
mysql> insert into t1 values();
Query OK, 1 row affected (0.01 sec)
mysql> insert into t1 values();
Query OK, 1 row affected (0.01 sec)
mysql> select * from t1;
+----+
| a |
+----+
| 1 |
| 2 |
| 11 |
| 21 |
| 22 |
| 23 |
+----+
6 rows in set (0.00 sec)
global 全局修改,并不会影响当前会话的配置
mysql> set global auto_increment_increment=10;
Query OK, 0 rows affected (0.06 sec)
mysql> show variables like 'auto_increment_increment';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 1 |
+--------------------------+-------+
1 row in set (0.00 sec)
global的参数修改,会影响新的连接会话
[root@tidb ~]# mysql --host 192.168.16.12 --port 4000 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 413
Server version: 5.7.25-TiDB-v6.1.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show variables like 'auto_increment_increment';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 10 |
+--------------------------+-------+
1 row in set (0.00 sec)
,global全局参数修改是会持久化的,所以数据库重启后这个参数也是修改后的
使用tiup config 和tiup reload 修改所有TiKV节点的配置,配置参数名为log-level,默认值是info,将其修改为warning。
1、进入TiKV -Server,打开配置文件,通常位置在/tidb-deploy/tikv-port/conf。
注意: 这里只是查看,不是在这修改
sed -n '/log/p' tikv.toml
log-level= "info"
2、编辑配置文件,修改变量
tiup cluster edit-config tidb-test
注意:使用方法跟vi 是一样的
3、加载参数,使其生效
tiup cluster reload 。 这一步会重启所有TiKV节点。
tiup cluster relod tidb-test
4、再次查看
sed -n '/log/p' tikv.toml
log-level= "warning"