Tidb 運維--叢集檢視的使用
登入 Tidb
登入任意 Tidb S erver 節點。
mysql -h192.168.0.1 -P4000 -uroot -p 'xxxx' -A
不登入僅執行 SQL
mysql -h192.168.0.1 -P4000 -uroot -p 'xxxxx' -A information_schema -e ‘select * from cluster_processlist where info is not null\G’ > /tmp/a
直接登入某資料庫
mysql -h192.168.0.1 -P4000 -uroot -p 'xxxxx' -A INFORMATION_SCHEMA
登入後檢視有哪些資料庫:
MySQL [(none)]> show databases; +-----------------------------------+ | Database +-----------------------------------+ | INFORMATION_SCHEMA | METRICS_SCHEMA | PERFORMANCE_SCHEMA | mysql | test +-----------------------------------+ 7 rows in set (0.00 sec)
Tidb cluster 檢視
檢視 |
作用 |
SQL |
CLUSTER_PROCESSLIST |
查詢會話資訊 |
1 )實時 TOP SQL 執行次數、平均時間維度 2 )實時 TOP 10 SQL 按執行時間排序 3 )實時按照 ID 殺程式 |
CLUSTER_SLOW_QUERY |
查詢慢 SQL |
1 )查詢慢 SQL Text 2 )查詢慢 SQL 平均時間執行次 |
CLUSTER_STATEMENTS_SUMMARY |
近 3 0 分鐘 TOP SQL |
1 )查詢近 3 0 分鐘 TOP SQL |
CLUSTER_STATEMENTS_SUMMARY_HISTORY |
3 0 分鐘後持久話 TOP SQL |
目前發現持久化並未按照理想情況持久,需要再觀察一下。 |
CLUSTER_LOAD |
查詢負載資訊 |
- |
CLUSTER_HARDWARE |
查詢硬體資訊 |
- |
CLUSTER_CONFIG |
查詢叢集配置資訊 |
- |
CLUSTER_LOG |
查詢叢集日誌資訊 |
- |
CLUSTER_SYSTEMINFO |
查詢系統新系統配置資訊 |
- |
CLUSTER_PROCESSLIST
cluster_processlist 檢視類似於 gv$session 用於檢視會話資訊
TOP SQL 執行次數平均時間維度
select substr(INFO,1,100) sql_text,avg(TIME),count(*) cc from cluster_processlist where info!=‘NULL’ group by substr(INFO,1,100) order by count(*);
TOP 10 SQL 按執行 SQL 平均時間排序
select current_time; select * from ( select ID,INSTANCE,INFO,max(TIME) max_time from cluster_processlist where INFO like ‘update%’ group by INSTANCE,ID,INFO order by max(TIME) desc ) a limit 10;
按照 ID 殺程式
MySQL [nlc]> show processlist -> ; +--------+------+----------------+--------------------+---------+-------+-------+------------------------------------------------------------------------------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +--------+------+----------------+--------------------+---------+-------+-------+------------------------------------------------------------------------------------------------------+ | 428968 | root | 10.116.119.143 | information_schema | Query | 110 | 2 | SELECT Digest, Conn_ID, (UNIX_TIMESTAMP(Time) + 0E0) AS timestamp, Query, Query_time, Me | | 438151 | nlc | 10.116.128.76 | nlc | Sleep | 851 | 2 | NULL | 437697 | nlc | 10.116.128.76 | nlc | Execute | 0 | 2 | select a.tot_nav, a.cfm_date, a.nav from tbprddaily a where a.prd_code = ? and a.cfm_date <= ? and | +--------+------+----------------+--------------------+---------+-------+-------+------------------------------------------------------------------------------------------------------+ ...... ... MySQL [nlc]> kill tidb 428968; Query OK, 0 rows affected (0.00 sec)
select TIME e_time,INSTANCE,’ :--kill tidb ‘ || ID |;| FROM cluster_processlist where INFO like ‘update%’ order by e_time desc;
CLUSTER_SLOW_QUERY
Dash board 中慢查詢出處
查詢慢 SQL Text
格式化後 SQL:
SELECT Query ,count(*) ,round(avg(Query_time), 1) etime FROM CLUSTER_SLOW_QUERY WHERE TIME > ‘2022-03-07 09:00:00.647448’ AND TIME < ‘2022-03-07 09:30:00.647448’ AND Query LIKE ‘update%tbprddailychg %force index (index1) set%’ GROUP BY Query ORDER BY Query ,count(*);
查詢慢
SQL平均時間執行次
SELECT date_format(TIME, ‘%Y-%m-%d %H:%i’) AS stime ,round(avg(Query_time), 1) etime ,count(*) cc FROM INFORMATION_SCHEMA.CLUSTER_SLOW_QUERY WHERE TIME > ‘2022-03-07 09:00:00.647448’ AND TIME < ‘2022-03-07 09:30:00.647448’ AND Query LIKE ‘update tbprddailychg force index (index1) set net_red_vol = net_red_vol where trans_date = cast(2022%’ GROUP BY date_format(TIME, ‘%Y-%m-%d %H:%i’) ORDER BY stime;
+------------------+-------+-----+ | stime | etime | cc | +------------------+-------+-----+ | 2022-03-07 09:00 | 5.2 | 76 | | 2022-03-07 09:01 | 17.3 | 108 | | 2022-03-07 09:02 | 27.0 | 113 | | 2022-03-07 09:03 | 40.4 | 99 | | 2022-03-07 09:04 | 41.7 | 92 | | 2022-03-07 09:05 | 38.9 | 127 | | 2022-03-07 09:06 | 37.1 | 130 | | 2022-03-07 09:07 | 36.8 | 109 | | 2022-03-07 09:08 | 35.4 | 105 | | 2022-03-07 09:09 | 37.9 | 117 | | 2022-03-07 09:10 | 33.6 | 103 | | 2022-03-07 09:11 | 37.8 | 123 | | 2022-03-07 09:12 | 34.9 | 111 | | 2022-03-07 09:13 | 29.9 | 116 | | 2022-03-07 09:14 | 31.2 | 105 | | 2022-03-07 09:15 | 32.2 | 117 | | 2022-03-07 09:16 | 33.6 | 83 | | 2022-03-07 09:17 | 41.2 | 75 | | 2022-03-07 09:18 | 37.2 | 74 | | 2022-03-07 09:19 | 32.0 | 53 | | 2022-03-07 09:20 | 27.7 | 50 | | 2022-03-07 09:21 | 25.7 | 65 | | 2022-03-07 09:22 | 28.1 | 47 | | 2022-03-07 09:23 | 28.3 | 40 | | 2022-03-07 09:24 | 18.7 | 50 | | 2022-03-07 09:25 | 18.5 | 52 | | 2022-03-07 09:26 | 25.9 | 52 | | 2022-03-07 09:27 | 28.6 | 55 | | 2022-03-07 09:28 | 22.4 | 53 | | 2022-03-07 09:29 | 23.8 | 59 | +------------------+-------+-----+ 30 rows in set (1.40 sec)
CLUSTER_STATEMENTS_SUMMARY 檢視 T OP SQL 使用
statements_summary 是 information_schema 裡的一張系統表,它把 SQL 按 SQL digest 和 plan digest 分組,統計每一組的 SQL 資訊。
此處的 SQL digest 與 slow log 裡的 SQL digest 一樣,是把 SQL 規一化後算出的唯一識別符號。 SQL 的規一化會忽略常量、空白符、大小寫的差別。即語法一致的 SQL 語句,其 digest 也相同。
D ashboard TOP S QL 的出處。
SELECT DIGEST ,DIGEST_TEXT ,AVG_LATENCY e_time_avg ,EXEC_COUNT exec_count ,QUERY_SAMPLE_TEXT ,SUMMARY_BEGIN_TIME ,SUMMARY_END_TIME ,FIRST_SEEN ,LAST_SEEN ,QUERY_SAMPLE_TEXT ,PLAN_DIGEST FROM CLUSTER_STATEMENTS_SUMMARY WHERE SUMMARY_BEGIN_TIME >= ‘2022-02-22 09:30:00’ AND SUMMARY_END_TIME <= ‘2022-02-22 10:00:00’ AND QUERY_SAMPLE_TEXT LIKE ‘select * from tbclientadd1&’ \G
CLUSTER_STATEMENTS_SUMMARY_HISTORY 檢視 T OP SQL 使用
持久化 CLUSTER_STATEMENTS_SUMMARY 表上內容,當 T OP 會話超過 3 0 分鐘後,會持久化到 CLUSTER_STATEMENTS_SUMMARY_HISTORY 。
D ashboard TOP S QL 的出處。
SELECT DIGEST ,DIGEST_TEXT ,AVG_LATENCY e_time_avg ,EXEC_COUNT exec_count ,QUERY_SAMPLE_TEXT ,SUMMARY_BEGIN_TIME ,SUMMARY_END_TIME ,FIRST_SEEN ,LAST_SEEN ,QUERY_SAMPLE_TEXT ,PLAN_DIGEST FROM CLUSTER_STATEMENTS_SUMMARY_HISTORY WHERE SUMMARY_BEGIN_TIME >= ‘2022-02-22 09:30:00’ AND SUMMARY_END_TIME <= ‘2022-02-22 10:00:00’ AND QUERY_SAMPLE_TEXT LIKE ‘select * from tbclientadd1&’ \G
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26474945/viewspace-2889765/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MongoDB叢集運維筆記MongoDB運維筆記
- RabbitMQ叢集運維實踐MQ運維
- redis哨兵,叢集和運維Redis運維
- mongos分片叢集管理和運維Go運維
- 400+節點的 Elasticsearch 叢集運維Elasticsearch運維
- 400+ 節點的 Elasticsearch 叢集運維Elasticsearch運維
- ElasticSearch 叢集的規劃部署與運維Elasticsearch運維
- 如何檢視Oracle RAC叢集的叢集名稱(CLUSTER NAME)Oracle
- Elasticsearch叢集運維相關知識Elasticsearch運維
- HACMP的叢集檢視後臺程式命令ACM
- 運維利器-ClusterShell叢集管理操作記錄運維
- docker筆記41-ceph叢集的日常運維Docker筆記運維
- MySQL 5.5 NDB叢集檢視日誌MySql
- 使用開源元件構建自動運維Kafka叢集 - Slack元件運維Kafka
- 如何運維多叢集資料庫?58 同城 NebulaGraph Database 運維實踐運維資料庫Database
- oracle cluster叢集相關日誌檢視Oracle
- OracleRAC管理 之 叢集狀態&資訊檢視Oracle
- 叢集資料庫重要檔案的檢視管理資料庫
- 阿里雲註冊叢集+Prometheus 解決多雲容器叢集運維痛點阿里Prometheus運維
- Oracle RAC日常運維-NetworkManager導致叢集故障Oracle運維
- 阿里超大規模 Flink 叢集運維實踐阿里運維
- 小知識:使用oracle使用者檢視RAC叢集資源狀態Oracle
- Docker叢集管理工具 - Kubernetes 使用手冊 (運維小結)Docker運維
- 轉OracleRAC管理 之 叢集狀態&資訊檢視Oracle
- 轉 OracleRAC管理 之 叢集狀態&資訊檢視Oracle
- 【TUNE_ORACLE】檢視索引的叢集因子SQL參考Oracle索引SQL
- rabbitmq 原理、叢集、基本運維操作、常見故障處理MQ運維
- 運維之我的docker-compose快速建立zookeeper叢集薦運維Docker
- tidb之dm叢集同步異常處理TiDB
- 檢視Redis叢集所有節點記憶體工具Redis記憶體
- 阿里超大規模 Flink 叢集運維體系介紹阿里運維
- 檢視當前windows使用的字符集Windows
- PB 級大規模 Elasticsearch 叢集運維與調優實踐Elasticsearch運維
- web叢集都有哪些學習知識?Linux運維技術WebLinux運維
- 【IT運維小知識】如何通俗理解節點、叢集以及主從?運維
- rac叢集日常維護命令
- hbase叢集 常用維護命令
- 雷神 Thor —— TiDB 自動化運維平臺TiDB運維