HA Proxy / Keepalived не перенаправляет трафик - PullRequest
0 голосов
/ 28 февраля 2019

Я действительно новичок в HAProxy, и Keepalived был крутой кривой обучения на этой неделе, но я думаю, что я почти достиг своей конечной цели, и я подозреваю, что мне не хватает действительно простого шага для достижения того, что мне нужно.Я был бы очень признателен за любую помощь, которую кто-то может мне дать.Проблема, с которой я сталкиваюсь, заключается в том, что балансировщик нагрузки, по-видимому, не перенаправляет трафик на серверы при использовании VIP.Я могу пинговать VIP, чтобы я знал его.Я смог выполнить команду curl http://192.168.5.42 и получить желаемый ответ от самого узла MASTER.Однако затем я попытался решить проблему и добавил файл HAProxy.xml в папку / etc / firewalld / services со следующими настройками, и теперь я не могу выполнить эту команду:

В моей лаборатории у меня есть следующееsetup

2 x RHEL 7.6 сервера с установленными HAProxy и Keepalived

2 x Windows 2016 IIS-серверы со страницей IIS по умолчанию с привязками на 80

RHEL-A Keepalived setup:

!Файл конфигурации для keepalived

global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}

vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.5.42 dev ens33 label ens33:100
}
}
virtual_server 192.168.5.42 80 {
delay_loop 10
protocol TCP
lb_algo rr

Use direct routing
lb_kind DR
persistence_timeout 7200

real_server 192.168.5.50 80 {
    weight 1
    TCP_CHECK {
      connect_timeout 5
      connect_port 80
    }
}

real_server 192.168.5.51 80 {
    weight 1
    TCP_CHECK {
      connect_timeout 5
      connect_port 80
    }
}
}

Настройка RHEL-A HAProxy

#---------------------------------------------------------------------

Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the ‘-r’ option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2

chroot      /var/lib/haproxy
pidfile     /var/run/haproxy.pid
maxconn     4000
user        haproxy
group       haproxy
daemon

# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------

common defaults that all the ‘listen’ and ‘backend’ sections will
use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000

#---------------------------------------------------------------------

main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
bind    192.168.5.42:80
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 192.168.5.50
server app2 192.168.5.51

Настройка RHEL-B Keepalived

! Configuration File for keepalived

global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}

vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.5.42 dev ens33 label ens33:100
}
}
virtual_server 192.168.5.42 80 {
delay_loop 10
protocol TCP
lb_algo rr

Use direct routing
lb_kind DR
persistence_timeout 7200

real_server 192.168.5.50 80 {
    weight 1
    TCP_CHECK {
      connect_timeout 5
      connect_port 80
    }
}

real_server 192.168.5.51 80 {
    weight 1
    TCP_CHECK {
      connect_timeout 5
      connect_port 80
    }
}
}

Настройка RHEL-B HAProxy

#---------------------------------------------------------------------

Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the ‘-r’ option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2

chroot      /var/lib/haproxy
pidfile     /var/run/haproxy.pid
maxconn     4000
user        haproxy
group       haproxy
daemon

# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------

common defaults that all the ‘listen’ and ‘backend’ sections will
use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000

#---------------------------------------------------------------------

main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
bind    192.168.5.42:80
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 192.168.5.50
server app2 192.168.5.51
...