TDengine3.0 DBA常用的运维命令和SQL2

文章目录

    • [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. 状态检查

sql 复制代码
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. 订阅监控

sql 复制代码
## 查询是否有消费记录为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 分布

sql 复制代码
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

sql 复制代码
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. 查看表分布

sql 复制代码
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分布

sql 复制代码
REDISTRIBUTE VGROUP vgroup_no DNODE dnode_id1 [DNODE dnode_id2] [DNODE dnode_id3];

18. 查看占用磁盘空间

sql 复制代码
select * from  INFORMATION_SCHEMA.INS_DISK_USAGE where db_name = 'db_name';
show db_name.disk_info;

19. Adapter Websocket 连接数

sql 复制代码
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 连接数

sql 复制代码
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 内存使用

sql 复制代码
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. 查询进程下线程数量

bash 复制代码
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
相关推荐
飞奔的瓜牛1 小时前
Wireshark 抓包实战:呼叫中心项目中的 SIP、DTMF 与 RTP 分析
运维·wireshark
顧棟1 小时前
【ES实战】 索引模板「可追溯、可校验」:一种模板治理的工程化思路
java·数据库·elasticsearch
Decay__2 小时前
SQLServer 监控体系构建 —— sql_exporter + Prometheus + Grafana 全栈实战
运维·数据库·sql·mysql·架构
遇雪长安2 小时前
wslc 来了:Docker Desktop 还要留着吗?
运维·docker·容器
tianyuanwo3 小时前
NocoDB 系统手册:PostgreSQL 主机资产管理的界面层实施方案
数据库·postgresql·oracle
Umi·3 小时前
MySQL之多表关联查询练习
数据库·mysql
实泽有之,无泽虚之3 小时前
Windows环境bat脚本自动备份MySQL数据库并清理旧备份文件
数据库·mysql
csdn_aspnet3 小时前
【Docker 攻略】MySQL 安裝篇
运维·mysql·docker·容器
艺杯羹3 小时前
ufw 已 active,Docker 端口却仍对外开放的复盘
运维·docker·容器