设为首页 收藏本站
查看: 1180|回复: 0

[经验分享] 使用mysql5.7.16头文件库文件编译安装atlas

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-1-3 09:15:33 | 显示全部楼层 |阅读模式
最近mysql数据库升级到5.7.16,而中间件atlas之前是基于mysql5.6编译的,打算重新编译下atlas并使用mysql5.7.16的库文件头文件。这里主要介绍下编译过程遇到问题及解决方法。

由于需要glib版本要大于2.32以上,centos6.6系统自带的glib版本为2.28,因此需要重新编译安装2.32以上的glib,这里安装2.34版本的glib需要依赖pcre大于8.31
一、编译安装pcre8.35
# ./configure --prefix=/usr/local/glib --with-pcre=/usr/local/pcre/
# make
# make install
二、编译安装glib-2.34.3.tar.xz
# ./configure --prefix=/usr/local/glib --with-pcre=/usr/local/pcre/
# make
# make install
三、编译安装Atlas-2.2.1.tar.gz
1.解决依赖关系
# yum install libffi-devel lua-devel libevent libevent-devel jemalloc jemalloc-devel
2.修改源码中mysql版本代码,这里mysql版本为5.7.16
找到plugins/proxy/proxy-plugin.c文件
修改1974行:challenge->server_version_str = g_strdup("5.0.81-log");
为:challenge->server_version_str = g_strdup("5.7.16-log");
修改1974行:challenge->server_version = 50081;
为:challenge->server_version = 50716;
3.安装atlas
修改bootstrap.sh
1
2
3
4
#!/bin/sh
base=$(cd "$(dirname "$0")"; pwd)
cd $base
PKG_CONFIG_PATH=/usr/local/glib/lib/pkgconfig ./configure --with-mysql=/usr/local/mysql5.7.16/bin/mysql_config --prefix=/usr/local/mysql-proxy CFLAGS="-DHAVE_LUA_H -O2" CPPFLAGS="-I/usr/local/mysql5.7.16/include/" LDFLAGS="-lm -ldl -lcrypto -ljemalloc" LUA_CFLAGS="-I/usr/include/" LUA_LIBS="-L/usr/lib64 -llua"



