tcpcopy引流测试前端
tcpcopy 0.8.0 安装:nginx
yum -y install libpcap-devel
web
tar xvf tcpcopy-0.8.0.tar.gz后端
cd tcpcopy-0.8.0服务器
./configure --enable-advanced --enable-pcaptcp
makeide
make install
测试
tcpcopy原理:server
tcpcopy client将request复制给tcpcopy server,tcpcopy server将response导向intercept作丢弃处理。ip
测试环境:
tcpcopy client:线上web服务器(后文用 ${tcpcopy_client} 表示)
tcpcopy server(intercept):测试环境server-A(后文用 ${tcpcopy_server} 表示)
测试web服务器:varnish集群 vip-A(前端varnish集群:${vip-A},后端nginx集群:${vip-B})
${tcpcopy_client} 运行
tcpcopy -x 80-10.20.10.137:80 -s 10.20.10.137 -i eth0 -l tcpcopy.log -d
${tcpcopy_server} 运行
iptables -A INPUT -p tcp -m tcp --dport 36524 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --sport 80 -j QUEUE
intercept -i eth0 -F 'tcp and src host ${vip-A} src port 80' -d