ubuntu系统上OBclient无法用backspace

https://zhuanlan.zhihu.com/p/678874871

在ubuntu/debian系列的系统上使用源代码编译OBclient
1.下载obclient源代码

1
git clone git@github.com:oceanbase/obclient.git

这里下载必须使用git clone的方式,因为后面编译的时候还需要项目中的git信息编译前安装依赖

2.安装依赖(debian/ubuntu系统)

1
sudo apt-get install -y git cmake gcc make libssl-dev libncurses5-dev rpm g++ bison libbison-dev zlib1g-dev libgnutls28-dev libxml2-dev libssl-dev libevent-dev libaio-dev libcrack2-dev

3.修改obclient源代码里的cmake/ssl.cmake

本来这里应该修改CMakeLists.txt 的第371 行 传递参数 yes,但是不知为什么改了没生效,就直接改cmake/ssl.cmake文件了

直接在第46行,前面随便找个位置 加入了 SET(WITH_SSL “yes”)

4.复制ssl库文件

下面命令都是在obclient的源代码路径中执行

这里是编译时要依赖这两个文件,下面的路径是x86_64架构的路径,如果是arm架构,需要将路径中的x86_64换成aarch_64(不对的话自己用find查找一下这两个文件在哪)

1
2
3
mkdir -p deps/3rd/usr/local/oceanbase/deps/devel/lib/
cp /usr/lib/x86_64-linux-gnu/libcrypto.a deps/3rd/usr/local/oceanbase/deps/devel/lib/
cp /usr/lib/x86_64-linux-gnu/libssl.a deps/3rd/usr/local/oceanbase/deps/devel/lib/

5.构建

./build.sh

6.获取OBclient可执行文件

构建成功后,obclient会保存在 ./client 文件夹下

我最终是在debian系统上先用前面rpm转换出来的deb包安装上obclient,然后将重新编译出的这个obclient拿去替换/u01/obclient/bin/中安装的.

使用vscode debug调试oceanbase

在vscode中安装下面插件
Alt text
编辑或添加 .vscode/launch.json

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
{
"version": "0.2.0",
"configurations": [

{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "/root/.obd/repository/oceanbase-ce/4.1.0.1/oceanbase-ce/bin/observer",//根据自己情况修改
"processId": "${input:FindPID}",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"sourceFileMap": {
"./build_debug/src/sql/./src/sql": {
"editorPath": "${workspaceFolder}/src/sql",
"useForBreakpoints": true
}
}
}
],
"inputs": [
{
"id": "FindPID",
"type": "command",
"command": "shellCommand.execute",
"args": {
"command": "ps -aux | grep /bin/observer | grep -v grep | awk '{print $2}'",
"description": "Select your observer PID",
"useFirstResult": true,
}
}
]
}

注:因为oceanbase有很多后台任务,会定时的执行SQL,所以调试时设置的断点有可能会命中后台任务执行的SQL,建议使用条件断点

debug启动!