执行
# ./bootstrap.sh
# make && make install
4.执行make时会报错:
错误1:
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/mysql5.7/include -I/usr/local/glib/include/glib-2.0 -I/usr/local/glib/lib/glib-2.0/include -pthread -I/usr/local/glib/include/glib-2.0 -I/usr/local/glib/lib/glib-2.0/include -g -O2 -MT libmysql_proxy_la-network-mysqld-packet.lo -MD -MP -MF .deps/libmysql_proxy_la-network-mysqld-packet.Tpo -c network-mysqld-packet.c  -fPIC -DPIC -o .libs/libmysql_proxy_la-network-mysqld-packet.o
network-mysqld-packet.c: In function ‘network_mysqld_auth_challenge_new’:
network-mysqld-packet.c:1147: error: ‘CLIENT_SECURE_CONNECTION’ undeclared (first use in this function)
network-mysqld-packet.c:1147: error: (Each undeclared identifier is reported only once
network-mysqld-packet.c:1147: error: for each function it appears in.)
network-mysqld-packet.c: In function ‘network_mysqld_proto_get_auth_challenge’:
network-mysqld-packet.c:1221: error: ‘CLIENT_SECURE_CONNECTION’ undeclared (first use in this function)
network-mysqld-packet.c: In function ‘network_mysqld_auth_response_new’:
network-mysqld-packet.c:1323: error: ‘CLIENT_SECURE_CONNECTION’ undeclared (first use in this function)
network-mysqld-packet.c: In function ‘network_mysqld_proto_get_auth_response’:
network-mysqld-packet.c:1378: error: ‘CLIENT_SECURE_CONNECTION’ undeclared (first use in this function)
make[3]: *** [libmysql_proxy_la-network-mysqld-packet.lo] Error 1
make[3]: Leaving directory `/usr/local/src/Atlas-2.2.1/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/usr/local/src/Atlas-2.2.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/Atlas-2.2.1'
make: *** [all] Error 2
错误2:
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -I/usr/local/mysql5.7.16/include -I/usr/local/glib/include/glib-2.0 -I/usr/local/glib/lib/glib-2.0/include -I/usr/include/ -pthread -I/usr/local/glib/include/glib-2.0 -I/usr/local/glib/lib/glib-2.0/include -I../../src/ -I/usr/local/mysql5.7.16/include/ -DHAVE_LUA_H -O2 -MT libadmin_la-admin-plugin.lo -MD -MP -MF .deps/libadmin_la-admin-plugin.Tpo -c admin-plugin.c  -fPIC -DPIC -o .libs/libadmin_la-admin-plugin.o
admin-plugin.c: In function ‘server_con_init’:
admin-plugin.c:203: error: ‘CLIENT_SECURE_CONNECTION’ undeclared (first use in this function)
admin-plugin.c:203: error: (Each undeclared identifier is reported only once
admin-plugin.c:203: error: for each function it appears in.)
make[3]: *** [libadmin_la-admin-plugin.lo] Error 1
make[3]: Leaving directory `/usr/local/src/Atlas-2.2.1/plugins/admin'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/local/src/Atlas-2.2.1/plugins'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/Atlas-2.2.1'
make: *** [all] Error 2
报错原因:mysql5.7之后头文件中的CLIENT_SECURE_CONNECTION变量名修改为CLIENT_RESERVED2
cat /usr/local/src/mysql-5.6.17/include/mysql_com.h
wKiom1hmPqnSIpg_AACZ3w8b3fs747.jpg cat /usr/local/src/mysql-5.7.16/include/mysql_com.h
wKiom1hmPsmQ56W-AACjmqg2vdA033.jpg
5.解决方法:
修改atlas源码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
visrc/network-mysqld-packet.c
1139network_mysqld_auth_challenge *network_mysqld_auth_challenge_new() {
1140         network_mysqld_auth_challenge *shake;
1141
1142         shake =g_new0(network_mysqld_auth_challenge, 1);
1143
1144         shake->challenge =g_string_sized_new(20);
1145         shake->capabilities =
1146                 CLIENT_PROTOCOL_41 |
1147                 CLIENT_SECURE_CONNECTION |
1148                 0;
1149
1150
1151         return shake;
1152 }
修改1147行为如下:
1139network_mysqld_auth_challenge *network_mysqld_auth_challenge_new() {
1140         network_mysqld_auth_challenge *shake;
1141
1142         shake =g_new0(network_mysqld_auth_challenge, 1);
1143
1144         shake->challenge =g_string_sized_new(20);
1145         shake->capabilities =
1146                 CLIENT_PROTOCOL_41 |
1147                 CLIENT_RESERVED2 |
1148                 0;
1149
1150
1151         return shake;
1152 }

