发布时间:2023-11-05 15:30
安装
yum install -y keepalived
修改keepalived配置文件容灾节点
vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id LVS_OPENSTACK
vrrp_iptables
}
vrrp_instance VI_1 {
state MASTER(BACKUP)
interface ens192
virtual_router_id 192
priority 100(备50)
advert_int 1
authentication {
auth_type PASS
auth_pass 192
}
virtual_ipaddress {
192.168.188.20/24
}
}
启动keepalived容灾节点
systemctl restart keepalived
启动时会自动添加一个drop的防火墙规则,需要清空
iptables -F
systemctl status keepalived
systemctl enable keepalived
查看vip
ip add | grep 188.20
安装
yum install -y haproxy
创建HAProxy记录日志文件并授权容灾节点
mkdir /var/log/haproxy
touch /var/log/haproxy/haproxy-info.log
touch /var/log/haproxy/haproxy-err.log
touch /var/log/haproxy/haproxy-notice.log
chmod -R 777 /var/log/haproxy
在rsyslog文件下修改以下字段
vi /etc/rsyslog.conf
module(load=\"imudp\")
input(type=\"imudp\" port=\"514\")
module(load=\"imtcp\")
input(type=\"imtcp\" port=\"514\")
#### GLOBAL DIRECTIVES ####
#在文件最后添加haproxy配置日志
local0.=info -/var/log/haproxy/haproxy-info.log
local0.=err -/var/log/haproxy/haproxy-err.log
local0.notice;local0.!=err -/var/log/haproxy/haproxy-notice.log
重启rsyslog
systemctl restart rsyslog
上传并修改配置文件容灾节点
vi /etc/haproxy/haproxy.cfg
#openstack高可用haproxy配置
###########全局配置#########
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
#线程数
nbproc 16
stats socket /var/lib/haproxy/stats
########默认配置############
defaults
#默认模式{ tcp|http|health }
mode tcp
log global
#最大连接数
maxconn 4000
#连接超时
timeout connect 5m
#客户端超时
timeout client 1m
#服务器超时
timeout server 31m
#心跳检测超时
timeout check 10s
#负载均衡方式,轮询
balance roundrobin
########haproxy监控页统计页面配置########
listen stats
bind *:1080
mode http
option httplog
log 127.0.0.1 local0 err
stats refresh 30s
#状态页面 http//ip:1080/admin访问
stats uri /admin
stats realm Haproxy\\ Statistics
#用户和密码:admin
stats auth admin:admin
#隐藏版本信息
stats hide-version
#设置手工启动/禁用
stats admin if TRUE
maxconn 10
########以下为基础服务高可用配置############
# mysql服务;
listen mysql_cluster_status
bind *:3306
balance source
mode tcp
server mysql-mgr01 节点ip:3306 check inter 2000 rise 2 fall 5
server mysql-mgr02 节点ip:3306 backup check inter 2000 rise 2 fall 5
server mysql-mgr03 节点ip:3306 backup check inter 2000 rise 2 fall 5
# mysqlMGR服务;
listen mysql_mgr_cluster_status
bind *:33062
balance source
mode tcp
server mysql-mgr01 节点ip:33062 check inter 2000 rise 2 fall 5
server mysql-mgr02 节点ip:33062 backup check inter 2000 rise 2 fall 5
server mysql-mgr03 节点ip:33062 backup check inter 2000 rise 2 fall 5
#RabbitMQ
listen RabbitMQ_Web_cluster
bind *:15672
mode tcp
balance roundrobin
option tcpka
timeout client 3h
timeout server 3h
option clitcpka
server openstackcontroller01 节点ip:15672 check inter 5s rise 2 fall 3
server openstackcontroller02 节点ip:15672 check inter 5s rise 2 fall 3
server openstackcontroller03 节点ip:15672 check inter 5s rise 2 fall 3
listen RabbitMQ_api_cluster_status
bind *:5672
mode tcp
balance roundrobin
option tcpka
timeout client 3h
timeout server 3h
option clitcpka
server openstackcontroller01 节点ip:5672 check inter 5s rise 2 fall 3
server openstackcontroller02 节点ip:5672 check inter 5s rise 2 fall 3
server openstackcontroller03 节点ip:5672 check inter 5s rise 2 fall 3
#memcache
listen memcache_api_cluster_status
bind *:11211
mode tcp
balance roundrobin
option tcpka
timeout client 3h
timeout server 3h
option clitcpka
server openstackcontroller01 节点ip:11211 check inter 5s rise 2 fall 3
server openstackcontroller02 节点ip:11211 check inter 5s rise 2 fall 3
server openstackcontroller03 节点ip:11211 check inter 5s rise 2 fall 3
#etcd
listen etcd_api_cluster_status
bind *:2379
mode tcp
balance roundrobin
option tcpka
timeout client 3h
timeout server 3h
option clitcpka
server openstackcontroller01 节点ip:2379 check inter 5s rise 2 fall 3
server openstackcontroller02 节点ip:2379 check inter 5s rise 2 fall 3
server openstackcontroller03 节点ip:2379 check inter 5s rise 2 fall 3
########以下为openstack高可用配置############
##################horizon服务
listen dashboard_cluster
bind *:80
balance source
option tcpka
option httpchk
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:80 check port 80 inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:80 check port 80 inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:80 check port 80 inter 2000 rise 2 fall 5
#################keystone服务
#keystoneANDkeystone_admin_cluster、keystone_public_api
listen keystone_public_api_cluster
bind *:5000
balance source
option tcpka
option httpchk
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:5000 check inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:5000 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:5000 check inter 2000 rise 2 fall 5
#################glance服务
#glance_api_cluster
listen glance_api_cluster
bind *:9292
mode tcp
balance source
option tcpka
option httpchk
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:9292 check inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:9292 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:9292 check inter 2000 rise 2 fall 5
#glance_registry_cluster
listen glance_registry_cluster
bind *:9191
mode tcp
balance source
option tcpka
option httpchk
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:9191 check inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:9191 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:9191 check inter 2000 rise 2 fall 5
#################placement服务
#placement
listen placement_cluster
bind *:8778
balance source
option tcpka
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:8778 check inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:8778 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:8778 check inter 2000 rise 2 fall 5
#################nova服务
#nova_compute
listen nova_compute_api_cluster
bind *:8774
balance source
option tcpka
option httpchk
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:8774 check inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:8774 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:8774 check inter 2000 rise 2 fall 5
#Nova-api-metadata
listen Nova-api-metadata_cluster
bind *:8775
balance source
option tcpka
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:8775 check inter 2000 rise 2 fall 5
server openstackcontroller01 节点ip:8775 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:8775 check inter 2000 rise 2 fall 5
#nova_vncproxy
listen nova_vncproxy_cluster
bind *:6080
balance source
option tcpka
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:6080 check inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:6080 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:6080 check inter 2000 rise 2 fall 5
#################Neutron服务
#Neutron_API
listen Neutron_API_cluster
bind *:9696
balance source
option tcpka
option httpchk
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:9696 check inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:9696 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:9696 check inter 2000 rise 2 fall 5
#################Cinder服务
#Cinder_API_cluster
listen Cinder_API_cluster
bind *:8776
balance source
option tcpka
option httpchk
option tcplog
timeout client 3h
timeout server 3h
server openstackcontroller01 节点ip:8776 check inter 2000 rise 2 fall 5
server openstackcontroller02 节点ip:8776 check inter 2000 rise 2 fall 5
server openstackcontroller03 节点ip:8776 check inter 2000 rise 2 fall 5
启动haproxy容灾节点
systemctl start haproxy
systemctl status haproxy
systemctl enable haproxy
访问haproxy网站观察服务部署情况
http://vip:1080/admin
用户名/密码:admin/admin
喜欢的亲可以关注点赞评论哦!以后每天都会更新的哦!本文为小编原创文章; 文章中用到的文件、安装包等可以加小编联系方式获得;
欢迎来交流小编联系方式VX:CXKLittleBrother 进入运维交流群