标签:
今天测试人员反映,一台测试环境mysql服务器查询很慢,有时登录不上, 在top中发现cpu被大量占用,系统内存还有,jave程序运行的很慢,登录服务器,
show full processlist 刷屏了很多进程,还有大量 unauthenticated user 状态的
连接如下:
| 6465371 | unauthenticated user | connecting host | NULL | Connect | NULL | login | NULL | 0 | 0 |
| 6465372 | unauthenticated user | connecting host | NULL | Connect | NULL | login | NULL | 0 | 0 |
| 6465373 | unauthenticated user | connecting host | NULL | Connect | NULL | login | NULL | 0 | 0 |
| 6465374 | unauthenticated user | connecting host | NULL | Connect | NULL | login | NULL | 0 | 0 |
| 6465375 | unauthenticated user | connecting host | NULL | Connect | NULL | login | NULL | 0 | 0 |
| 6465376 | unauthenticated user | connecting host | NULL | Connect | NULL | login | NULL | 0 | 0 |
| 6465377 | unauthenticated user | connecting host | NULL | Connect | NULL | login | NULL | 0 | 0 |
| 6465378 | unauthenticated user | connecting host | NULL | Connect | NULL | login | NULL | 0 | 0 |
看下手册中的解释是:
unauthenticated user refers to a thread that has become associated with a client connection but for which authentication of the client user has not yet been done。
即:有一个线程在处理客户端的连接,但是该客户端还没通过用户验证。
原因可能有:
1、服务器在做DNS反响解析,解决办法有2个:
a、在 hosts 中添加客户端ip,如
192.168.100.18 web-javeb、MySQL启动参数增加一个skip-name-resolve,即不启用DNS反响解析
在配置文件里面添加skip-name-resolve,然后重启服务生效;
2、服务器的线程还处于排队状态,因此可以加大 back_log
back_log为只读参数 需要重启mysql服务
back_log定义mysql在暂时停止回答请求之前的短时间内多少请求可以被存在堆栈中。
如果期望在端时间内有很多连接,则需要增加它
在配置文件里面修改back_log的值;
换句话说,就是该值定义了TCP/IP连接侦听队列的大小
操作系统在这个队列大小上有它自己的限制,视图设定back_log高于操作系统的限制将是无效的。
在mysql中的back_log的设置取决于操作系统,
在Linux下这个参数的值不能大于系统参数tcp_max_syn_backlog的值
通过以下命令可以查看当前值:cat /proc/sys/net/ipv4/tcp_max_syn_backlog通过以下命令进行修改sysctl -w net.ipv4.tcp_max_syn_backlog=n
root@(none) 18:05> show status like ‘Thread%‘;+-------------------------+-------+| Variable_name | Value |+-------------------------+-------+| Threadpool_idle_threads | 10 || Threadpool_threads | 15 || Threads_cached | 0 || Threads_connected | 998 | ====已经用完,(剩下2个是预留的)| Threads_created | 16944 || Threads_running | 5 |+-------------------------+-------+root@(none) 18:05> show variables like ‘%connect%‘;+-----------------------------------------------+-----------------+| Variable_name | Value |+-----------------------------------------------+-----------------+| character_set_connection | utf8 || collation_connection | utf8_general_ci || connect_timeout | 20 || disconnect_on_expired_password | ON || extra_max_connections | 1 || init_connect | || max_connect_errors | 10000 || max_connections | 1000 | =====最大连接数1000| max_user_connections | 1000 || performance_schema_session_connect_attrs_size | 512 |+-----------------------------------------------+-----------------+10 rows in set (0.00 sec
[Warning] Too many connections
mysql 执行show processlist出现很多大量的 ”unauthenticated user”的解决
标签:
原文地址:http://www.cnblogs.com/mysqlplus/p/4767972.html