无法在ubuntu中安装和运行mysqlnd_ms

时间:2018-09-03 15:19:04

标签: php mysqli ubuntu-16.04 mysqlnd

我很难在ubuntu机器上安装mysqlnd_ms。 遵循的步骤:

  1. 更新了我的本地计算机以运行php 7
  2. 遵循https://github.com/sergiotabanelli/mysqlnd_ms并安装了必需的库
sudo apt-get install libxml2-dev 
sudo apt-get install libmemcached-dev 
sudo apt-get install php-json
  1. make和sudo make install
  2. 使用主机名,用户名,密码和数据库创建了一个json文件
{
    "myapp": {
        "master": {
            "master_0": {
                "host": "XXXX.rds.amazonaws.com",
                "username":"XXXX",
                "password":"XXXX",
                "database":"XXXX"
            }
        },
        "slave": {
            "slave_0": {
                "host": "XXXX.rds.amazonaws.com",
                "username":"XXXX",
                "password":"XXXX",
                "database":"XXXX",
                "port": "3306"
            }
        }
    }
}
  1. 已编辑php.ini文件以使其具有
 mysqlnd_ms.enable=1      mysqlnd_ms.force_config_usage=1
 mysqlnd_ms.config_file=/etc/mysqlnd_ms_cfg.ini
 extension=mysqlnd_ms.so
  1. 重新启动Apache服务

我错过了什么吗? PHP信息仍然没有显示与mysqlnd_ms相关的任何信息。

$mysqli = new mysqli("myapp", "username", "password", "database");

给予

  

php_network_getaddresses:getaddrinfo失败

错误

尝试“ make”创建mysqlnd_ms.so文件时 它抛出了一个错误,提示缺少php_smart_str.h。在阅读了几个相关的线程之后,我们了解到php7中的php_smart_str.h被重命名为php_smart_string.h。因此添加了符号链接

ln -s  ext/standard/php_smart_string.h ext/standard/php_smart_str.h

现在,当尝试使用命令再次制作时

sudo pecl install mysqlnd_ms

出现以下错误

running: make
    /bin/bash /tmp/pear/temp/pear-build-rootNt6r2K/mysqlnd_ms-1.5.2/libtool
