views:

583

answers:

2

php generates GIFs on the web server using a databases on a second server. The the page shows 20 GIFs, so there is some load for a short time (multiple connections)


Some GIFs are loaded but some are not, in /var/www/logs/error_log

[Mon Feb 23 10:05:56 2009] [error] PHP Warning:  mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 in /htdocs/.../myImage.php on line 4
[Mon Feb 23 10:05:56 2009] [error] PHP Fatal error: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 in /htdocs/.../myImage.php on line 4


in /var/www/logs/error_log on the MySQL server I found:

[alert] httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName


Rebooting the MySQL server "resolves" the problem ... for a few days.

The 2 servers are virtual machines running OpenBSD, chroot'ed Apache and MySQL + phpMyAdmin. unfortunately in diferent versions (OpenBSD 4.2(web) and 3.9(mysql))

my knowledge in /var/www/conf/httpd.conf and my.cnf(didn't found it) is very limited.
Any ideas ?

+1  A: 

The "Could not determine the server's fully qualified domain name" error can be ignored, that's an internal apache thing.

Per http://dev.mysql.com/doc/refman/5.0/en/error-lost-connection.html and http://bugs.mysql.com/bug.php?id=28359 this sounds like either a slow network, or an overloaded mysql that can't respond to connections fast enough.

Given that rebooting fixes the issue, I'm going to guess that you've got a slow resource leak. Probably something like expensive queries left running on mysql. You should be able to verify this by tracking system load over time.

A: 

Have you tried putting resolv.conf inside chroot? Such as:

mkdir -p /var/www/etc/ && cp -p /etc/resolv.conf /var/www/etc/

You may also wish to do the same for /etc/localtime if you find your web server time is off from your time zone.

Note:

  • do not use a sym link because it won't work through chroot
  • do not use a hard link because modifying file in chroot would modify file in /etc!
dwc