首页 > 数据库 > > GreatDB参数调整与系统视图(3)

[root@greatdb1 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306 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)

[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,); 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 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 级别调整的参数只在当前会话中生效,其他会话或其他新连接的会话均不生效。
[root@greatdb1 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306 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 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306 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 ~]# /greatdb/sh/sqlnode3306.sh restart [root@greatdb1 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306 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 级别调整的参数在当前会话中不生效,在其他已连接的会话中也不生效,只在新连接中生效,但是实例重启后不会生效。
[root@greatdb1 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306 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 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306 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 ~]# /greatdb/sh/sqlnode3306.sh restart [root@greatdb1 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306 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 级别的调整加配置持久化,重启实例后依然生效。
[root@greatdb2 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.82 -P3306 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 并不会自动同步。


[root@greatdb1 ~]# greatsql -ugreatdb -pgreatdb -h192.168.0.81 -P3306 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 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: 38 Current database: Current user: greatdb@192.168.0.81 SSL: Cipher in use is ECDHE-RSA-AES128-GCM-SHA256 Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.25-15-greatdbcluster5.0.7-GA GreatDB Cluster, Release GA, Revision fbb08fbed60 Protocol version: 10 Connection: 192.168.0.81 via TCP/IP Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 TCP port: 3306 Binary data as: Hexadecimal Uptime: 36 min 40 sec Threads: 14 Questions: 1362 Slow queries: Opens: 207 Flush tables: 3 Open tables: 115 Queries per second avg: 0.619 --------------
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 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 | | 1 | | 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 2 | COPY REMOTE DATA | 1 | | 1 | | 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 3 | APPLY_REMOTE_LOG | 1 | | 1 | | 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 4 | CATCH_REMOTE_LOG | 1 | | 1 | | 43 | test.t_normal | test.t_normal from shard2 to shard1 | COMPLETE | 5 | CHANGE_TOPOLOGY | 1 | | 1 | +---------+---------------+-------------------------------------+----------------+----------------+------------------+-----------------------+---------------------+-------------+ 5 rows in set (0.00 sec) 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)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69946831/viewspace-3152436/ ,如需转载,请注明出处,否则将追究法律责任。