1220
1221         if (shake->capabilities &CLIENT_SECURE_CONNECTION) {
1222                 err = err ||network_mysqld_proto_get_string_len(packet, &scramble_2, 12);
1223                 err = err ||network_mysqld_proto_skip(packet, 1);
1224         }
1225
1226         if (!err) {
1227                 /* process the data */
1228
1229                 if (3 !=sscanf(shake->server_version_str, "%d.%d.%d%*s", &maj,&min, &patch)) {
1230                         /* can't parse theprotocol */
1231
1232                         g_critical("%s:protocol 10, but version number not parsable", G_STRLOC);
1233
1234                         return -1;
1235                 }
1236
修改1221行为如下:
1220
1221         if (shake->capabilities & CLIENT_RESERVED2) {
1222                 err = err ||network_mysqld_proto_get_string_len(packet, &scramble_2, 12);
1223                 err = err ||network_mysqld_proto_skip(packet, 1);
1224         }
1225
1226         if (!err) {
1227                 /* process the data */
1228
1229                 if (3 !=sscanf(shake->server_version_str, "%d.%d.%d%*s", &maj,&min, &patch)) {
1230                         /* can't parse theprotocol */
1231
1232                         g_critical("%s:protocol 10, but version number not parsable", G_STRLOC);
1233
1234                         return -1;
1235                 }
1236

1312network_mysqld_auth_response *network_mysqld_auth_response_new() {
1313         network_mysqld_auth_response *auth;
1314
1315         auth =g_new0(network_mysqld_auth_response, 1);
1316
1317         /* we have to make surescramble->buf is not-NULL to get
1318          * the "empty string" andnot a "NULL-string"
1319          */
1320         auth->response =g_string_new("");
1321         auth->username =g_string_new("");
1322         auth->database =g_string_new("");
1323         auth->capabilities =CLIENT_SECURE_CONNECTION | CLIENT_PROTOCOL_41;
1324
1325         return auth;
1326 }
修改1323行为如下:
1312network_mysqld_auth_response *network_mysqld_auth_response_new() {
1313         network_mysqld_auth_response *auth;
1314
1315         auth =g_new0(network_mysqld_auth_response, 1);
1316
1317         /* we have to make surescramble->buf is not-NULL to get
1318          * the "empty string" andnot a "NULL-string"
1319          */
1320         auth->response =g_string_new("");
1321         auth->username =g_string_new("");
1322         auth->database =g_string_new("");
1323         auth->capabilities = CLIENT_RESERVED2 | CLIENT_PROTOCOL_41;
1324
1325         return auth;
1326 }

1378                 if (auth->capabilities& CLIENT_SECURE_CONNECTION) {
1379                         err = err ||network_mysqld_proto_get_lenenc_gstring(packet, auth->response);
1380                 } else {
1381                         err = err ||network_mysqld_proto_get_gstring(packet, auth->response);
1382                 }
1383
1384                 if (packet->offset !=packet->data->len) {
1385                         /* database isoptional and may include a trailing \0 char */
1386                         err = err ||network_mysqld_proto_get_gstring_len
修改1378行为如下:
1378                 if (auth->capabilities& CLIENT_RESERVED2) {
1379                         err = err ||network_mysqld_proto_get_lenenc_gstring(packet, auth->response);
1380                 } else {
1381                         err = err ||network_mysqld_proto_get_gstring(packet, auth->response);
1382                 }
1383
1384                 if (packet->offset !=packet->data->len) {
1385                         /* database isoptional and may include a trailing \0 char */
1386                         err = err ||network_mysqld_proto_get_gstring_len

viplugins/admin/admin-plugin.c
195NETWORK_MYSQLD_PLUGIN_PROTO(server_con_init) {
196         network_mysqld_auth_challenge*challenge;
197         GString *packet;
198
199         challenge =network_mysqld_auth_challenge_new();
200         challenge->server_version_str =g_strdup("5.0.99-agent-admin");
201         challenge->server_version     = 50099;
202         challenge->charset            = 0x08; /* latin1 */
203         challenge->capabilities       = CLIENT_PROTOCOL_41 |CLIENT_SECURE_CONNECTION | CLIENT_LONG_PASSWORD;
204         challenge->server_status      = SERVER_STATUS_AUTOCOMMIT;
205         challenge->thread_id          = 1;
修改203行为如下:
195NETWORK_MYSQLD_PLUGIN_PROTO(server_con_init) {
196         network_mysqld_auth_challenge*challenge;
197         GString *packet;
198
199         challenge =network_mysqld_auth_challenge_new();
200         challenge->server_version_str =g_strdup("5.0.99-agent-admin");
201         challenge->server_version     = 50099;
202         challenge->charset            = 0x08; /* latin1 */
203         challenge->capabilities       = CLIENT_PROTOCOL_41 | CLIENT_RESERVED2 | CLIENT_LONG_PASSWORD;
204         challenge->server_status      = SERVER_STATUS_AUTOCOMMIT;
205         challenge->thread_id          = 1;



6.重新编译安装
7.导入mysql5.7库文件
# echo '/usr/local/mysql5.7.16/lib' >> /etc/ld.so.conf
# ldconfig
8.启动atlas
# /usr/local/mysql-proxy/bin/mysql-proxyd test start



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-323066-1-1.html 上篇帖子: mysql导入表shell脚本 下篇帖子: mysql自动安装脚本
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表