haproxy 配置
openstack的api组件,horizon,rabbitmq management等用用Http协议作为接口交互协议的组件。
defaults
log global
mode http
option redispatch
option httplog
option forwardfor
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout check 10s
listen stats
bind 192.168.102.22:1984
mode http # http协议,7层负载均衡
stats enable
stats uri /
stats refresh 15s
stats realm Haproxy\ Stats
stats auth openstack:Heso5GZoRSMRTN9KKygArOcyj2MBpH0cq5k0QCkd
listen rabbitmq_management
bind 192.168.102.47:15672
server controller01 192.168.102.15:15672 check inter 2000 rise 2 fall 5
listen keystone_internal
bind 192.168.102.47:5000
http-request del-header X-Forwarded-Proto if { ssl_fc }
server controller01 192.168.102.15:5000 check inter 2000 rise 2 fall 5
listen keystone_admin
bind 192.168.102.47:35357
http-request del-header X-Forwarded-Proto if { ssl_fc }
server controller01 192.168.102.15:35357 check inter 2000 rise 2 fall 5
listen glance_registry
bind 192.168.102.47:9191
server controller01 192.168.102.15:9191 check inter 2000 rise 2 fall 5
listen glance_api
bind 192.168.102.47:9292
server controller01 192.168.102.15:9292 check inter 2000 rise 2 fall 5
listen nova_api
bind 192.168.102.47:8774
http-request del-header X-Forwarded-Proto if { ssl_fc }
server controller01 192.168.102.15:8774 check inter 2000 rise 2 fall 5
listen horizon
bind 192.168.102.47:80
balance source # 让HAProxy按照客户端的IP地址进行负载均衡策略,即同一IP地址的所有请求都发送到同一服务器, 默认是roundrobin.
http-request del-header X-Forwarded-Proto if { ssl_fc }
server controller01 192.168.102.15:80 check inter 2000 rise 2 fall 5
listen nova_novncproxy
bind 192.168.102.47:6080
http-request del-header X-Forwarded-Proto if { ssl_fc } #针对http协议的处理
http-request set-header X-Forwarded-Proto https if { ssl_fc } #针对https协议的处理
server controller01 192.168.102.15:6080 check inter 2000 rise 2 fall 5
mariadb数据库的配置,默认配置为mode tcp, 这个mysql是用galera.conf模式做高可用的。
defaults
log global
mode http
option redispatch
option httplog
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout check 10s
listen mariadb
mode tcp # TCP协议,4层负载均衡
timeout client 3600s
timeout server 3600s
option tcplog
option tcpka
option mysql-check user haproxy post-41
bind 192.168.102.47:3306
server controller01 192.168.102.15:3306 check inter 2000 rise 2 fall 5
Keepalived配置
配置文件如下:这里是单个keepalived节点的配置情况,生产环境可配置两个以上
vrrp_script check_alive {
script "/check_alive.sh"
interval 2
fall 2
rise 10
}
vrrp_instance kolla_internal_vip_51 {
state BACKUP
nopreempt
interface eno1
virtual_router_id 51
priority 1
advert_int 1
virtual_ipaddress {
192.168.102.47 dev eno1
}
authentication {
auth_type PASS
auth_pass xqNevnru1y6pO3kQnfXTcRPzJ6b2oQCtT4lbvm1t
}
track_script {
check_alive
}
}