Solve the Problem of too many connections in MySQLTIME_WAIT status

Source: Internet
Author: User
When you use netstat-an to view the system connection status, a large number of TIME_WAIT connections are found, all of which are mysql. Then google, and the following is a solution. [Root @ blog ~] # Netstat-anActiveInternetconnections (serversandestablished) ProtoRecv-QSend-QLocalAddressForeignAddressS

Use netStat-An large number of TIME_WAIT connections are found when you view the system connection status, all of which are mysql. Then google, and the following is a solution.
[Root @ blog ~] #Netstat-
Active Internet connections (servers and establishEd)
Proto Recv-Q Send-Q LocalDdRess Foreign Address State
TCp0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN
Tcp 0 0 127.0.0.1: 11211 0.0.0.0: * LISTEN
Tcp 0 0 0.0.0.0: 80 0.0.0.0: * LISTEN
Tcp 0 0 127.0.0.1: 43389 127.0.0.1: 3306 TIME_WAIT
Tcp 0 0 127.0.0.1: 43388 127.0.0.1: 3306 TIME_WAIT
Tcp 0 0 127.0.0.1: 43387 127.0.0.1: 3306 TIME_WAIT
Tcp 0 0 127.0.0.1: 43382 127.0.0.1: 3306 TIME_WAIT
Tcp 0 0 127.0.0.1: 43381 127.0.0.1: 3306 TIME_WAIT
Tcp 0 0 127.0.0.1: 43380 127.0.0.1: 3306 TIME_WAIT
Tcp 0 0 127.0.0.1: 43379 127.0.0.1: 3306 TIME_WAIT
Tcp 0 0 127.0.0.1: 43378 127.0.0.1: 3306 TIME_WAIT
Tcp 0 0 127.0.0.1: 11211 127.0.0.1: 38792 ESTABLISHED
Tcp 0 0 127.0.0.1: 11211 127.0.0.1: 38799 ESTABLISHED

Solution
# Vi/etc/sysctl. conf. Add the following content at the end of the file:
Net. ipv4.tcp _ syNcOokies = 1
Net. ipv4.tcp _ tw_reuse = 1
Net. ipv4.tcp _ tw_recycle = 1
Net. ipv4.tcp _ fin _TimeOut = 30
# Sysctl-p // make the modified kernel take effect

Option description
Net. ipv4.tcp _SyncOokies = 1 // indicates enabling SYN Cookies. When a SYN wait queue overflows, cookies are enabled to prevent a small number of SYN attacks. The default value is 0, indicating that the operation is disabled.
Net. ipv4.tcp _ tw_reuse = 1 // indicates enabling reuse. Allow TIME-WAIT sockets to be re-used for new TCP connections. The default value is 0, indicating that it is disabled.
Net. ipv4.tcp _ tw_recycle = 1 // indicates to enable fast TIME-WAIT sockets recovery in the TCP connection. The default value is 0, indicating to disable TIME-WAIT sockets.
Net. ipv4.tcp _ fin_timeout // modify the system? Default TIMEOUT time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.