openstack-pike-HA环境部署-集群部署+haproxy
邓高韵
2023-12-01
1、集群安装配置(pacemaker三个节点执行)
yum install -y lvm2 cifs-utils quota psmisc pcs pacemaker corosync fence-agents-all resource-agents
2、启动服务并且设置开机自启动(三个节点执行)
systemctl start pcsd
systemctl enable pcsd
3、修改管理员密码(三个节点执行)
echo 123456 | passwd --stdin hacluster
4、建立认证(三个节点执行)
pcs cluster auth controller1 controller2 controller3 -u hacluster -p 123456 --force
5、配置集群(三个节点执行)
pcs cluster setup --force --name openstack-cluster controller1 controller2 controller3
6、启动集群并且设置开机自启动
pcs cluster start --all
pcs cluster enable --all
7、查看集群状态
pcs status cluster
8、查看corosync状态
pcs status corosync
9、禁用stonith和quorum
pcs property set stonith-enabled=false
pcs property set no-quorum-policy=ignore
10、配置
pcs property set default-resource-stickiness="INFINITY"
pcs property list
验证
crm_verify -L -V
pcs property set pe-warn-series-max=1000 \
pe-input-series-max=1000 \
pe-error-series-max=1000 \
cluster-recheck-interval=5min
11、设置浮动IP
pcs resource create vip ocf:heartbeat:IPaddr2 ip=192.168.148.200 cidr_netmask=24 op monitor interval=30s
####################################################################################################################
安装haproxy
1、安装haproxy软件包、并且设置开机自启动
yum install -y haproxy
systemctl enable haproxy
2、编辑配置文件
vim /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# 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.10.10.48.111 /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 keystone-in
# bind 10.10.48.111:5000
# mode http
# option httplog
# log global
# default_backend keystone-pool
#
#backend keystone-pool
# balance leastconn
# server keystone1 172.16.16.100:5000 cookie 1 weight 5 check inter 2000 rise 2 fall 3
#
listen Stats *:10000
mode http
stats enable
stats uri /
stats refresh 5s
stats show-node
stats show-legends
stats hide-version
listen horizon
bind 192.168.148.200:80
balance source
#capture cookie vgnvisitor= len 32
#cookie SERVERID insert indirect nocache
mode http
option forwardfor
option httpchk
option httpclose
option httplog
# rspidel ^Set-cookie:\ IP=
# timeout client 3h
# timeout server 3h
server 192.168.148.91 192.168.148.91:80 cookie 192.168.148.91 check inter 2000 fall 3
server 192.168.148.89 192.168.148.89:80 cookie 192.168.148.89 check inter 2000 fall 3
server 192.168.148.88 192.168.148.88:80 cookie 192.168.148.88 check inter 2000 fall 3
listen keystone-1
bind 192.168.148.200:5000
option httpchk
option httplog
option httpclose
server 192.168.148.91 192.168.148.91:5000 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.89 192.168.148.89:5000 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.88 192.168.148.88:5000 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
listen keystone-2
bind 192.168.148.200:35357
option httpchk
option httplog
option httpclose
server 192.168.148.91 192.168.148.91:35357 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.89 192.168.148.89:35357 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.88 192.168.148.88:35357 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
listen nova-api-1
bind 192.168.148.200:8774
option httpchk
option httplog
option httpclose
server 192.168.148.91 192.168.148.91:8774 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.89 192.168.148.89:8774 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.88 192.168.148.88:8774 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
listen nova-novncproxy
bind 192.168.148.200:6080
balance roundrobin
option httplog
server 192.168.148.91 192.168.148.91:6080 check
server 192.168.148.89 192.168.148.89:6080 check
server 192.168.148.88 192.168.148.88:6080 check
listen nova-metadata-api
bind 192.168.148.200:8775
option httpchk
option httplog
option httpclose
server 192.168.148.91 192.168.148.91:8775 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.89 192.168.148.89:8775 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.88 192.168.148.88:8775 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
listen cinder-api
bind 192.168.148.200:8776
option httpchk
option httplog
option httpclose
server 192.168.148.91 192.168.148.91:8776 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.89 192.168.148.89:8776 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.88 192.168.148.88:8776 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
listen glance-api
bind 192.168.148.200:9292
option httpchk
option httplog
option httpclose
server 192.168.148.91 192.168.148.91:9292 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.89 192.168.148.89:9292 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.88 192.168.148.88:9292 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
listen neutron
bind 192.168.148.200:9696
option httpchk
option httplog
option httpclose
server 192.168.148.91 192.168.148.91:9696 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.89 192.168.148.89:9696 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
server 192.168.148.88 192.168.148.88:9696 check inter 10s fastinter 2s downinter 3s rise 3 fall 3
listen glance-registry
bind 192.168.148.200:9191
balance roundrobin
option httplog
server 192.168.148.91 192.168.148.91:9191 check
server 192.168.148.89 192.168.148.89:9191 check
server 192.168.148.88 192.168.148.88:9191 check
listen mysqld
bind 192.168.148.200:3306
#balance leastconn
mode tcp
option tcp-check
server 192.168.148.91 192.168.148.91:3306 check port 3306 inter 2000 rise 2 fall 3
server 192.168.148.89 192.168.148.89:3306 backup check port 3306 inter 2000 rise 2 fall 3
server 192.168.148.88 192.168.148.88:3306 backup check port 3306 inter 2000 rise 2 fall 3
listen placement
bind 192.168.148.200:8778
balance source
option httplog
server 192.168.148.91 192.168.148.91:8778 check
server 192.168.148.89 192.168.148.89:8778 check
server 192.168.148.88 192.168.148.88:8778 check
#listen swift
# bind 192.168.148.200:8080
# balance roundrobin
# option httplog
# #server 10.10.48.111 10.10.48.111:8080 check
# #server 10.10.48.112 10.10.48.112:8080 check
# #server 10.10.48.113 10.10.48.113:8080 check
#
listen heat-heat-api-cluster
bind 192.168.148.200:8004
balance source
option httplog
server 192.168.148.91 192.168.148.91:8004 check
server 192.168.148.89 192.168.148.89:8004 check
server 192.168.148.88 192.168.148.88:8004 check
listen heat-cfi-api-cluster
bind 192.168.148.200:8000
balance source
option httplog
server 192.168.148.91 192.168.148.91:8004 check
server 192.168.148.89 192.168.148.89:8004 check
server 192.168.148.88 192.168.148.88:8004 check
将配置文件copy到其他两个节点
3、修改系统参数(三个节点执行)
echo "net.ipv4.ip_nonlocal_bind = 1" >>/etc/sysctl.conf
echo "net.ipv4.ip_forward = 1" >>/etc/sysctl.conf
sysctl -p
4、启动haproxy(三个节点执行)
systemctl restart haproxy
systemctl status haproxy
5、登录haproxy web界面
http://vip:port