问题
I have two servers both having Apache httpd with identical configurations Server1 and Server2. I want to create active and passive setup for these servers.
- Server1(lbserver.my.com) IP:192.168.10.88 (Active)
- Server2(lbserver.my.com) IP:192.168.10.89 (Passive)
Server1 should respond to http requests. In case Server1 goes down then Server2 should become Active server and respond to http requests. Can anyone suggest how to achieve this. I tried this with keepalived configured on both the servers with Virtual IP:192.168.20.90 for both of them However I am not able to check if httpd is running on Server1 in keepalived.conf. The passive server i.e Server2 only responds to http requests only if Server1 goes off the network. My configuration in keepalived.conf is as follows.
vrrp_script chk_haproxy{
script "killall -0 httpd"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.10.90
}
track_script{
chk_haproxy
}
}
I also tried with script "pidof httpd"
I want passive server to start responding once httpd on server1 goes down. Can anyone suggest me on this. Also correct me if any other approach needs to be followed for this setup. Any help will be appreciated
来源:https://stackoverflow.com/questions/42791699/how-to-configure-apache-with-active-passive-setup