Load balancing not possible with Zend Framework due to MySQL Adapter Error

Test Account asked:

I recieve the following error message when I set up load balancing between two servers that are running the zendframework called “SocialEngine”

As it looks there is a problem that I can’t connect twice to my DB-Server, how can I handle this problem?

Fatal error: Uncaught exception ‘Zend_Db_Adapter_Mysqli_Exception’ with message ‘Can’t connect to MySQL server on ‘10.8.160.132’ (13)’ in /var/www/html/Test12082013SocialEngine/application/libraries/Zend/Db/Adapter/Mysqli.php:352 Stack trace: #0 /var/www/html/Test12082013SocialEngine/application/libraries/Zend/Db/Adapter/Abstract.php(448): Zend_Db_Adapter_Mysqli->_connect() #1 /var/www/html/Test12082013SocialEngine/application/modules/Core/Bootstrap.php(112): Zend_Db_Adapter_Abstract->query(‘SET time_zone =…’) #2 /var/www/html/Test12082013SocialEngine/application/libraries/Engine/Application/Bootstrap/Abstract.php(256): Core_Bootstrap->_initDb() #3 /var/www/html/Test12082013SocialEngine/application/libraries/Engine/Application/Bootstrap/Abstract.php(207): Engine_Application_Bootstrap_Abstract->_executeResource(‘db’) #4 /var/www/html/Test12082013SocialEngine/application/libraries/Engine/Application/Bootstrap/Abstract.php(150): Engine_Application_Bootstrap_Abstract->_bootstrap(NULL) #5 /var/www/html/Test12082013SocialEngi in /var/www/html/Test12082013SocialEngine/application/libraries/Zend/Db/Adapter/Mysqli.php on line 352

EDIT
This Error only showns on the second server, the first server can connect properly to the db

My answer:


You need to set the appropriate SELinux boolean to allow the web server to communicate with remote databases.

setsebool -P httpd_can_network_connect_db 1

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.