Moonshine's Blog

日拱一卒无有尽,功不唐捐终入海

本地调试proxysql

1. 构建镜像

Dockerfile + 构建镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
FROM centos:7

LABEL description="Container for dev & debug"

# 安装依赖
RUN yum install -y automake bzip2 cmake make gcc-c++ gcc git openssl openssl-devel gnutls gnutls-devel libtool patch openssh-server perl-IPC-Cmd
RUN yum install -y gdb-gdbserver which

# 配置ssh服务
RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && \
echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config && \
echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config && \
echo 'root:root' | chpasswd && \
ssh-keygen -A

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
1
docker build -t proxysqldebug:v1 .

2. 运行容器

1
2
3
docker run -d -p 2222:22 --security-opt seccomp:unconfined -v $PWD:/home/luzhangting001/proxysql --name proxysqldev proxysqldebug:v1

# 后面容器stop + start 不要在重启,如下图
image-20211229121528631

3. 启动debug

配置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
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/home/luzhangting001/proxysql/src/proxysql",
"args": [
"--foreground",
"--debug",
"--config",
"/home/luzhangting001/proxysql/src/proxysql.cfg",
"--initial"
],
"stopAtEntry": true,
"cwd": "/home/luzhangting001/proxysql",
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "/usr/bin/ssh",
"pipeArgs": [
"root@localhost",
"-p",
"2222"
],
"pipeCwd": ""
},
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"sourceFileMap": {
"/home/luzhangting001/proxysql": "${workspaceFolder}"
}
}
]

启动报错:因为之前弄过,ssh报错了

image-20211229121827990

将known_hosts里面的相关信息删除, 其实我不知道是不是必须这么做,可能不是必须的

image-20211229122615654

将本机的公钥上传

1
ssh-copy-id -p 2222 root@localhost

vscode里面启动

image-20211229153334425