mysqlnd_ms error - getaddrinfo failed, mysqlnd_glo

2019-05-28 00:47发布

I'm trying to set up mysqlnd_ms so that it serves its purpose of doing the reads on the slave db and writes on the master db. However, I'm getting this error when httpd is restarted.

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysqlnd_ms.so' - /usr/lib64/php/modules/mysqlnd_ms.so: undefined symbol: mysqlnd_global_stats in Unknown on line 0

I'm running an Amazon EC2 x64 AMI instance and ran the following commands on a fresh instance:

sudo yum update

sudo yum install -y gcc make gcc-c++

sudo yum install -y httpd24 php54

sudo yum install -y php54-devel php54-mysqlnd php54-mbstring

sudo pecl install mysqlnd_ms

php -m | grep mysql

My php.ini included the following additions:

mysqlnd_ms.enable=1
mysqlnd_ms.force_config_usage=1
mysqlnd_ms.config_file=/etc/mysqlnd_ms.ini
extension=mysqlnd_ms.so

The mysqlnd_ms.ini file has this:

{    
"appname": {
    "master": {
        "master_0": {
            "host": "1.2.3.4",
            "db": "dbname",
            "user": "dbuser",
            "password": "dbpswd",
            "socket" : "\/var\/lib\/mysql\/mysql.sock"
        }
    },
    "slave": {
        "slave_0": {
            "host": "12.22.32.42",
            "db": "dbname",
            "user": "dbuser",
            "password": "dbpswd",
            "socket" : "\/var\/lib\/mysql\/mysql.sock"
        }
       }
}
}

To connect, I do:

$mysqli = new mysqli("appname", "dbuser", "dbpswd", "schema");

Doing the above throws the following error:

ERROR: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Mysqli, mysql, and pdo are all enabled on the server.

If we change it directly to the host name, it works:

$mysqli = new mysqli("1.2.3.4", "dbuser", "dbpswd", "schema");

How can I get mysqlnd_ms to function properly?

1条回答
老娘就宠你
2楼-- · 2019-05-28 01:32

Problem solved!!!

To resolve this issue:

  1. Remove the lines:

mysqlnd_ms.enable=1

mysqlnd_ms.force_config_usage=1

mysqlnd_ms.config_file=/etc/mysqlnd_ms_cfg.ini

extension=mysqlnd_ms.so

from the php.ini file

  1. Create a new file called "/etc/php.d/mysqlnd_ms.ini" and put those lines in there

  2. Reload httpd

查看更多
登录 后发表回答