mysqlnd_ms错误 - getaddrinfo失败,mysqlnd_global_stats in Unknown

时间:2013-07-22 19:10:08

标签: php amazon-ec2 mysqli ec2-ami mysqlnd

我试图设置mysqlnd_ms,以便它的目的是对从属数据库进行读取并在主数据库上进行写入。但是,重新启动httpd时,我收到此错误。

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

我正在运行Amazon EC2 x64 AMI实例并在新实例上运行以下命令:

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

我的php.ini包括以下内容:

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

mysqlnd_ms.ini文件包含:

{    
"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"
        }
       }
}
}

要连接,我这样做:

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

执行以上操作会引发以下错误:

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

Mysqli,mysql和pdo都在服务器上启用。

如果我们将其直接更改为主机名,则可以:

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

如何让mysqlnd_ms正常运行?

1 个答案:

答案 0 :(得分:4)

问题解决了!!!

要解决此问题:

  1. 删除行:
  2.   

    mysqlnd_ms.enable = 1

         

    mysqlnd_ms.force_config_usage = 1

         

    mysqlnd_ms.config_file =的/ etc / mysqlnd_ms_cfg.ini

         

    延长= mysqlnd_ms.so

    来自php.ini文件

    1. 创建一个名为“/etc/php.d/mysqlnd_ms.ini”的新文件并将这些行放在那里

    2. 重新加载httpd