When mysqlslap stress tests "Can not connect to MySQL server"

mysqlslap -utest -h 192.168.1.12 -p'test' --concurrency=100 --iterations=500 --create-schema='my_db'

 

The results of the pressure 10 seconds, frequently report

mysqlslap: Error when connecting to server: 2003 Can't connect to MySQL server

 

Then see tcp connection with netstat -tnp, we found more than 20,000 tcp connection, the entire stay in time_wait state. Suspected port exhausted. Internet looked at the statistics and found an article providing information useful

http://blog.csdn.net/fanyun7654/article/details/20725783

 

Program available port range, is a kernel parameter

shell> sysctl -a | grep port

net.ipv4.ip_local_port_range = 32768 61000

 

The solution

First, increase the range of ports, but limited role

shell> echo "net.ipv4.ip_local_port_range = 10240 61000" >> /etc/sysctl.conf

shell> sysctl -p

 

Second, the port can be reused

sysctl net.ipv4.tcp_tw_reuse=1

or

net.ipv4.tcp_tw_reuse = 1 write /etc/sysctl.conf

 

Turn: http: //yeyingxian.lofter.com/post/1cc6ccfe_65f74af

Guess you like

Origin www.cnblogs.com/royfans/p/11329085.html