MySQL connection leak tracking

I have an application server (berth 6 in the Linux box), which hosts 15 private applications (individual war). Every 3 or 4 days I get a warning from nagios regarding the number of open TCP connections. After checking, I see that the vast majority of these connections are connected to the MySQL server.

netstat -ntu | grep TIME_WAIT

Shows 10,000+ connections to the MySQL server from the application server (note that this is TIME_WAIT). If I restart the pier, the connections will drop to almost zero.

Some interesting values ​​from the show state:

mysql> show status;
+--------------------------+-----------+
| Variable_name            | Value     |
+--------------------------+-----------+
| Aborted_clients          | 244       |
| Aborted_connects         | 695853860 |
| Connections              | 697203154 |
| Max_used_connections     | 77        |
+--------------------------+-----------+

A "show processlist" does not show anything unusual (which I would expect, since most connections are idle - remember the TIME_WAIT state above).

TEST env , . , , , . , , , /.

, , ?

+5
6

, my.cnf [mysqld]

wait_timeout=60
interactive_timeout=60

( ): http://community.livejournal.com/mysql/82879.html

, , 22800 . :

mysql> show variables like 'wait_%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 60    |
+---------------+-------+

EDIT: , /etc/sysctl.conf:

net.ipv4.tcp_fin_timeout = 15

.

EDIT 2:/etc/init.d/mysql reload my.cnf(. )

+3

, , , .

, , , , , . , , mysql conf, , X ( 5, ),

+2

, , ( ) mySQL connect/close. , , mySQL , , , /.

0

SHOW PROCESSLIST , . 15 , .

0

+30,000 TIME_WAIT . ​​, /etc/sysctl.conf:

net.ipv4.tcp_syncookies = 1 
net.ipv4.tcp_tw_reuse = 1 
net.ipv4.tcp_tw_recycle = 1 
net.ipv4.tcp_fin_timeout = 30 

:

/sbin/sysctl -p

2 3 TIME_WAIT 30 000 7 000.

0

/proc/sys/net/ipv4/tcp_fin_timeout 60 RHEL7.tcp_tw_reuse tcp_tw_recycle 1, .

0

All Articles