Page 1 of 1

Memory is full.

Posted: 2019/11/12 08:14:26
by hack3rcon
Hello,
On a CentOS web server I see below error:

Code: Select all

SQLSTATE[HY000] [1040] Too many connections
The MySQL config file is:

Code: Select all

# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-show-database

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
user=mysql

# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
;plugin-load=rpl_semi_sync_master=semisync_master.so
# uncomment next line on SLAVE
;plugin-load=rpl_semi_sync_slave=semisync_slave.so

# Others options for Semisynchronous Replication
;rpl_semi_sync_master_enabled=1
;rpl_semi_sync_master_timeout=10
;rpl_semi_sync_slave_enabled=1

# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
;performance_schema


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

bind-address = 127.0.0.1
local-infile=0
And "htop" command show me:
htop.png
htop.png (182.13 KiB) Viewed 1215 times
How can I troubleshoot it?

Thanks.

Re: Memory is full.

Posted: 2019/11/12 12:15:33
by TrevorH
SQLSTATE[HY000] [1040] Too many connections
Has nothing to do with memory "being full". You either don't have enough connections allowed in your mysql config (unlikely but possible) or, far more likely, you have a bug in whatever app you are using that leaks mysql connections - i.e. opens them and never closes them - so it runs until all possible connections are used up and then hits that error. Raising the connection limit on the mysql side in that case will only delay (possibly only slightly) the onset of the problem.

Re: Memory is full.

Posted: 2019/11/12 12:49:48
by hack3rcon
How can I estimate a good value of "max_connections"?

Re: Memory is full.

Posted: 2019/11/12 13:16:56
by BShT
you can size server and max_connections according to your load

there is no magic number

here we have max_connections = 1000 and innodb_buffer_pool_size = 16G per 32vCPUx32GB node

Re: Memory is full.

Posted: 2019/11/12 14:19:00
by TrevorH
In 99% of cases, that error means your app is buggy and leaking connections. I checked a CentOS 6 mysql server that does not have "max_connections=" in my.cnf and it is set to a maximum of 151 connections. You would need to have 152 concurrent accesses to your app to make it exhaust those.

Re: Memory is full.

Posted: 2019/11/12 21:53:48
by lightman47
Is this the same machine with the 'testuser' account, or a different one?

Re: Memory is full.

Posted: 2019/11/12 23:03:35
by TrevorH
Also, since the reported symptom (Too many connections) has nothing whatsoever to do with the subject title, perhaps a pointer to http://linuxatemyram.com wouldn't go amiss...

Re: Memory is full.

Posted: 2019/11/13 07:03:20
by hack3rcon
TrevorH wrote:
2019/11/12 23:03:35
Also, since the reported symptom (Too many connections) has nothing whatsoever to do with the subject title, perhaps a pointer to http://linuxatemyram.com wouldn't go amiss...
Is you mean https://www.linuxatemyram.com/play.html?

Re: Memory is full.

Posted: 2019/11/13 07:33:32
by jlehtone
It does appear that:
* There is a seriously misconfigured server (accounts, firewall)
* There are web pages with flaws (that misuse SQL)
* Current admin has insufficient knowledge
* The "web server" is "vital" (and for vital things one must allocate appropriate resources)

We can not, nor should teach the basics. For that one should seek local expert.
We can not, nor should teach how to write a web page. For that one should seek local expert.

We can explain CentOS-specific bits, if the recipient knows general principles.

Re: Memory is full.

Posted: 2019/11/13 07:59:41
by TrevorH
No, I meant the thing I linked to, not what you did.