sudo dnf install haproxy
vim /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
bind *:81
default_backend app
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static 127.0.0.1:4331 check
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server app1 172.27.0.254:80 check
server app2 172.27.0.32:80 check
bind 포트 : Apache에서 80을 사용하므로 다른 포트로 설정
backend server : Apache를 이중화할 예정이므로 Apache 서버 IP를 입력
Apache서버 모두 동일하게 설정해준다
sudo dnf install keepalived
vim /etc/keepalived/keepalived.conf
마스터 서버
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.1.100 # VIP 설정
}
}
백업 서버
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.100 # VIP 설정
}
}
sudo systemctl restart httpd
sudo systemctl restart haproxy
sudo systemctl restart keepalived