文章目录
-
- [12. 状态检查](#12. 状态检查)
- [13. 订阅监控](#13. 订阅监控)
- [14. leader 分布](#14. leader 分布)
- [15. 查询读写流量QPS](#15. 查询读写流量QPS)
- [16. 查看表分布](#16. 查看表分布)
- [17. 调整vnode分布](#17. 调整vnode分布)
- [18. 查看占用磁盘空间](#18. 查看占用磁盘空间)
- [19. Adapter Websocket 连接数](#19. Adapter Websocket 连接数)
- [20. Adapter Restful 连接数](#20. Adapter Restful 连接数)
- [21. Adapter 内存使用](#21. Adapter 内存使用)
- [22. 查询进程下线程数量](#22. 查询进程下线程数量)
TDengine3.0 DBA常用的运维命令和SQL1
12. 状态检查
select * from information_schema.ins_mnodes where status !='ready';
select * from information_schema.ins_dnodes where status !='ready';
select * from information_schema.ins_vnodes where status not in ('leader','follower') or restored = 'false';
select dnode_id,vgroup_id,db_name,status,role_time,restored,unapplied from information_schema.ins_vnodes order by role_time desc limit 10;
select dnode_id,vgroup_id,db_name,status,role_time,restored,unapplied from information_schema.ins_vnodes order by unapplied desc limit 10;
select dnode_id,vgroup_id,db_name,status,role_time,restored,unapplied from information_schema.ins_vnodes where restored='false' limit 10;
13. 订阅监控
## 查询是否有消费记录为0的consumer_id
select count(*) as off_count from (select substring_index(`offset`,'/',-1) as off_num,consumer_id from information_schema.ins_subscriptions where consumer_id is not null ) where off_num=0;
### 查询消费差异
select * from (select topic_name,vgroup_id,consumer_group,consumer_id,cast(substring_index(`offset`,'/',-1)-substring_index(substring_index(`offset`,'/',1),':',-1) as int) as la
g from information_schema.ins_subscriptions where consumer_id is not null) where lag >0 order by topic_name,consumer_group,consumer_id,vgroup_id;
14. leader 分布
select count(*),dnode_id from information_schema.ins_vnodes where status='leader' and db_name='test' group by dnode_id order by dnode_id;
15. 查询读写流量QPS
select _wstart,cast(sum(`query_success`)/5/60 as int) as qps_q, cast(sum(`write_success`)/5/60 as int) as qps_w from log.adapter_requests where _c0>now-1h interval(5m);
select _wstart as ts,cast(sum(wt)/600 as int) as wps from (select _c0 as ts,diff(taos_stmt2_exec_success) as wt,endpoint from log.adapter_c_interface where _c0>now-1h partition by endpoint) interval(10m);
select _wstart,sql_type,cast(sum(`count`)/600 as int) as qps from log.taosd_sql_req where _c0>now-1h partition by sql_type interval(10m);
select _wstart,sql_type,cast(sum(`count`)/600 as int) as qps from log.taos_sql_req where _c0>now-1h partition by sql_type interval(10m);
select * from (select _wstart,sum(`count`) as csum,sql_type,username from taos_sql_req where _c0>now-2h and sql_type='select' partition by sql_type, username interval(10m) ) where csum>0;
16. 查看表分布
select count(*),vgroup_id from information_schema.ins_tables where stable_name='meters' and db_name='test' group by vgroup_id;
select vgroup_id,dnode_id from information_schema.ins_vnodes where status='leader' and db_name='test';
17. 调整vnode分布
REDISTRIBUTE VGROUP vgroup_no DNODE dnode_id1 [DNODE dnode_id2] [DNODE dnode_id3];
18. 查看占用磁盘空间
select * from INFORMATION_SCHEMA.INS_DISK_USAGE where db_name = 'db_name';
show db_name.disk_info;
19. Adapter Websocket 连接数
select _wstart,max(ws_ws_conn),endpoint from log.adapter_status where _c0>now-1h partition by endpoint interval(5m) order by endpoint,_wstart;
20. Adapter Restful 连接数
select _wstart,max(conn_pool_total) as total,max(conn_pool_in_use) as in_use,endpoint from log.adapter_conn_pool where _c0>now-1h partition by endpoint interval(5m) order by endpoint,_wstart;
21. Adapter 内存使用
select _wstart,cast(max(rss)/1024/1024/1024 as int) as rss_gb,endpoint from log.adapter_status where _c0>now-1h partition by endpoint interval(5m) order by endpoint,_wstart;
22. 查询进程下线程数量
grep '^Name:' /proc/`pidof taosadapter`/task/*/status | awk '{print $NF}' |sort -n |uniq -c
grep '^Name:' /proc/`pidof taosd`/task/*/status | awk '{print $NF}' |sort -n |uniq -c