采用标准集群模式  HAPROXY + rabbitmq 2个 ram  和  一个 disk 节点

主机规划:
192.168.157.128 haproxy keepalive 主 ram节点
192.168.157.129 haproxy keepalive 从 disk 节点
192.168.157.130 disk 节点
VIP 192.168.154.131
前期准备:
关闭 selinux firewalld 配置host解析 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.157.128 k8s-node2
192.168.157.129 k8s-node1
192.168.157.130 k8s-maste

配置 haproxy的高可用

haproxy的配置

[root@k8s-master haproxy]# cat /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:
#
# ) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# ) 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
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/
option redispatch
retries
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 #---------------------------------------------------------------------
## main frontend which proxys to the backends
##---------------------------------------------------------------------
#frontend main *:
# acl url_static path_beg -i /static /images /javascript /stylesheets
# acl url_static path_end -i .jpg .gif .png .css .js
#
# use_backend static if url_static
# default_backend app
#
##---------------------------------------------------------------------
## static backend for serving up images, stylesheets and such
##---------------------------------------------------------------------
#backend static
# balance roundrobin
# server static 127.0.0.1: check
#
##---------------------------------------------------------------------
## round robin balancing between the various backends
##---------------------------------------------------------------------
#backend app
# balance roundrobin
# server app1 127.0.0.1: check
# server app2 127.0.0.1: check
# server app3 127.0.0.1: check
# server app4 127.0.0.1: check
listen http_front
bind 0.0.0.0: #监听端口
stats refresh 30s #统计页面自动刷新时间
stats uri /haproxy?stats #统计页面url
stats realm Haproxy Manager #统计页面密码框上提示文本
stats auth admin:admin #统计页面用户名和密码设置
#stats hide-version #隐藏统计页面上HAProxy的版本信息
listen rabbitmq_admin
bind 0.0.0.0:
server node1 192.168.157.128: check inter 5s rise fall
server node2 192.168.157.129: check inter 5s rise fall
server node3 192.168.157.130: check inter 5s rise fall
listen rabbitmq_cluster
bind 0.0.0.0: #rabbitmq集群调用的端口
option tcplog
mode tcp
timeout client 3h
timeout server 3h
option clitcpka
balance roundrobin #负载均衡算法(#banlance roundrobin 轮询,balance source 保存session值,支持static-rr,leastconn,first,uri等参数)
server rabbitmq1 192.168.157.128: check inter 5s rise fall #check inter 是检测心跳频率,rise 2是2次正确认为服务器可用,fall 3是3次失败认为服务器不可用
server rabbitmq2 192.168.157.129: check inter 5s rise fall
server rabbitmq3 192.168.157.130: check inter 5s rise fall 3 keepalive配置

! Configuration File for keepalived
vrrp_script chk_http_port {
script "/etc/keepalived/check_haproxy.sh"
interval 2
weight 2
global_defs {
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state BACKUP #cong上改为BACKUP
interface eth0
virtual_router_id 51
priority 150 #上改为120
advert_int 1
authentication {
auth_type PASS
auth_pass 2356
}
track_script {
chk_http_port
}
virtual_ipaddress {
192.168.154.131
}
}
}

 

/etc/keepalived/check_haproxy.sh
#!/bin/bash
num=`ps -C haproxy --no-header |wc -l`
if [ $num -eq 0 ];then
systemctl restart haproxy
sleep 3
if [ `ps -C haproxy --no-header |wc -l` -eq 0 ];then
systemctl stop keepalived
fi
fi

chmod  +x

安装配置rabbitmq集群

wget https://github.com/rabbitmq/erlang-rpm/releases/download/v21.2.6/erlang-21.2.6-1.el6.x86_64.rpm
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.13/rabbitmq-server-3.7.13-1.el7.noarch.rpm
rpm -ivh erlang-21.2.-.el6.x86_64.rpm
yum localinstall rabbitmq-server-3.7.-.el7.noarch.rpm -y 添加环境变量

export ERL_HOME
export RABBIT_HOME=/rabbitmq
export PATH=/$RABBIT_HOME/sbin:$PATH:$ERL_HOME/bin

mkdir /rabbitmq

chown rabbitmq /rabbitmq

在master

root@k8s-master rabbitmq]# systemctl start rabbitmq-server.service
[root@k8s-master rabbitmq]# systemctl status rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2019-03-13 23:41:59 +08; 3s ago
Process: 10083 ExecStop=/usr/sbin/rabbitmqctl shutdown (code=exited, status=69)
Main PID: 10229 (beam.smp)
Status: "Initialized"
CGroup: /system.slice/rabbitmq-server.service
├─10229 /usr/lib64/erlang/erts-10.2.4/bin/beam.smp -W w -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/...
├─10559 erl_child_setup 32768
├─10587 inet_gethost 4
└─10588 inet_gethost 4

Mar 13 23:41:58 k8s-master rabbitmq-server[10229]: ## ##
Mar 13 23:41:58 k8s-master rabbitmq-server[10229]: ## ## RabbitMQ 3.7.13. Copyright (C) 2007-2019 Pivotal Software, Inc.
Mar 13 23:41:58 k8s-master rabbitmq-server[10229]: ########## Licensed under the MPL. See http://www.rabbitmq.com/
Mar 13 23:41:58 k8s-master rabbitmq-server[10229]: ###### ##
Mar 13 23:41:58 k8s-master rabbitmq-server[10229]: ########## Logs: /var/log/rabbitmq/rabbit@k8s-master.log
Mar 13 23:41:58 k8s-master rabbitmq-server[10229]: /var/log/rabbitmq/rabbit@k8s-master_upgrade.log
Mar 13 23:41:58 k8s-master rabbitmq-server[10229]: Starting broker...
Mar 13 23:41:59 k8s-master rabbitmq-server[10229]: systemd unit for activation check: "rabbitmq-server.service"
Mar 13 23:41:59 k8s-master systemd[1]: Started RabbitMQ broker.
Mar 13 23:41:59 k8s-master rabbitmq-server[10229]: completed with 0 plugins.

