Не удается установить и запустить mysqlnd_ms в Ubuntu - PullRequest
0 голосов
/ 03 сентября 2018

Мне трудно установить mysqlnd_ms на мою машину с Ubuntu. Шаги:

  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

ошибка

При попытке "заставить" создать файл mysqlnd_ms.so он выдал ошибку, что php_smart_str.h отсутствует. После прочтения нескольких связанных тем понял, что php_smart_str.h переименован в php_smart_string.h в php7. так добавлена ​​символическая ссылка

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 голосов
/ 07 сентября 2018

Я могу решить проблему, выполнив следующие шаги

Шаги установки mysqlnd_ms для php7.2

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();

будет отображаться, если плагин активен

...