mysqlnd_ms error - getaddrinfo failed, mysqlnd_global_stats in Unknown

爷,独闯天下 提交于 2019-12-10 11:19:04

问题


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:


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



来源:https://stackoverflow.com/questions/17795500/mysqlnd-ms-error-getaddrinfo-failed-mysqlnd-global-stats-in-unknown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!