I have a FreeBSD unix box installed with mysql and InterBase database servers.
I don't have too many traffic or too many sites on the server when this problem happens (both happened in the evening, off traffic peak time). Many other time, the traffic would be much bigger.
The problem
1) the web sites using mysql database get stuck there and then after a long time, shows the error, no mysql connection.
2) the web sites using interbase database are working fine except, the php execution become slow.
The following are the steps I took to solve the problem.
1) run "apachectl restart" to restart the httpd.
It solves the problems, only temporary. the sites using mysql database are working again. But only after a few runs, these sites get stuck again, and shows the mysql no connection error again.
I shut down the hung in httpd process, but mysql server seems still stuck, all my mysql reqeusts are from httpd, I already killed the httpd process by restart apache, why the mysql server still stuck?
2) I then try to use "msqladmin shutdown" to shutdown the mysql server. It hung in there. I cannot shut down the mysql server. A guide says, "if the memory exhaust, you cannot shut down the server by using mysqladmin shutdown."
How can I have memory exhaust problem in a less traffic time, and the server only host a few active sites now, the other same server host hundreds sites and not have the memory problem?
3) So I run the "apachectl restart" to restart the httpd again to kill hung in httpd process. And then I run "msqladmin shutdown" again to shutdown the mysql server. This time, due to the hung in httpd process has been killed, the mysql is shut down.
It seems I have to kill both stuck httpd and mysql progress to free the mysql server, any expert explainations?
4) Then I run the "/usr/local/mysql/bin/mysqld_safe &", it restart the mysql server fresh.
Now it seems solve the problem. I open dozens windows to run the biggest traffic php pages which calls huge work from mysql at the same time. It seems never exhaust the memory and the php and mysql not get stuck again.
My questions:
1) Is this a server memory problem?
2) if it is a memory problem, it happens twice in a year, and both of them happens in the less traffic time, how could it be a memory problem?
3) is it a php problem or mysql problem? php has the reputation using a lot of memory at an instant second, right?
4) what expert explainations you can give?
5) it might be jsut my imageination, it seems after I "apachectl restart", "mysqladmin shutdown", "/usr/local/mysql/bin/mysqld_safe &", it doesn't just solve the problem, the execution become much faster than the regular speed.
is it because "never dead" php process stuck on the server exhuasting the memory or "never dead" mysql process stuck in the server exhuasting the memory?
Is it becase these never dead but stock process sitting there which slow the the server first and then until enough these kind never dead but stock process accumulating to the limit which exhuast the server memory?
Do I have to do "apachectl restart", "mysqladmin shutdown", "/usr/local/mysql/bin/mysqld_safe &" once a while to do some mysql house clean up works as a routine even before I run into the same problems again?
Thanks!