obproxy 源码编译以及一些问题整理-暂未编译成功
尝试自己编译下oceanbase 的obproxy 并记录下一些问题,目前是暂未编译成功,因为是openssl 版本包的问题
环境说明
基于了Rocky Linux release 8.8, 同时obproxy 使用了4.2.1 版本的
- 构建参考命令
这个官方已经提供了,主要就是init debug,make
sh build.sh init
sh build.sh config debug
sh build.sh make
- 配置oceanbase 官方提供的yum 愿
curl http://mirrors.aliyun.com/oceanbase/OceanBase.repo
依赖包
- mariadb mysql 依赖
make all-am
make[3]: 进入目录“/opt/ob/obproxy-4.2.1/src”
CXX lib/ob_worker.lo
CXX obproxy/ob_proxy_init.lo
In file included from ./lib/ob_errno.h:15,
from ./lib/oblog/ob_log_print_kv.h:20,
from ./lib/oblog/ob_log.h:48,
from ./lib/ob_define.h:26,
from lib/ob_worker.h:18,
from lib/ob_worker.cpp:13:
./lib/mysql_errno.h:16:10: fatal error: mariadb/mysqld_error.h: No such file or directory
16 | #include <mariadb/mysqld_error.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [Makefile:6268:lib/ob_worker.lo] 错误 1
make[3]: *** 正在等待未完成的任务
In file included from ./lib/ob_errno.h:15,
from ./lib/oblog/ob_log_print_kv.h:20,
from ./lib/oblog/ob_log.h:48,
from ./lib/ob_define.h:26,
from obproxy/ob_proxy_main.h:17,
from obproxy/ob_proxy_init.cpp:32:
./lib/mysql_errno.h:16:10: fatal error: mariadb/mysqld_error.h: No such file or directory
16 | #include <mariadb/mysqld_error.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~
linux 指定include 文件
buid.sh
function sw()
{
export DEP_DIR;
export TOOLS_DIR;
export RUNTIME_DIR;
export DEP_VAR=$DEP_DIR/var/;
/sbin/ldconfig -n $DEP_DIR/lib;
export LD_LIBRARY_PATH=$DEP_DIR/lib:$DEP_VAR/usr/local/lib64:$DEP_VAR/usr/local/lib:$DEP_VAR/usr/lib64:$DEP_VAR/usr/lib:$DEP_VAR/lib64:/usr/lib/x86_64-linux-gnu;
export LIBRARY_PATH=$DEP_DIR/lib:$DEP_VAR/usr/local/lib64:$DEP_VAR/usr/local/lib:$DEP_VAR/usr/lib64:$DEP_VAR/usr/lib:/usr/lib/x86_64-linux-gnu;
export CPLUS_INCLUDE_PATH=$DEP_DIR/include:${RUNTIME_DIR}/include:$DEP_VAR/usr/local/include:$DEP_VAR/usr/include:$DEP_VAR/devel/include:/usr/include/x86_64-linux-g$
export C_INCLUDE_PATH=$DEP_DIR/include:${RUNTIME_DIR}/include:/usr/include/x86_64-linux-gnu:/usr/local/oceanbase/deps/devel/include;
export PATH=$DEP_DIR/bin:$TOOLS_DIR/bin:$PATH;
}
- openssl 依赖
这种安装是有问题的,继续构建后边会有一些错误,实际上github 也有一个简单的说明,但是估计版本太老了,信息不太对,应该使用oceanbase 自己构建的openssl-static 开发包
../deps/easy/src/io/easy_io_struct.h:5:10: fatal error: openssl/ssl.h: No such file or directory
5 | #include <openssl/ssl.h>
| ^~~~~~~~~~~~~~~
安装依赖
yum install -y openssl-devel
- sqlite3 依赖
In file included from lib/allocator/ob_malloc.cpp:18:
../src/obproxy/obutils/ob_proxy_config.h:16:10: fatal error: sqlite/sqlite3.h: No such file or directory
16 | #include <sqlite/sqlite3.h>
| ^~~~~~~~~~~~~~~~~~
安装依赖
yum install -y libsq3-devel
mkdir -p /usr/include/sqlite
ln -s /usr/include/sqlite3.h /usr/include/sqlite/sqlite3.h
- ob sql 解析依赖
../src/obproxy/obutils/ob_proxy_sql_parser.h:29:10: fatal error: ob_sql_parser.h: No such file or directory
29 | #include <ob_sql_parser.h>
安装
yum install -y oceanbase-ce-utils
配置include (build.sh ) 如下
/home/admin/oceanbase/include/ob_sql_parser.h
function sw()
{
export DEP_DIR;
export TOOLS_DIR;
export RUNTIME_DIR;
export DEP_VAR=$DEP_DIR/var/;
/sbin/ldconfig -n $DEP_DIR/lib;
export LD_LIBRARY_PATH=$DEP_DIR/lib:$DEP_VAR/usr/local/lib64:$DEP_VAR/usr/local/lib:$DEP_VAR/usr/lib64:$DEP_VAR/usr/lib:$DEP_VAR/lib64:/usr/lib/x86_64-linux-gnu;
export LIBRARY_PATH=$DEP_DIR/lib:$DEP_VAR/usr/local/lib64:$DEP_VAR/usr/local/lib:$DEP_VAR/usr/lib64:$DEP_VAR/usr/lib:/usr/lib/x86_64-linux-gnu;
export CPLUS_INCLUDE_PATH=$DEP_DIR/include:${RUNTIME_DIR}/include:$DEP_VAR/usr/local/include:$DEP_VAR/usr/include:$DEP_VAR/devel/include:/usr/include/x86_64-linux-gnu:/usr/local/oceanbase/deps/devel/include:/home/admin/oceanbase/include/;
export C_INCLUDE_PATH=$DEP_DIR/include:${RUNTIME_DIR}/include:/usr/include/x86_64-linux-gnu:/usr/local/oceanbase/deps/devel/include:/home/admin/oceanbase/include/;
export PATH=$DEP_DIR/bin:$TOOLS_DIR/bin:$PATH;
}
问题
In file included from /home/admin/oceanbase/include/ob_sql_parser.h:17,
from ../src/obproxy/obutils/ob_proxy_sql_parser.h:29,
from ../src/obproxy/obutils/ob_config_processor.h:41,
from ../src/obproxy/omt/ob_cpu_table_processor.h:34,
from ../src/obproxy/iocore/net/ob_net_accept.h:47,
from ../src/obproxy/iocore/net/ob_net.h:59,
from ../src/obproxy/proxy/client/ob_client_utils.h:16,
from ../src/obproxy/proxy/client/ob_raw_mysql_client.h:20,
from obproxy/proxy/client/ob_mysql_proxy.h:18,
from obproxy/ob_proxy.h:20,
from obproxy/ob_proxy_main.h:20,
from obproxy/main.cpp:17:
/home/admin/oceanbase/include/parse_node.h:403:17: error: conflicting declaration of C function ‘uint64_t parsenode_hash(const ParseNode*, int*)’
403 | extern uint64_t parsenode_hash(const ParseNode *node, int *ret);
| ^~~~~~~~~~~~~~
In file included from ./lib/hash/ob_hashmap.h:20,
from ../src/obproxy/obutils/ob_proxy_config.h:17,
from ../src/obproxy/obutils/ob_proxy_config_manager.h:16,
from obproxy/obutils/ob_proxy_table_processor.h:20,
from obproxy/ob_proxy.h:18,
from obproxy/ob_proxy_main.h:20,
from obproxy/main.cpp:17:
./lib/hash/ob_hashutils.h:49:17: note: previous declaration ‘uint64_t parsenode_hash(const _ParseNode*)’
49 | extern uint64_t parsenode_hash(const _ParseNode *node);
| ^~~~~~~~~~~~~~
In file included from /home/admin/oceanbase/include/ob_sql_parser.h:17,
from ../src/obproxy/obutils/ob_proxy_sql_parser.h:29,
from ../src/obproxy/obutils/ob_config_processor.h:41,
from ../src/obproxy/omt/ob_cpu_table_processor.h:34,
from ../src/obproxy/iocore/net/ob_net_accept.h:47,
from ../src/obproxy/iocore/net/ob_net.h:59,
from ../src/obproxy/proxy/client/ob_client_utils.h:16,
from ../src/obproxy/proxy/client/ob_raw_mysql_client.h:20,
from obproxy/proxy/client/ob_mysql_proxy.h:18,
from obproxy/ob_proxy.h:20,
以上的依赖不太对,应该使用yum install -y oceanbase-ce-devel
然后移除以上的include 配置,因为这个安装的是可以直接include 查找到的
- mysql client 依赖
n file included from ./lib/mysqlclient/ob_mysql_statement.h:16,
from ./common/mysql_proxy/ob_mysql_proxy.h:18,
from ./share/config/ob_system_config.h:18,
from ./share/config/ob_server_config.h:17,
from share/ob_server_status.h:20,
from share/ob_server_status.cpp:14:
./lib/mysqlclient/ob_mysql_result_impl.h:15:10: fatal error: mysql.h: No such file or directory
15 | #include <mysql.h>
| ^~~~~~~~~
compilation terminated.
make[3]: *** [Makefile:6268:share/ob_server_status.lo] 错误 1
配置依赖,因为已经安装了
cd /usr/local/oceanbase/deps/devel/include
cp -rf mariadb/* .
- ssl 问题
obproxy/iocore/net/ob_ssl_processor.cpp: In member function ‘int oceanbase::obproxy::net::ObSSLProcessor::init()’:
obproxy/iocore/net/ob_ssl_processor.cpp:42:44: error: invalid conversion from ‘void* (*)(size_t)’ {aka ‘void* (*)(long unsigned int)’} to ‘void* (*)(size_t, const char*, int)’ {aka ‘void* (*)(long unsigned int, const char*, int)’} [-fpermissive]
42 | CRYPTO_set_mem_functions(ObSSLProcessor::malloc_for_ssl, ObSSLProcessor::realloc_for_ssl,
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
| |
| void* (*)(size_t) {aka void* (*)(long unsigned int)}
In file included from /usr/include/openssl/comp.h:16,
from /usr/include/openssl/ssl.h:17,
from ../src/obproxy/iocore/net/ob_ssl_processor.h:16,
from obproxy/iocore/net/ob_ssl_processor.cpp:15:
/usr/include/openssl/crypto.h:257:17: note: initializing argument 1 of ‘int CRYPTO_set_mem_functions(void* (*)(size_t, const char*, int), void* (*)(void*, size_t, const char*, int), void (*)(void*, const char*, int))’
257 | void *(*m) (size_t, const char *, int),
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
obproxy/iocore/net/ob_ssl_processor.cpp:42:76: error: invalid conversion from ‘void* (*)(void*, size_t)’ {aka ‘void* (*)(void*, long unsigned int)’} to ‘void* (*)(void*, size_t, const char*, int)’ {aka ‘void* (*)(void*, long unsigned int, const char*, int)’} [-fpermissive]
42 | CRYPTO_set_mem_functions(ObSSLProcessor::malloc_for_ssl, ObSSLProcessor::realloc_for_ssl,
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
| |
| void* (*)(void*, size_t) {aka void* (*)(void*, long unsigned int)}
In file included from /usr/include/openssl/comp.h:16,
from /usr/include/openssl/ssl.h:17,
from ../src/obproxy/iocore
实际应该安装yum install -y devdeps-openssl-static
但是有如下错误
file /usr/local/oceanbase/deps/devel from install of devdeps-openssl-static-1.1.1u-22023100710.el8.x86_64 conflicts with file from package devdeps-mariadb-connector-c-3.1.12-12022100422.el8.x86_64
file /usr/local/oceanbase/deps/devel/include from install of devdeps-openssl-static-1.1.1u-22023100710.el8.x86_64 conflicts with file from package devdeps-mariadb-connector-c-3.1.12-12022100422.el8.x86_64
file /usr/local/oceanbase/deps/devel/lib from install of devdeps-openssl-static-1.1.1u-22023100710.el8.x86_64 conflicts with file from package devdeps-mariadb-connector-c-3.1.12-12022100422.el8.x86_64
file /usr/local/oceanbase/deps/devel/lib/pkgconfig from install of devdeps-openssl-static-1.1.1u-22023100710.el8.x86_64 conflicts with file from package devdeps-mariadb-connector-c-3.1.12-12022100422.el8.x86_64
尝试解决
yum install --downloadonly --downloaddir=/opt/ob devdeps-openssl-static
rpm -ivh devdeps-openssl-static-1.1.1u-22023100710.el8.x86_64.rpm --force
安装的位置
/usr/local/oceanbase/deps/devel/include/openssl/ 因为已经配置include了直接继续构建
继续构建发现还是如上的错误
说明
目前基于源码构建还是比较费事的,提供的版本以及文档不全,需要自己踩坑,目前暂时没编译成功
参考资料
https://github.com/oceanbase/obproxy
https://github.com/oceanbase/oceanbase-proxy-doc/blob/V3.1.0/zh-CN/3.installation-and-deployment/3.compile-odp.md
https://mirrors.aliyun.com/oceanbase/development-kit/el/8/x86_64/?spm=a2c6h.25603864.0.0.5cc479dfIUvjmG