dbproxy安装问题记录

许波涛
2023-12-01
源码从代码仓库下载到本地
git clone git@github.com:Meituan-Dianping/DBProxy.git
编译源码并安装(添加新文件和修改版本的时候需要运行autogen.sh,注意docker centos:6.6 image下运行autogen.sh会失败)
sh autogen.sh
sh bootstrap.sh
make && make install

执行sh bootstrap.sh 报错

修改 bootstrap.sh 成下面这个样子
#!/bin/sh 
base=$(cd "$(dirname "$0")"; pwd)
cd $base
./configure  --with-mysql=/usr/local/mysql/bin/mysql_config --prefix=/usr/local/mysql-proxy CFLAGS="-s -O0" CPPFLAGS="-I/usr/local/mysql/include/" LDFLAGS="-lm -ldl -lcrypto -ljemalloc" LUA_CFLAGS="-I/usr/include/" LUA_LIBS="-L/usr/lib64 -llua"

执行 make && make install的时候报错
network-mysqld-packet.c: In function 'network_mysqld_auth_challenge_new':
network-mysqld-packet.c:1470:9: error: 'CLIENT_SECURE_CONNECTION' undeclared (first use in this function)
        CLIENT_SECURE_CONNECTION |
        ^
network-mysqld-packet.c:1470:9: note: each undeclared identifier is reported only once for each function it appears in
network-mysqld-packet.c: In function 'network_mysqld_proto_get_auth_challenge':
network-mysqld-packet.c:1583:31: error: 'CLIENT_SECURE_CONNECTION' undeclared (first use in this function)
    if (shake->capabilities & CLIENT_SECURE_CONNECTION) {
                              ^
network-mysqld-packet.c: In function 'network_mysqld_auth_response_new':
network-mysqld-packet.c:1695:26: error: 'CLIENT_SECURE_CONNECTION' undeclared (first use in this function)
    auth->capabilities = CLIENT_SECURE_CONNECTION | CLIENT_PROTOCOL_41;
                          ^
network-mysqld-packet.c: In function 'network_mysqld_proto_get_auth_response':
network-mysqld-packet.c:1772:34: error: 'CLIENT_SECURE_CONNECTION' undeclared (first use in this function)
        if (auth->capabilities & CLIENT_SECURE_CONNECTION) {

http://blog.51cto.com/hnr520/1887750

解决办法:看我标红的地方,注释 /*  CLIENT_SECURE_CONNECTION | */ 然后替换成 CLIENT_RESERVED2
/tools/DBProxy-master/src/network-mysqld-packet.c  
1467    shake->challenge = g_string_sized_new(20);
1468    shake->capabilities =
1469        CLIENT_PROTOCOL_41 |
1470      /*  CLIENT_SECURE_CONNECTION | */
1471        CLIENT_RESERVED2 |
1472        0;


1584    if (shake->capabilities & /*CLIENT_SECURE_CONNECTION*/ CLIENT_RESERVED2) {
1585        err = network_mysqld_proto_get_string_len(packet, &scramble_2, 12);
1586        if (err != 0) {
1587            msg = "get auth challenge's 12-bytes challenge random number failed";
1588            goto funcexit;
1589        }
1590    }

1685 network_mysqld_auth_response *network_mysqld_auth_response_new() {
1686    network_mysqld_auth_response *auth;
1687 
1688    auth = g_new0(network_mysqld_auth_response, 1);
1689 
1690    /* we have to make sure scramble->buf is not-NULL to get
1691      * the "empty string" and not a "NULL-string"
1692      */
1693    auth->response = g_string_new("");
1694    auth->username = g_string_new("");
1695    auth->database = g_string_new("");
1696    auth->capabilities = /*CLIENT_SECURE_CONNECTION*/CLIENT_RESERVED2 | CLIENT_PROTOCOL_41;
1697 
1698    return auth;
1699 }
1773 
1773        if (auth->capabilities & CLIENT_RESERVED2  /*CLIENT_SECURE_CONNECTION*/) {
1774            err = network_mysqld_proto_get_lenenc_gstring(packet, auth->response);
1775            if (err != 0) {
1776                msg = "get auth response failed with CLIENT_RESERVED2";
1777                goto fun_exit;
1778            }
1779        } else {
1780            err = network_mysqld_proto_get_gstring(packet, auth->response);
1781            if (err != 0) {
1782                msg = "get auth response failed without CLIENT_RESERVED2";
1783                goto fun_exit;
1784            }
1785        }

/tools/DBProxy-master/plugins/admin/admin-plugin.c
208 NETWORK_MYSQLD_PLUGIN_PROTO(server_con_init) {
209    network_mysqld_auth_challenge *challenge;
210    GString *packet;
211 
212    challenge = network_mysqld_auth_challenge_new();
213    challenge->server_version_str = g_strdup("5.0.99-agent-admin");
214    challenge->server_version    = 50099;
215    challenge->charset            = 0x08; /* latin1 */
216    challenge->capabilities      = CLIENT_PROTOCOL_41 | /*CLIENT_SECURE_CONNECTION*/ CLIENT_RESERVED2 | CLIENT_LONG_PASSWORD;
217    challenge->server_status      = SERVER_STATUS_AUTOCOMMIT;
218    challenge->thread_id  
      = 1;
219 

/tools/DBProxy-master/src/network-conn-pool-lua.c
285    g_assert((con->client->response->capabilities
286            & (CLIENT_COMPRESS | CLIENT_PLUGIN_AUTH)) == 0);
287 
288    g_assert((con->client->response->capabilities
289            & (CLIENT_PROTOCOL_41 | CLIENT_RESERVED2 /*CLIENT_SECURE_CONNECTION*/)) != 0);
290 

/tools/DBProxy-master/plugins/proxy/proxy-plugin.c
1107    if (!(auth->capabilities & CLIENT_RESERVED2 /*CLIENT_SECURE_CONNECTION*/)) {
1108        gchar *msg = "Old Password Authentication is not supported";
1109        CON_MSG_HANDLE(g_warning, con, msg);
1110        SEND_INTERNAL_ERR(msg);
1111        network_mysqld_auth_response_free(auth);
1112        return NETWORK_SOCKET_ERROR;
1113    }

/tools/DBProxy-master/src/network-mysqld-proto.h
48 // 不支持CLIENT_CONNECT_ATTRS
49 #define MYSQL_PROTOCOL_CAPABILITIES (CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB | \
50                CLIENT_PROTOCOL_41 | CLIENT_TRANSACTIONS | CLIENT_RESERVED2 /*CLIENT_SECURE_CONNECTION*/)
51 

.导入mysql5.7库文件
echo '/usr/local/mysql/lib' >> /etc/ld.so.conf
ldconfig

 类似资料: