Linux server learning ---- haproxy + keepalived

Experiment requires four virtual machines, do the two servers, two proxy servers do

www1: ip: 10.30.40.11 hk1: Agent: 10.30.40.13 (hk1.netdj.net)

www2: ip 10.30.40.12 hk2: Agent: 10.30.40.14 (hk2, netdj.net)

First to set up two sites as the back end, the following test:

 

 On hk1 and hk2 installation services (the same on both sides)

Haproxy edit the main configuration file on hk1

 

 

 

 Keepalived into the main configuration file

 

 

Delete all redundant

Restart the service and turn off the firewall

 

 

 

 

 

 Check whether the virtual address into force

 

 We just find a machine to do the test

We can see automatically jump to visit our website www2 two back www1 and after the virtual address pool

 

 

 

The hk1 configuration files directly covered hk2 profile

Hk2 into the server we do the same operation:

Haproxy.conf no configuration, and has been covered.

Look:

 

 

Keepalived service a little change

MASTER represents the primary server

BACKUP representatives standby server

 

 

Modify the master became Backup , delete all redundant.

Now we have to test the load balancing

First, we test the virtual address is not dynamic drift

Validated in windows under cmd in

This is both load balancing host Mac Address

 

 Now on the virtual address 10.30.40.13

 

 Keepalived service stopped in at 10.30.40.13

 

 Restart the service and turn in at 10.30.40.14

 

 

Now when I turned off the Hk1 server, so haproxy service and keepalived service is not in force

(You can disable the service directly, it is I just happened to be turned off)

 

 

Continued access to the virtual address

You can see haproxy and keepalived service or operating state

 

 

 

 

 

 Configure the client automatically jump to https when using http access;

Guess you like

Origin www.cnblogs.com/hgd3279137708/p/12111440.html
Recommended