获取erlang  cookie

同步三台主机

然后启动三台主机

在另外两个节点上加入集群

停止应用

rabbitmqctl stop_app

rabbitmqctl join_cluster rabbit@k8s-master
rabbitmqctl start_app

rabbitmqctl join_cluster --ram rabbit@k8s-master
rabbitmqctl start_app

rabbitmqctl add_user mytest mytest
rabbitmqctl set_user_tags mytest administrator
rabbitmqctl set_permissions -p / mytest '.*' '.*' '.*

1.rabbitmq高可用方案的更多相关文章

  1. RabbitMQ高可用方案总结

    RabbitMQ的集群方案有以下几种: 1.普通的集群 exchange,buindling再所有的节点上都会保存一份,但是queue只会存储在其中的一个节点上,但是所有的节点都会存储一份queue的 ...

  2. rabbitMQ高可用方案

    普通模式 默认的集群模式,以两个节点(rabbit01.rabbit02)为例来进行说明.对于Queue来说,消息实体只存在于其中一个节点rabbit01(或者rabbit02),rabbit01和r ...

  3. RabbitMQ学习系列(六): RabbitMQ 高可用集群

    前面讲过一些RabbitMQ的安装和用法,也说了说RabbitMQ在一般的业务场景下如何使用.不知道的可以看我前面的博客,http://www.cnblogs.com/zhangweizhong/ca ...

  4. Redis总结(五)缓存雪崩和缓存穿透等问题 Web API系列(三)统一异常处理 C#总结(一)AutoResetEvent的使用介绍(用AutoResetEvent实现同步) C#总结(二)事件Event 介绍总结 C#总结(三)DataGridView增加全选列 Web API系列(二)接口安全和参数校验 RabbitMQ学习系列(六): RabbitMQ 高可用集群

    Redis总结(五)缓存雪崩和缓存穿透等问题   前面讲过一些redis 缓存的使用和数据持久化.感兴趣的朋友可以看看之前的文章,http://www.cnblogs.com/zhangweizhon ...

  5. MySQL高可用方案

    高可用架构对于互联网服务基本是标配,无论是应用服务还是数据库服务都需要做到高可用.虽然互联网服务号称7*24小时不间断服务,但多多少少有一些时候服务不可用,比如某些时候网页打不开,百度不能搜索或者无法 ...

  6. [转]MYSQL高可用方案探究(总结)

    前言 http://blog.chinaunix.net/uid-20639775-id-3337432.htmlLvs+Keepalived+Mysql单点写入主主同步高可用方案 http://bl ...

  7. Sentinel-Redis高可用方案(一):主从复制

    引言 大概是因为Redis是个人开发的产品,所以Redis的高可用方案是被分成了几块来实现:主从复制.主从切换以及虚拟IP或客户端方案. 从Redis 2.8开始加入对Sentinel机制从而实现了服 ...

  8. Redis之高可用方案

    Redis之高可用方案   Redis以其高效的访问速度著称.但由于官方还未发布redis-cluster,而redis的replica又有诸多不便:比如一组master-slave的机器,如果之间有 ...

  9. mysql高可用方案总结性说明

    MySQL的各种高可用方案,大多是基于以下几种基础来部署的(也可参考:Mysql优化系列(0)--总结性梳理   该文后面有提到)1)基于主从复制:2)基于Galera协议(PXC):3)基于NDB引 ...

随机推荐

  1. Pyhon流程控制

    1.条件控制 Python 中用 elif 代替了 else if,所以if语句的关键字为:if – elif – else. 注意: 1.每个条件后面要使用冒号 :,表示接下来是满足条件后要执行的语 ...

  2. (转)MySQL慢查询分析优化 + MySQL调优

    .long_query_time的默认值为10,意思是运行10S以上的语句. .临时设置开启慢查询日志 mysql> show variables like '%slow_query_log%' ...

  3. CentOS下安装Apache

    CentOS下安装Apache,首先在用户状态下使用su root命令切换到超级管理员界面,让后开启终端,进行apache的安装过程. [root@localhost centos]# yum ins ...

  4. OPPO Developers Conference(2018.12.26)

    时间:2018.12.26地点:北京国家会议中心

  5. Spark官方调优文档翻译(转载)

    Spark调优 由于大部分Spark计算都是在内存中完成的,所以Spark程序的瓶颈可能由集群中任意一种资源导致,如:CPU.网络带宽.或者内存等.最常见的情况是,数据能装进内存,而瓶颈是网络带宽:当 ...

  6. golang中的context包

    标准库的context包 从设计角度上来讲, golang的context包提供了一种父routine对子routine的管理功能. 我的这种理解虽然和网上各种文章中讲的不太一样, 但我认为基本上还是 ...

  7. Spring+SpringMVC+MyBatis+easyUI整合基础篇(一)项目简述及技术选型介绍

    作者:13GitHub:https://github.com/ZHENFENG13版权声明:本文为原创文章,未经允许不得转载. 萌芽阶段 很久之前就开始打算整理一下自己的技术博客了,由于各种原因(借口 ...

  8. Django Restframework 过滤器

    一.基本配置: 1.安装:pip install django-filter 2.将 django_filters 配置到INSTALLED-APPS中 3.对 REST_FRAMEWORK 配置: ...

  9. centos7下zabbix安装与部署

    1.Zabbix介绍 zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系 ...

  10. Average Sleep Time CodeForces - 808B (前缀和)

    It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, on ...