关于查询mysql processlist的建议
查询mysql进程,因为数据库的sleep连接很多(一般都会在几千个左右),不建议直接show processlist或者show full
Processlist
尽量去用select查询
正在running的线程
Select count(*)from information_schema.processlist where info is not null;
Mysql的全部线程
Select count(*)from information_schema.processlist;
查询当前running sql执行时间最长的10条
Select * frominformation_schema.processlist where info is not null order by time desc limit10 ;
查询执行sql的ip 的连接数量
select left(host,instr(host,‘:‘)-1) asip,count(*) as num from information_schema.processlist group by ip order by num desc;
查询执行sql的user的连接数量
select user,count(*) as num from information_schema.processlist group by userorder by num desc;
查询执行sql语句的数量
select count(*) as num,info from information_schema.processlist where info isnot null group by info order by num;
查询mysql服务器最大连接数、当前数据库连接数和running数show global variables like ‘max_connections‘;
show global status like ‘Threads%‘;
查询用户最大连接数
show grants for ‘mysql_bi‘;
slave错误问题,需要确认数据不一致原因
adm和click库可以直接跳过1个错误
一般处理的方式包括
杀掉慢查询进程,可以针对用户,执行时间去操作
select concat(‘KILL ‘,id,‘;‘) frominformation_schema.processlist where user=‘用户名称‘ and time>100into outfile ‘/tmp/aa.txt‘;
source/tmp/aa.txt
原文:http://liuminkun.blog.51cto.com/10171900/1685492