Saved it! Environment Preparation 1. Start four virtual machines (centos is used as an example here), the ip is: 192.168.130 192.168.132 192.168.128 192.168.129 2. Install haproxy Open the external network access rights for the corresponding ports 130 and 132 of these two machines
Install haproxy on machines 130 and 132 respectively:
After both machines are installed, perform file configuration and modify the configuration file on 132:
Copy the configuration file to the same directory on the 130 server and perform the following operations on the 130 server:
The haproxy installation and configuration of the two servers are complete. 3. Install keepalived on 132 and 130 respectively: First check to install openssl-devel
Create a keepalived installation directory and download and install it:
After both machines are installed, configure keepalived (132 machines):
Create a detection file
Copy the configuration and detection files to another server and perform the following operations on 130:
Here keepalived is installed. 4. Install the tomcat service environment Copy two tomcats in 128, one with port 8080 and one with port 8081: a. Modify the tomcat port, which is too low. Execute the operation. b. Modify the tomcat page in tomcat port 8080 to facilitate testing and verification:
The js file will modify the "js location" content, indicating that this js file comes from the 8080 port service of the 128 host. c. Make similar changes in tomcat port 8081:
Similarly, copy two tomcats on the 129 server, one with port 8080 and the other with port 8081. When modifying the tomcat file, just change ip 128 to 129. Now the environment is installed. Run 4 tomcats Run haproxy: service haproxy start Run keepalived:
Open the page to view the haproxy monitoring page: http://192.168.230.132/haproxy, http://192.168.230.130/haproxy Through monitoring, you can see the number of visits and other messages Refresh the page multiple times by visiting http://192.168.230.200 or http://192.168.230.201: By observing the changes in the source of the js file and the page, we can see that the js file comes from the server with port 8080 of 128 and 129, and the page comes from the server with port 8081 of 128 and 129. Describes the different haproxy service rules used for page and static file loads Visit http://192.168.230.200, http://192.168.230.201. By monitoring the data changes on the page, we can find that 200 is forwarded by the 132 server, and access 201 is forwarded by 130 In actual scenarios, when accessing dynamic resources, the 200 address is used, and when accessing static resources, the 201 address is used. By shutting down tomcat or haproxy, you can see the server switching. This achieves dual-master backup, ensuring high availability while also improving server utilization. Full text from: http://www.javaseo.cn/article/63/ |
>>: Java Photo Station Beauty Installation Tutorial
Telasera, a South African hosting provider, was f...
ServNode is a newly established hosting provider....
PieLayer, old and stable. Here are some good pack...
CloudCone is a relatively active hosting provider...
ComputeLabs is a newly established British busine...
Details: AlphaRacks: $7/year/1GB memory/20GB spac...
ChicagoVPS, dedicated servers have a 30% discount...
25% off resale hosting Reseller Hosting / r25perc...
Host features: Space: 200MB Traffic limit: 300M p...
Hostpapa is a multinational hosting company locat...
ION is a new sub-brand of the old merchant Krypt....
PieLayer, old and stable. The latest offers are a...
HKServerSolution, a Chinese hosting provider, fea...
VPSlices, registered in England in May 2017, curr...
HostFav, a newly established hosting provider, pr...