command to view the number of time_wait connections netstat-ae|grep "time_wait" |wc-l

Source: Internet
Author: User
command to view the number of time_wait connections netstat-ae|grep "time_wait" |wc-l the morning log in to the server when entering Netstat-an|grep MySQL Found a large number of time_wait states connected tcp        0      0 127.0.0.1:3306              127.0.0.1:41378              time_wait tcp         0      0 127.0.0.1:3306               127.0.0.1:41379              time_wait tcp        0      0 127.0.0.1:3306              127.0.0.1:39352              time_wait tcp         0      0 127.0.0.1:3306               127.0.0.1:39350             TIME_WAIT TCP         0      0 127.0.0.1:3306               127.0.0.1:35763              time_wait tcp        0       0 127.0.0.1:3306               127.0.0.1:39372             TIME_WAIT TCP         0      0 127.0.0.1:3306               127.0.0.1:39373              time_wait tcp        0       0 127.0.0.1:3306              127.0.0.1:41176              time_wait       by adjusting kernel parameters to resolve Vi/etc/sysctl.conf
Edit the file and add the following: net.ipv4.tcp_syncookies = 1 Net.ipv4.tcp_tw_reuse = 1 Net.ipv4.tcp_tw_recycle = 1 Net.ipv4.tcp_fin_timeout = 30 then executes the/sbin/sysctl-p to allow the parameters to take effect. net.ipv4.tcp_syncookies = 1Indicates that the SYN cookie is opened. When the SYN wait queue overflow occurs, cookies are enabled to handle, to prevent a small number of SYN attacks, the default is 0, indicating shutdown;
net.ipv4.tcp_tw_reuse = 1Indicates open reuse. Allows time-wait sockets to be re used for a new TCP connection, which defaults to 0, indicating shutdown;
net.ipv4.tcp_tw_recycle = 1Represents a quick recycle of time-wait sockets on a TCP connection, which defaults to 0, indicating shutdown.
Net.ipv4.tcp_fin_timeoutAfter modifying the system default TIMEOUT time changes, then use the command to view the number of time_wait connections netstat-ae|grep "time_wait" |wc–l
found that a large number of time_wait no longer exist, the MySQL process occupancy rate quickly down, the site access is normal. However, many times, the presence of a large number of time_wait state of the connection, often because the Web site program code does not use Mysql.colse (), resulting in a large number of MySQL time_wait.

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.