--mode=compile cc  -I. -I/tmp/pear/temp/mysqlnd_ms -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootNt6r2K/mysqlnd_ms-1.5.2/include -I/tmp/pear/temp/pear-build-rootNt6r2K/mysqlnd_ms-1.5.2/main -I/tmp/pear/temp/mysqlnd_ms -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c -o php_mysqlnd_ms.lo
    libtool: compile:  cc -I. -I/tmp/pear/temp/mysqlnd_ms -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootNt6r2K/mysqlnd_ms-1.5.2/include -I/tmp/pear/temp/pear-build-rootNt6r2K/mysqlnd_ms-1.5.2/main -I/tmp/pear/temp/mysqlnd_ms -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c  -fPIC -DPIC -o .libs/php_mysqlnd_ms.o
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function ‘zm_startup_mysqlnd_ms’:
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:161:3: error: too few arguments to function ‘mysqlnd_stats_init’
       mysqlnd_stats_init(&mysqlnd_ms_stats, MS_STAT_LAST);
       ^
    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:34:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
    /usr/include/php/20151012/ext/mysqlnd/mysqlnd_statistics.h:160:13: note: declared here
     PHPAPI void mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count, int persistent);
                 ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function ‘zm_shutdown_mysqlnd_ms’:
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:206:3: error: too few arguments to function ‘mysqlnd_stats_end’
       mysqlnd_stats_end(mysqlnd_ms_stats);
       ^
    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:34:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
    /usr/include/php/20151012/ext/mysqlnd/mysqlnd_statistics.h:161:13: note: declared here
     PHPAPI void mysqlnd_stats_end(MYSQLND_STATS * stats, int persistent);
                 ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function ‘zif_mysqlnd_ms_get_last_used_connection’:
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:293:21: error: too few arguments to function ‘zval_to_mysqlnd’
      if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
                         ^
    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
    /usr/include/php/20151012/ext/mysqlnd/mysqlnd_reverse_api.h:36:18: note: declared here
     PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int client_api_capabilities, unsigned int * save_client_api_capabilities);
                      ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:301:3: error: too many arguments to function ‘add_assoc_string_ex’
       add_assoc_string_ex(return_value, "scheme", sizeof("scheme"), conn->scheme? conn->scheme:"", 1);
       ^
    In file included from /usr/include/php/20151012/main/php.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_API.h:397:14: note: declared here
     ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
                  ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:302:3: error: too many arguments to function ‘add_assoc_string_ex’
       add_assoc_string_ex(return_value, "host_info", sizeof("host_info"), conn->host_info? conn->host_info:"", 1);
       ^
    In file included from /usr/include/php/20151012/main/php.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_API.h:397:14: note: declared here
     ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
                  ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:303:3: error: too many arguments to function ‘add_assoc_string_ex’
       add_assoc_string_ex(return_value, "host", sizeof("host"), conn->host? conn->host:"", 1);
       ^
    In file included from /usr/include/php/20151012/main/php.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_API.h:397:14: note: declared here
     ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
                  ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:305:3: error: too many arguments to function ‘add_assoc_string_ex’
       add_assoc_string_ex(return_value, "socket_or_pipe", sizeof("socket_or_pipe"), conn->unix_socket? conn->unix_socket:"", 1);
       ^
    In file included from /usr/include/php/20151012/main/php.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_API.h:397:14: note: declared here
     ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
                  ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:307:3: error: too many arguments to function ‘add_assoc_string_ex’
       add_assoc_string_ex(return_value, "last_message", sizeof("last_message"), conn->last_message? conn->last_message:"", 1);
       ^
    In file included from /usr/include/php/20151012/main/php.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_API.h:397:14: note: declared here
     ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
                  ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:309:3: error: too many arguments to function ‘add_assoc_string_ex’
       add_assoc_string_ex(return_value, "error", sizeof("error"), (char *) MYSQLND_MS_ERROR_INFO(conn).error, 1);
       ^
    In file included from /usr/include/php/20151012/main/php.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_API.h:397:14: note: declared here
     ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
                  ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:310:3: error: too many arguments to function ‘add_assoc_string_ex’
       add_assoc_string_ex(return_value, "sqlstate", sizeof("sqlstate"), (char *) MYSQLND_MS_ERROR_INFO(conn).sqlstate, 1);
       ^
    In file included from /usr/include/php/20151012/main/php.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_API.h:397:14: note: declared here
     ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
                  ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function ‘zif_mysqlnd_ms_get_last_gtid’:
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:333:21: error: too few arguments to function ‘zval_to_mysqlnd’
      if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
                         ^
    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
    /usr/include/php/20151012/ext/mysqlnd/mysqlnd_reverse_api.h:36:18: note: declared here
     PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int client_api_capabilities, unsigned int * save_client_api_capabilities);
                      ^
    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:37:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
    /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms_enum_n_def.h:37:51: error: too few arguments to function ‘ms_orig_mysqlnd_conn_methods->send_query’
     #define MS_CALL_ORIGINAL_CONN_DATA_METHOD(method) ms_orig_mysqlnd_conn_methods->method
                                                       ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:365:15: note: in expansion of macro ‘MS_CALL_ORIGINAL_CONN_DATA_METHOD’
       if (PASS != MS_CALL_ORIGINAL_CONN_DATA_METHOD(send_query)(conn, (*conn_data)->global_trx.fetch_last_gtid, (*conn_data)->global_trx.fetch_last_gtid_len TSRMLS_CC)) {
                   ^
    /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms_enum_n_def.h:37:51: error: too few arguments to function ‘ms_orig_mysqlnd_conn_methods->reap_query’
     #define MS_CALL_ORIGINAL_CONN_DATA_METHOD(method) ms_orig_mysqlnd_conn_methods->method
                                                       ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:369:16: note: in expansion of macro ‘MS_CALL_ORIGINAL_CONN_DATA_METHOD’
       if (PASS !=  MS_CALL_ORIGINAL_CONN_DATA_METHOD(reap_query)(conn TSRMLS_CC)) {
                    ^
    /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms_enum_n_def.h:37:51: error: too few arguments to function ‘ms_orig_mysqlnd_conn_methods->store_result’
     #define MS_CALL_ORIGINAL_CONN_DATA_METHOD(method) ms_orig_mysqlnd_conn_methods->method
                                                       ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:373:15: note: in expansion of macro ‘MS_CALL_ORIGINAL_CONN_DATA_METHOD’
       if (!(res = MS_CALL_ORIGINAL_CONN_DATA_METHOD(store_result)(conn TSRMLS_CC))) {
                   ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:379:3: warning: implicit declaration of function ‘MAKE_STD_ZVAL’ [-Wimplicit-function-declaration]
       MAKE_STD_ZVAL(row);
       ^
    In file included from /usr/include/php/20151012/Zend/zend.h:39:0,
                     from /usr/include/php/20151012/main/php.h:36,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_variables.h:122:48: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [-Wincompatible-pointer-types]
     #define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC)
                                                    ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:382:4: note: in expansion of macro ‘zval_ptr_dtor’
        zval_ptr_dtor(&row);
        ^
    /usr/include/php/20151012/Zend/zend_variables.h:112:15: note: expected ‘zval * {aka struct _zval_struct }’ but argument is of type ‘zval * {aka struct _zval_struct **}’
     ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:387:18: error: too many arguments to function ‘zend_hash_index_find’
       if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(row), 0, (void**)&gtid)) {
                      ^
    In file included from /usr/include/php/20151012/Zend/zend.h:36:0,
                     from /usr/include/php/20151012/main/php.h:36,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_hash.h:156:30: note: declared here
     ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
                                  ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:389:22: warning: implicit declaration of function ‘Z_STRVAL_PP’ [-Wimplicit-function-declaration]
        strncpy(gtid_str, Z_STRVAL_PP(gtid), sizeof(gtid_str) - 1);
                          ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:389:22: warning: passing argument 2 of ‘strncpy’ makes pointer from integer without a cast [-Wint-conversion]
    In file included from /usr/include/features.h:367:0,
                     from /usr/include/stdlib.h:24,
                     from /usr/include/php/20151012/main/php_config.h:2512,
                     from /usr/include/php/20151012/main/php.h:34,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/x86_64-linux-gnu/bits/string3.h:123:1: note: expected ‘const char * restrict’ but argument is of type ‘int’
     _NTH (strncpy (char *restrict __dest, const char *_restrict __src,
     ^
    In file included from /usr/include/php/20151012/Zend/zend.h:39:0,
                     from /usr/include/php/20151012/main/php.h:36,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:26:
    /usr/include/php/20151012/Zend/zend_variables.h:122:48: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [-Wincompatible-pointer-types]
     #define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC)
                                                    ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:390:4: note: in expansion of macro ‘zval_ptr_dtor’
        zval_ptr_dtor(&row);
        ^
    /usr/include/php/20151012/Zend/zend_variables.h:112:15: note: expected ‘zval * {aka struct _zval_struct }’ but argument is of type ‘zval * {aka struct _zval_struct **}’
     ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:392:29: error: macro "RETURN_STRING" passed 2 arguments, but takes just 1
        RETURN_STRING(gtid_str, 1);
                                 ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:392:4: error: ‘RETURN_STRING’ undeclared (first use in this function)
        RETURN_STRING(gtid_str, 1);
        ^
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:392:4: note: each undeclared identifier is reported only once for each function it appears in
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function ‘zif_mysqlnd_ms_set_qos’:
    /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:506:21: error: too few arguments to function ‘zval_to_mysqlnd’
      if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
                         ^
    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,
                     from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
    /usr/include/php/20151012/ext/mysqlnd/mysqlnd_reverse_api.h:36:18: note: declared here
     PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int client_api_capabilities, unsigned int * save_client_api_capabilities);
                      ^
    Makefile:194: recipe for target 'php_mysqlnd_ms.lo' failed
    make: * [php_mysqlnd_ms.lo] Error 1
    ERROR: `make' failed

1 个答案:

答案 0 :(得分:1)

我可以按照以下步骤解决问题

用于php7.2的mysqlnd_ms的安装步骤

sudo yum update -y 
sudo yum install -y  php72-mysqlnd php72-devel  libmemcached  libmemcached-devel  libxml2 libxml2-devel git gcc 
git clone https://github.com/sergiotabanelli/mysqlnd_ms.git
cd mysqlnd_ms
phpize
./configure
make
sudo make install
  

在/etc/php.d/mysqlnd_ms.ini中创建一个具有以下内容的文件

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

重新启动apache服务器

使用

创建一个php页面
echo phpinfo();

它将显示插件是否处于活动状态