Mysql – PHP thesqlnd on Debian 6

debianMySQLmysql-replicationphp5

I've installed php5-mysqlnd via:


apt-get install php5-mysqlnd

This is a brand new virgin Debian install with just apache2 and php5 via:

apt-get install apache2
echo "deb http://http.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list
apt-get update
apt-get install php5 php5-dev php5-cli libapache2-mod-php5 php5-mysqlnd

When I do a phpinfo() it shows that mysqlnd is being used.

My question is, where do I place config details to specify the master/slave details so I can use automatic load balancing and read/write splitting?

I've read and followed: http://www.php.net/manual/en/mysqlnd-ms.quickstart.configuration.php

I appended:

mysqlnd_ms.enable=1
mysqlnd_ms.config_file=/etc/php5/mysqlnd_ms_plugin.ini

To /etc/php5/conf.d/10-mysqlnd.ini

Which now reads:

; configuration for php MySQL module
; priority=10
extension=mysqlnd.so

mysqlnd_ms.enable=1
mysqlnd_ms.config_file=/etc/php5/mysqlnd_ms_plugin.ini

Unfortunately these settings don't seem to have made any difference as I cannot do a mysql_connect() using the hostname "myapp" as the section name I configured in /etc/php5/mysqlnd_ms_plugin.ini as:

{
    "myapp": {
        "master": {
            "master_0": {
                "host": "127.0.0.1",
                "port": "3306"
            }
        },
        "slave": {
            "slave_0": {
                "host": "10.0.0.1",
                "port": "3306"
            }
        }
    }
}

Can anyone shed light on where I have gone wrong with the config and what I can do to get it working so I can connect using read/write splitting using my replicated DBs?

EDIT: After the comment below I realised I hadn't actually added the mysqlnd_ms plugin. After attempting to install this plugin via pecl I get an error about mysqlnd.h missing.

Best Answer

you not only need php5-mysqlnd but also mysqlnd_ms plugin (http://pecl.php.net/package/mysqlnd_ms) installed.