Precautions :
This is the 0.9 series, not the 1.0 series.
On -Line system Introduction:
Suppose we have online machine A, online machine B, online machine c three servers, of which online machine A, which runs Nginx (80-port) business system for end user access, while Nginx will also access the intranet in online machine B above AdServer (port 11311) business, Online machine C runs the pseudo online business msyql (using Sysbench Simulation) test system:
We have a test server a,b.
One of the above runs the following systems:
1) Nginx Business System (Port 18080)
2 AdServer Business (process is asyn_server, port is 11811)
3 MySQL (3306-Port)
Here Nginx will access the asyn_server process, MySQL is an independent application.
Objective:
We need to import the Nginx application and the Asyn_server application of the online system into test machine A, and also copy the MySQL request in the online machine C to test machine A.
How to set up a route in test machine A:
For test machine B, it is the place where the intercept is run to capture the response of MySQL in test machine A, the response of Nginx and the partial response of Asyn_server (because nginx in test machine A also accesses Asyn_server, This part of the response should not be routed to test machine B.
Therefore, the application of the above test machine A has extranet applications (Nginx) and intranet applications (Asyn_server and MySQL applications), how to set the route. (This is the key to routing settings)
1 Set nginx response route: test Machine A nginx out of the network card, we set the following:
Route del default GW original gateway IP address
Route add default GW machine B's extranet IP address
This setting, if the extranet response does not eventually match the route, will go to the default gateway, that is, to the test machine B to go (note: Requests from the same network segment, if the use of external network address access, its response will not go to the default route).
So the Nginx response route is set up.
2 Set the response route for Asyn_server:
As the online asyn_server is accessed by Nginx, we assume that only the Nginx on the online machine A is accessible, and that the intranet address (not localhost) is used to access the asyn_server.
We set the route as follows:
Intranet IP address of Route add-host online machine a GW test machine B Intranet IP Address
Such a replicated Asyn_server request to the test machine A, the response will flow to test machine B, but test machine a nginx access Asyn_server request, will return to Nginx.
3 Set MySQL response route: because we test machine A above the MySQL, DNS query extranet, so we must find the IP address of access, we assume to access the IP address of the machine D network address, need to open this IP address permissions:
Route add-host Machine D IP Extranet address GW original Gateway IP address
When this is done, the MySQL request copy is in my order.
MySQL request itself access to the intranet approach, and MySQL's request client IP address for the online machine C, then set the route as follows:
Route add-host Online IP address GW Test machine B Intranet IP Address
Run:
After testing machine A's routing is set up, start Nginx application, Asyn_server and MySQL application, wait for the request to copy over.
We start multiple intercept instances in test machine B, capturing nginx responses, Asyn_server responses, and MySQL responses
Capture MySQL response (./configure--enable-advanced--enable-pcap--enable-mysql)
sudo./intercept-f ' TCP and SRC Port 3306 '-P 36525-i eth0-d
Capture Nginx response (./configure--enable-advanced--enable-pcap)
sudo./intercept-f ' TCP and SRC Port 18080 '-P 36526-i eth1-d
Capture Asyn_server response (./configure--enable-advanced--enable-pcap)
sudo./intercept-f ' TCP and SRC port 11811 '-I eth0-d
of course intercept can also run only one instance (-F parameter settings filter the capture condition of the response package), there is no need to apply a intercept instance
We copy nginx request (./configure--enable-advanced--enable-pcap) in online machine A: sudo./tcpcopy-x 80-Test machine A's extranet IP address: 18080-p 36526-s test machine B Intranet IP address-i eth0-d
Since the online nginx front has LVS, here request to walk intranet network card
Our online machine b copies the Asyn_server request (./configure--enable-advanced--enable-pcap):
sudo./tcpcopy-x 11311-The intranet IP address of the test machine A: 11811-S IP address of the test machine B-I eth0-d
Capture intranet request from Eth0
We copy the MySQL request (./configure--enable-advanced--enable-pcap--enable-mysql) in the online machine C:
sudo./tcpcopy-x 3306-Test Machine A's intranet IP address: 3306-u root@ password-s test machine B Intranet IP address-p 36525-i lo-d
Capture MySQL request from Lo
Effect Demo
After the copy, we screenshot as follows:
Online machine A, copy nginx request, run Tcpcopy
Online machine B, copy asyn_server request
Online machine c, copy MySQL request
Test The Intercept on machine B.
Test the various services above machine A: