常规排查项
数据库日志文件
查看数据库所有日志文件,查看日志文件中是否存在异常项,日志文件详细说明参见《日志参考》。
登录验证
查看数据库所有工作节点是否可成功登录,需要编写数据库登录脚本实现通过指定IP地址验证所有节点是否可登入。
集群状态
查看集群所有节点状态、存储分布情况、节点运行时长等。
sql
show clusters
或
sql
select * from sys_clusters
数据库连接
查看各节点连接情况,包括总连接数、各状态连接数、各客户端IP连接数、连接时长、连接内存使用、连接空闲时间等。
sql
select * from sys_all_sessions;--查看所有连接
select * from sys_all_sessions where status=114;--查看活动连接
select * from sys_all_sessions order by start_t desc limit 10;--查看在线时间长的连接
select * from sys_all_sessions order by visit_t asc limit 10;--查看空闲时间长的连接
select * from sys_all_sessions order by TRANS_START_T asc limit 10;--查看长事务连接
select * from sys_all_sessions order by mem_size desc limit 10;--查看内存使用多的连接
select ip,count(*) from sys_all_sessions group by ip;--查看客户端ip连接分布
select nodeid,count(*) from sys_all_sessions group by nodeid;--查看各节点连接数分布
事务状态
查看数据库中事务执行情况,包括长事务、大事务、事务命令数、代理事务分布、事务完成或未完成数据副本同步数、事务中修改数据量等。
sql
select * from sys_all_trans;--查看所有事务列表
select * from sys_all_trans order by start_t asc limit 10;--查看长事务
select * from sys_all_trans order by modify_count asc limit 10;--查看事务修改数据量
select * from sys_all_trans where want_sync>done_sync;--查看副本同步未完成事务
select * from sys_all_trans where done_del_idx>0 order by done_del_idx desc;--查看事务已完成索引删除
select * from sys_all_trans where is_proxy='F';--查看所有主事务(根事务)
select * from sys_all_trans where r_transid=@p;--查看某个主事务及其代理事务分布
线程状态
查看数据库线程与性能情况,包括线程ID、当前状态、等候资源、当前内存大小、当前事务等。
sql
select * from sys_all_thd_status;--所有线程列表
select * from sys_all_thd_status where type=9;--任务线程
select * from sys_all_thd_status where type=9 and state=0;--空闲态任务线程
select * from sys_all_thd_status where type=9 and state=1;--运行态任务线程
select * from sys_all_thd_status where type=9 and state>1;--正等候资源任务线程
select * from sys_all_thd_status where type=9 and state=@p;--某个等候态的任务线程
select * from sys_all_thd_status order by mem_size desc limit 10;--查看内存使用大的线程
select * from sys_all_thd_status where curr_tid=@p;--查看某个事务的执行线程(线程正在执行的事务,此处事务可能时主事务或代理事务)
select state,count(*) from sys_all_thd_status group by state;--各状态的线程数
select state,count(*) from sys_all_thd_status where type=9 group by state;--各状态的任务线程数
select state,count(*) from sys_all_thd_status where type=9 and state>1 group by state;--各等候状态的任务线程数
select * from sys_all_thd_status where WAIT_TYPE =@p;--等候某类资源的线程
select * from sys_all_thd_status where WAIT_OBJ =@p;--等候某个资源的线程
-----------