haproxy 配置
openstack的api組件酣藻,horizon祭衩,rabbitmq management等用用Http協(xié)議作為接口交互協(xié)議的組件乃戈。
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協(xié)議荒辕,7層負(fù)載均衡
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地址進(jìn)行負(fù)載均衡策略策泣,即同一IP地址的所有請求都發(fā)送到同一服務(wù)器, 默認(rèn)是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協(xié)議的處理
http-request set-header X-Forwarded-Proto https if { ssl_fc } #針對https協(xié)議的處理
server controller01 192.168.102.15:6080 check inter 2000 rise 2 fall 5
mariadb數(shù)據(jù)庫的配置膛檀,默認(rèn)配置為mode tcp锰镀, 這個(gè)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協(xié)議,4層負(fù)載均衡
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配置
配置文件如下:這里是單個(gè)keepalived節(jié)點(diǎn)的配置情況泳炉,生產(chǎn)環(huán)境可配置兩個(gè)以上
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
}
}