GreatDB SqlNode参数调整 ?示例,SqlNode 所有节点调整 max_connections 参数值
[root@greatdb1 ~]
GreatDB Cluster[(none)]> select * from information_schema.greatdb_SqlNode_variables where variable_name='max_connections';
+
| SQLNODE | VARIABLE_NAME | VARIABLE_VALUE |
+
| 192.168.0.81:3306 | max_connections | 2000 |
| 192.168.0.82:3306 | max_connections | 2000 |
| 192.168.0.83:3306 | max_connections | 2000 |
+
3 rows in set (0.14 sec)
GreatDB Cluster[(none)]> CALL mysql.greatdb_set_var_for_all_SqlNodes('max_connections',1000,true);
Query OK, 1 row affected (0.04 sec)
GreatDB Cluster[(none)]> select * from information_schema.greatdb_SqlNode_variables where variable_name='max_connections';
+
| SQLNODE | VARIABLE_NAME | VARIABLE_VALUE |
+
| 192.168.0.81:3306 | max_connections | 1000 |
| 192.168.0.82:3306 | max_connections | 1000 |
| 192.168.0.83:3306 | max_connections | 1000 |
+
3 rows in set (0.14 sec)
GreatDB DataNode参数调整 ?示例,调整节点datanode1的 max_connections 参数值 `[root@greatdb1 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306
GreatDB Cluster[(none)]> select * from information_schema.greatdb_DataNode_variables where variable_name=‘max_connections’; ±----------±----------------±------+ | DATANODE | VARIABLE_NAME | VALUE | ±----------±----------------±------+ | datanode1 | max_connections | 3000 | | datanode2 | max_connections | 3000 | | datanode3 | max_connections | 3000 | | datanode4 | max_connections | 3000 | | datanode5 | max_connections | 3000 | | datanode6 | max_connections | 3000 | | datanode7 | max_connections | 3000 | | datanode8 | max_connections | 3000 | | datanode9 | max_connections | 3000 | ±----------±----------------±------+ 9 rows in set (0.40 sec)
GreatDB Cluster[(none)]> call mysql.greatdb_set_var_for_DataNode(‘datanode1’,‘max_connections’,2000,0); Query OK, 1 row affected (0.03 sec)
GreatDB Cluster[(none)]> select * from information_schema.greatdb_DataNode_variables where variable_name=‘max_connections’; ±----------±----------------±------+ | DATANODE | VARIABLE_NAME | VALUE | ±----------±----------------±------+ | datanode1 | max_connections | 2000 | | datanode2 | max_connections | 3000 | | datanode3 | max_connections | 3000 | | datanode4 | max_connections | 3000 | | datanode5 | max_connections | 3000 | | datanode6 | max_connections | 3000 | | datanode7 | max_connections | 3000 | | datanode8 | max_connections | 3000 | | datanode9 | max_connections | 3000 | ±----------±----------------±------+ 9 rows in set (0.14 sec)
[root@greatdb1 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P4406 GreatDB Cluster[(none)]> show variables like ‘max_connections’; ±----------------±------+ | Variable_name | Value | ±----------------±------+ | max_connections | 2000 | ±----------------±------+ 1 row in set (0.00 sec)` GreatDB 参数调整的传统方式 ?如果需要的调整的参数不在 SqlNode 和 DataNode “可调整的参数列表”中,可以分别连接到每个 SqlNode 节点或每个 DataNode 节点进行修改。 ?例如 SESSION 级别调整 long_query_time 参数
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 0.300000 |
+
1 row in set (0.01 sec)
GreatDB Cluster[(none)]> set session long_query_time=3;
Query OK, 0 rows affected (0.00 sec)
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 3.000000 |
+
1 row in set (0.01 sec)
GreatDB Cluster[(none)]> select @@session.long_query_time;
+
| @@session.long_query_time |
+
| 3.000000 |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> select @@global.long_query_time;
+
| @@global.long_query_time |
+
| 0.300000 |
+
1 row in set (0.00 sec)
SESSION 级别调整的参数只在当前会话中生效,其他会话或其他新连接的会话均不生效。 ?例如 GLOBAL 级别调整 long_query_time 参数
[root@greatdb1 ~]
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 0.300000 |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> set global long_query_time=3;
Query OK, 0 rows affected (0.00 sec)
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 0.300000 |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> select @@session.long_query_time;
+
| @@session.long_query_time |
+
| 0.300000 |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> select @@global.long_query_time;
+
| @@global.long_query_time |
+
| 3.000000 |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> exit
Bye
[root@greatdb1 ~]
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 3.000000 |
+
1 row in set (0.00 sec)
[root@greatdb1 ~]
[root@greatdb1 ~]
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 0.300000 |
+
1 row in set (0.01 sec)
GLOBAL 级别调整的参数在当前会话中不生效,在其他已连接的会话中也不生效,只在新连接中生效,但是实例重启后不会生效。 ?使用 persist 选项修改参数会将配置信息加载到配置文件中,下次重启实例会自动读取配置文件使参数生效
[root@greatdb1 ~]
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 0.300000 |
+
1 row in set (0.01 sec)
GreatDB Cluster[(none)]> set persist long_query_time=3;
Query OK, 0 rows affected (0.00 sec)
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 0.300000 |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> exit
Bye
[root@greatdb1 ~]
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 3.000000 |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> exit
Bye
[root@greatdb1 ~]
[root@greatdb1 ~]
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 3.000000 |
+
1 row in set (0.01 sec)
persist 就相当于 GLOBAL 级别的调整加配置持久化,重启实例后依然生效。 ?传统方式修改参数需要分别连接到每个 SqlNode 节点或每个 DataNode 节点进行修改
[root@greatdb2 ~]
GreatDB Cluster[(none)]> show variables like 'long_query_time';
+
| Variable_name | Value |
+
| long_query_time | 0.300000 |
+
1 row in set (0.01 sec)
这里可以看到,SQLNODE 192.168.0.81 修改的参数,SQLNODE 192.168.0.82 并不会自动同步。
GreatDB 常用参数列表
GreatDB 状态属性说明 状态属性 说明 greatdb_cluster_initialized 标识 SqlNode 上是否已经初始化 GreatDB cluster greatdb_cluster_name 当前集群的名称 greatdb_cluster_user 集群各节点间创建连接使用的用户名 greatdb_read_only_mode 当为 true 时表示集群当前处于只读模式
[root@greatdb1 ~]
GreatDB Cluster[(none)]> show status like 'greatdb_cluster_initialized';
+
| Variable_name | Value |
+
| greatdb_cluster_initialized | ON |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> show status like 'greatdb_cluster_name';
+
| Variable_name | Value |
+
| greatdb_cluster_name | greatdb_cluster |
+
1 row in set (0.01 sec)
GreatDB Cluster[(none)]> show status like 'greatdb_cluster_user';
+
| Variable_name | Value |
+
| greatdb_cluster_user | greatdb |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> show status like 'greatdb_read_only_mode';
+
| Variable_name | Value |
+
| greatdb_read_only_mode | OFF |
+
1 row in set (0.00 sec)
GreatDB 获取集群信息
GreatDB Cluster[(none)]> show status like 'greatdb_cluster_initialized';
+
| Variable_name | Value |
+
| greatdb_cluster_initialized | ON |
+
1 row in set (0.00 sec)
GreatDB Cluster[(none)]> \s
greatsql Ver 8.0.25-15-greatdbcluster5.0.7-GA for Linux on x86_64 (GreatDB Cluster, Release GA, Revision fbb08fbed60)
Connection id: 38Current database:Current user: greatdb@192.168.0.81
SSL: Cipher in use is ECDHE-RSA-AES128-GCM-SHA256Current pager: stdoutUsing outfile: ''Using delimiter: ;
Server version: 8.0.25-15-greatdbcluster5.0.7-GA GreatDB Cluster, Release GA, Revision fbb08fbed60
Protocol version: 10Connection: 192.168.0.81 via TCP/IPServer characterset: utf8mb4
Db characterset: utf8mb4Client characterset: utf8mb4
Conn. characterset: utf8mb4
TCP port: 3306Binary data as: Hexadecimal
Uptime: 36 min 40 sec
Threads: 14 Questions: 1362 Slow queries: 0 Opens: 207 Flush tables: 3 Open tables: 115 Queries per second avg: 0.619
GreatDB 日常节点巡检视图 视图名称 说明 GREATDB_SHARDS 集群中的 Shard 及其状态 GREATDB_TABLE_DISTRIBUTION 表类型、在后端 Shard 的分布情况以及后端表引擎类型 GREATDB_SQLNODES 集群中的 SqlNode 及其状态 GREATDB_DCSTATS 当前 SqlNode 中字典缓存使用情况 GREATDB_SQLNODE_STATUS 各个 SqlNode 部分 status 的值 GREATDB_SQLNODE_VARIABLES 各个 SqlNode 部分 variables 的值 GREATDB_DATANODES 集群中的 DataNode 及其状态 GREATDB_DATANODE_STATUS 各个 DataNode 部分 status 属性值 GREATDB_DATANODE_VARIABLES 各个 DataNode 部分 variables 的值 GREATDB_CONNECTION_POOL SqlNode 到 DataNode 连接池状态
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_SHARDS;
+
| SHARD_ID | SHARD_NAME | SHARD_STATE | SUSPEND |
+
| 36 | shard1 | SHARD_ONLINE | OFF |
| 64 | shard2 | SHARD_ONLINE | OFF |
| 92 | shard3 | SHARD_ONLINE | OFF |
+
3 rows in set (0.00 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_TABLE_DISTRIBUTION;
+
| SCHEMA_NAME | TABLE_NAME | BACKEND_ENGINE | DISTRIBUTE_MODE | SHARD_NAME | PARTITION_NAME | PARTITION_ID |
+
| test | t_normal | InnoDB | NORMAL | shard1 | | 0 |
| test | t_global | InnoDB | GLOBAL | shard1 | | 0 |
| test | t_global | InnoDB | GLOBAL | shard2 | | 0 |
| test | t_global | InnoDB | GLOBAL | shard3 | | 0 |
| test | t_hash | InnoDB | PARTITION | shard1 | p0 | 0 |
| test | t_hash | InnoDB | PARTITION | shard2 | p1 | 1 |
| test | t_hash | InnoDB | PARTITION | shard3 | p2 | 2 |
| test | t_hash | InnoDB | PARTITION | shard2 | p3 | 3 |
| test | t_hash | InnoDB | PARTITION | shard1 | p4 | 4 |
| test | t_hash | InnoDB | PARTITION | shard2 | p5 | 5 |
| test | t_hash | InnoDB | PARTITION | shard3 | p6 | 6 |
| test | t_hash | InnoDB | PARTITION | shard2 | p7 | 7 |
| test | t_range | InnoDB | PARTITION | shard1 | p0 | 0 |
| test | t_range | InnoDB | PARTITION | shard2 | p1 | 1 |
| test | t_range | InnoDB | PARTITION | shard3 | p4 | 2 |
| test | t_list | InnoDB | PARTITION | shard1 | beijing | 0 |
| test | t_list | InnoDB | PARTITION | shard2 | shanghai | 1 |
+
17 rows in set (0.01 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_SQLNODES;
+
| UUID | HOST | PORT | STATUS | EXECUTED_GTID | Received_transaction_set |
+
| 588107ec-77d0-11eb-95a1-000c290f05e6 | 192.168.0.82 | 3306 | ONLINE | | |
| 58d09346-77d0-11eb-815f-000c293f8a6a | 192.168.0.83 | 3306 | ONLINE | | |
| 5aa2cd7d-77d0-11eb-a8ff-000c29d936e4 | 192.168.0.81 | 3306 | ONLINE | | |
+
3 rows in set (0.02 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_DCSTATS;
+
| CACHE_NAME | CACHE_SIZE | CACHE_INSTANCE_NO | CACHED_ELEMENTS | LRU_ELEMENTS |
+
| SQLNODE | 0 | 1 | 3 | 0 |
| SHARD | 0 | 1 | 3 | 0 |
| DATANODE | 0 | 1 | 9 | 0 |
| TABLE | 20480 | 8 | 0 | 0 |
+
4 rows in set (0.00 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_SQLNODE_STATUS where VARIABLE_NAME='greatdb_cluster_initialized';
+
| SQLNODE | VARIABLE_NAME | VARIABLE_VALUE |
+
| 192.168.0.81:3306 | greatdb_cluster_initialized | ON |
| 192.168.0.82:3306 | greatdb_cluster_initialized | ON |
| 192.168.0.83:3306 | greatdb_cluster_initialized | ON |
+
3 rows in set (0.03 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_SQLNODE_VARIABLES where VARIABLE_NAME='long_query_time';
+
| SQLNODE | VARIABLE_NAME | VARIABLE_VALUE |
+
| 192.168.0.81:3306 | long_query_time | 3.000000 |
| 192.168.0.82:3306 | long_query_time | 3.000000 |
| 192.168.0.83:3306 | long_query_time | 0.300000 |
+
3 rows in set (0.06 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_DATANODES;
+
| NODE_ID | NODE_NAME | SHARD_ID | SHARD_NAME | HOST | PORT | NODE_TYPE | NODE_STATE | EXECUTED_GTID | RECEIVED_TRANSACTION_SET |
+
| 36 | datanode1 | 36 | shard1 | 192.168.0.81 | 4406 | NODE_MGR | STATE_STANDBY | 33360000-0000-0000-0000-000000000000:1-13:1000011-1000021 | 33360000-0000-0000-0000-000000000000:1-13:1000011-1000021 |
| 43 | datanode2 | 36 | shard1 | 192.168.0.82 | 4406 | NODE_MGR | STATE_ACTIVE | 33360000-0000-0000-0000-000000000000:1-13:1000011-1000021 | 33360000-0000-0000-0000-000000000000:1-13:1000011-1000021 |
| 50 | datanode3 | 36 | shard1 | 192.168.0.83 | 4406 | NODE_MGR | STATE_STANDBY | 33360000-0000-0000-0000-000000000000:1-13:1000011-1000021 | 33360000-0000-0000-0000-000000000000:1-13:1000011-1000021 |
| 64 | datanode4 | 64 | shard2 | 192.168.0.81 | 4407 | NODE_MGR | STATE_ACTIVE | 36340000-0000-0000-0000-000000000000:1-28 | 36340000-0000-0000-0000-000000000000:1-28 |
| 71 | datanode5 | 64 | shard2 | 192.168.0.82 | 4407 | NODE_MGR | STATE_STANDBY | 36340000-0000-0000-0000-000000000000:1-28 | 36340000-0000-0000-0000-000000000000:1-28 |
| 78 | datanode6 | 64 | shard2 | 192.168.0.83 | 4407 | NODE_MGR | STATE_STANDBY | 36340000-0000-0000-0000-000000000000:1-28 | 36340000-0000-0000-0000-000000000000:1-28 |
| 92 | datanode7 | 92 | shard3 | 192.168.0.81 | 4408 | NODE_MGR | STATE_ACTIVE | 39320000-0000-0000-0000-000000000000:1-14 | 39320000-0000-0000-0000-000000000000:1-14 |
| 99 | datanode8 | 92 | shard3 | 192.168.0.82 | 4408 | NODE_MGR | STATE_STANDBY | 39320000-0000-0000-0000-000000000000:1-14 | 39320000-0000-0000-0000-000000000000:1-14 |
| 106 | datanode9 | 92 | shard3 | 192.168.0.83 | 4408 | NODE_MGR | STATE_STANDBY | 39320000-0000-0000-0000-000000000000:1-14 | 39320000-0000-0000-0000-000000000000:1-14 |
+
9 rows in set (0.01 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_DATANODE_STATUS where VARIABLE_NAME='Open_tables';
+
| DATANODE | VARIABLE_NAME | VALUE |
+
| datanode1 | Open_tables | 144 |
| datanode2 | Open_tables | 268 |
| datanode3 | Open_tables | 189 |
| datanode4 | Open_tables | 320 |
| datanode5 | Open_tables | 125 |
| datanode6 | Open_tables | 177 |
| datanode7 | Open_tables | 245 |
| datanode8 | Open_tables | 170 |
| datanode9 | Open_tables | 126 |
+
9 rows in set (0.20 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_DATANODE_VARIABLES where VARIABLE_NAME='long_query_time';
+
| DATANODE | VARIABLE_NAME | VALUE |
+
| datanode1 | long_query_time | 0.300000 |
| datanode2 | long_query_time | 0.300000 |
| datanode3 | long_query_time | 0.300000 |
| datanode4 | long_query_time | 0.300000 |
| datanode5 | long_query_time | 0.300000 |
| datanode6 | long_query_time | 0.300000 |
| datanode7 | long_query_time | 0.300000 |
| datanode8 | long_query_time | 0.300000 |
| datanode9 | long_query_time | 0.300000 |
+
9 rows in set (0.17 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_CONNECTION_POOL;
+
| NODE_NAME | TOTAL | IDLE |
+
| datanode1 | 101 | 100 |
| datanode2 | 101 | 100 |
| datanode3 | 101 | 100 |
| datanode4 | 101 | 100 |
| datanode5 | 101 | 100 |
| datanode6 | 101 | 100 |
| datanode7 | 101 | 100 |
| datanode8 | 101 | 100 |
| datanode9 | 101 | 100 |
+
9 rows in set (0.00 sec)
GreatDB 日志任务巡检视图 视图名称 说明 GREATDB_ALTER_TABLE_TASK 集群中 alter table 任务概览,含各阶段处理情况 GREATDB_ALTER_TABLE_SUBTASK 集群中 alter table 子任务及当前阶段进度 GREATDB_BACKUP_NODES 集群中用于备份的节点及其状态 GREATDB_BACKUP_TASKS 备份任务 GREATDB_BACKUP_TASK_ROUTINE 备份任务拓扑路由,各个增量备份依赖的层次及依赖的全量备份 GREATDB_TASK 集群中后台任务(alter,migrate,backup) GREATDB_BINLOG_SERVER_STATUS binlog server 同步数据的任务状态显示 GREATDB_MIGRATE_TABLE_TASK 集群中 migrate table 任务概览,含各阶段处理情况 GREATDB_MIGRATE_TABLE_SUBTASK migrate table 子任务及当前阶段进度
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_TASK;
+
| TASK_ID | TASK_TYPE | INFO | STATUS | OWNER_INSTANCE_HOST | OWNER_INSTANCE_PORT |
+
| 1 | SHARD_RECOVER | shard recover daemon task | RUNNING | 192.168.0.81 | 3306 |
| 43 | MIGRATE_TABLE | test.t_normal from shard2 to shard1 | COMPLETE | 192.168.0.81 | 3306 |
+
2 rows in set (0.01 sec)
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_MIGRATE_TABLE_TASK;
+
| TASK_ID | OBJECT_NAME | INFO | MIGRATE_STATUS | STAGE_SEQUENCE | STAGE | COMPLETED_SUBTASK_NUM | UNKNOWN_SUBTASK_NUM | SUBTASK_NUM |
+
| 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 1 | CREATE TABLE | 1 | 0 | 1 |
| 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 2 | COPY REMOTE DATA | 1 | 0 | 1 |
| 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 3 | APPLY_REMOTE_LOG | 1 | 0 | 1 |
| 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 4 | CATCH_REMOTE_LOG | 1 | 0 | 1 |
| 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 5 | CHANGE_TOPOLOGY | 1 | 0 | 1 |
+
GreatDB Cluster[(none)]> select * from information_schema.GREATDB_MIGRATE_TABLE_SUBTASK;
+
| TASK_ID | SUB_TASK_ID | OBJECT_NAME | FROM_SHARD_NAME | TO_SHARD_NAME | BACKEND_TABLE_NAME | STAGE | PROGRESS | ERROR |
+
| 43 | 1 | test.t_normal | shard2 | shard1 | `test`.`t_normal` | COMPLETE | 100% | |
+
1 row in set (0.01 sec)
|