3

我正在尝试设置 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 正常运行?

4

1 回答 1

4

问题解决了!!!

要解决此问题:

  1. 删除行:

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

于 2013-07-22T21:50:25.607 回答