TCPCOPY+ intercept这两个模拟流量转发倒简单。
但,想实现一个mysql-replay-module模块时,失败了。(我现在仔细想想,这个方案,在我们现在的场景里,实用性不大,但弄好点专业些。)
https://github.com/session-replay-tools/mysql-replay-module
https://github.com/session-replay-tools/tcpcopy
安装=================================
一,在assistant server上安装intercept:
- git clone git://github.com/session-replay-tools/intercept.git
- cd intercept
- ./configure --with-resp-payload
- make
- make install
二,在ONLINE SERVER上安装TCPCOPY:
- git clone git://github.com/session-replay-tools/tcpcopy.git
- cd tcpcopy
- git clone git://github.com/session-replay-tools/mysql-replay-module.git
- ./configure --set-protocol-module=mysql-replay-module
- make
- make install
配置====================================
一,在TARGET SERVER上配置路由:
For example:
Assume 10.110.12.18 is the IP address of the assistant server and
10.110.12.15 is the MySQL client IP address. We set the following route
command to route all responses to the 10.110.12.15 to the assistant server.
route add -host 10.110.12.15 gw 10.110.12.18
二,在assistant server上配置端口过滤:
For example:
./intercept -i eth0 -F ‘tcp and src port 3306‘ -d
intercept will capture response packets of the TCP based application which
listens on port 3306 from device eth0
三,在ONLINE SERVER上启动TCPCOPY:
a) set user password pair in conf/plugin.conf in the installion directory
Format:
user [email protected],[email protected],...,[email protected];
For example:
user [email protected];
b) start tcpcopy
./tcpcopy -x localServerPort-targetServerIP:targetServerPort -s <intercept server,>
For example(assume 10.110.12.17 is the IP address of the target server):
./tcpcopy -x 3306-10.110.12.17:3306 -s 10.110.12.18
tcpcopy would capture MySQL packets(assume MySQL listens on 3306 port) on current
server, do the necessary modifications and send these packets to the target port
‘3306‘ on ‘10.110.12.17‘(the target MySQL), and connect 10.110.12.18 for asking
intercept to pass response packets to it.
最后,一份转两份,真实服务器上有,测试服务器上也有流量。用过压力或冒烟测试,蛮好的。
时间: 2024-10-14 21:18:20