Can't connect to MySQL server for linux tcp connection Optimization

Source: Internet
Author: User

Can't connect to MySQL server for linux tcp connection optimization recently two web machines are connected to mysql, sometimes there will be Can't connect to MySQL server, view the exception log:

[message:protected] => SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘192.168.1.248′(99)

 

1): Problem description: only one of the two web servers has this exception, and the other does not. exception logs: Can't connect to MySQL server on '*. *. *. * '(99) 2): troubleshooting: 1. Check mysql variables, status:
max_connect_errors = 50000max_connections = 1000max_user_connections = 200max_connect_errors = 50000max_connections = 1000max_user_connections = 200

 

2. ulimit-a: 3. Check netstat-anp and check the netstat-anp of the problematic machine. Most of the machines are found to be TIME_WAIT, which is suspected to be a tcp problem. Nearly 30 thousand of network sockets exist, at this time, the CPU is also exhausted, causing so many TCP/IP connections to be unable to process the CPU, and some TCP/IP connections to time out or fail to process 3, OS: more/etc/sysctl. conf: net. ipv4.tcp _ syncookies = 1 new connection can be re-used with TIME-WAIT socket net. ipv4.tcp _ tw_reuse = 1 enable the Fast Loop function of TIME-WAIT socket status. net. ipv4.tcp _ tw_recycle = 1 when the socket is closed, the time for retaining the FIN-WAIT-2 status is net. ipv4.tcp _ fin_timeout = 30 for all protocol queues, set the maximum system sending cache (wmen) and receiving cache (rmem) to 8 M net. core. wm Em_max = 8388608 net. core. rmem_max = 8388608 to make the parameter take effect. 3): cause: the error "Can't connect to MySQL server on '*. *. *. * '(99) "refer to MySQL Client error code Description: The error code is 99,99. Meaning: $ perror 99 OS error code 99: cannot assign requested address this is a local OS error, indicating that the local address resources Cannot be allocated (it should be a port), and the socket Cannot create "Cannot assign requested address ", most of the reason is that the client requests are too frequent, and the local Server is temporarily in TIME_WAIT after the Server is shut down, so the ports are temporarily unavailable. Therefore, you can modify the OS parameter.

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.