1.rabbitmq高可用方案
采用标准集群模式 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高可用方案的更多相关文章
- RabbitMQ高可用方案总结
RabbitMQ的集群方案有以下几种: 1.普通的集群 exchange,buindling再所有的节点上都会保存一份,但是queue只会存储在其中的一个节点上,但是所有的节点都会存储一份queue的 ...
- rabbitMQ高可用方案
普通模式 默认的集群模式,以两个节点(rabbit01.rabbit02)为例来进行说明.对于Queue来说,消息实体只存在于其中一个节点rabbit01(或者rabbit02),rabbit01和r ...
- RabbitMQ学习系列(六): RabbitMQ 高可用集群
前面讲过一些RabbitMQ的安装和用法,也说了说RabbitMQ在一般的业务场景下如何使用.不知道的可以看我前面的博客,http://www.cnblogs.com/zhangweizhong/ca ...
- Redis总结(五)缓存雪崩和缓存穿透等问题 Web API系列(三)统一异常处理 C#总结(一)AutoResetEvent的使用介绍(用AutoResetEvent实现同步) C#总结(二)事件Event 介绍总结 C#总结(三)DataGridView增加全选列 Web API系列(二)接口安全和参数校验 RabbitMQ学习系列(六): RabbitMQ 高可用集群
Redis总结(五)缓存雪崩和缓存穿透等问题 前面讲过一些redis 缓存的使用和数据持久化.感兴趣的朋友可以看看之前的文章,http://www.cnblogs.com/zhangweizhon ...
- MySQL高可用方案
高可用架构对于互联网服务基本是标配,无论是应用服务还是数据库服务都需要做到高可用.虽然互联网服务号称7*24小时不间断服务,但多多少少有一些时候服务不可用,比如某些时候网页打不开,百度不能搜索或者无法 ...
- [转]MYSQL高可用方案探究(总结)
前言 http://blog.chinaunix.net/uid-20639775-id-3337432.htmlLvs+Keepalived+Mysql单点写入主主同步高可用方案 http://bl ...
- Sentinel-Redis高可用方案(一):主从复制
引言 大概是因为Redis是个人开发的产品,所以Redis的高可用方案是被分成了几块来实现:主从复制.主从切换以及虚拟IP或客户端方案. 从Redis 2.8开始加入对Sentinel机制从而实现了服 ...
- Redis之高可用方案
Redis之高可用方案 Redis以其高效的访问速度著称.但由于官方还未发布redis-cluster,而redis的replica又有诸多不便:比如一组master-slave的机器,如果之间有 ...
- mysql高可用方案总结性说明
MySQL的各种高可用方案,大多是基于以下几种基础来部署的(也可参考:Mysql优化系列(0)--总结性梳理 该文后面有提到)1)基于主从复制:2)基于Galera协议(PXC):3)基于NDB引 ...
随机推荐
- Windows解压安装mysql 5.7.24,并部署多个mysql服务
mysql官网windows安装文档 https://dev.mysql.com/doc/refman/5.7/en/windows-installation.html 第一步,选择安装包 htt ...
- [TPYBoard - Micropython之会python就能做硬件 8] 学习使用超声波模块制作避障小车
转载请注明:@小五义 http://www.cnblogs.com/xiaowuyi 欢迎加入讨论群 64770604 一.实验器材 1.TPYboard V102板 一块 2.电机驱动模块L2 ...
- Java多线程(五)——线程等待与唤醒
一.wait().notify().notifyAll()等方法介绍 在Object.java中,定义了wait(), notify()和notifyAll()等接口.wait()的作用是让当前线程进 ...
- Django:安装和启动
最近在学习利用python语言进行web站点开发,使用的框架是Django.这篇博客主要介绍Django的安装和简单使用. 一.Django介绍 Django是一个开源的Web应用框架,由Python ...
- 使用keras的LSTM进行预测----实战练习
代码 import numpy as np from keras.models import Sequential from keras.layers import Dense from keras. ...
- 面试:用 Java 实现一个 Singleton 模式
面试:用 Java 实现一个 Singleton 模式 面试系列更新后,终于迎来了我们的第一期,我们也将贴近<剑指 Offer>的题目给大家带来 Java 的讲解,个人还是非常推荐< ...
- 【Python入门只需20分钟】从安装到数据抓取、存储原来这么简单
基于大众对Python的大肆吹捧和赞赏,作为一名Java从业人员,我本着批判与好奇的心态买了本python方面的书<毫无障碍学Python>.仅仅看了书前面一小部分的我......决定做一 ...
- List对象去重碎碎念之神叨叨
前言 List集合操作去除重复数据的这种情况经常会碰到,博客园里面也有很多大神们做过,在这里主要是借鉴然后自己整理了一下,主要是为了方便自己,以后再次碰到这种去重问题,直接打开自己的链接拿起键盘就是干 ...
- Stochastic Optimization of PCA with Capped MSG
目录 Problem Matrix Stochastic Gradient 算法(MSG) 步骤二(单次迭代) 单步SVD \(project()\)算法 \(rounding()\) 从这里回溯到此 ...
- 百度统计微信网站绑定(vue项目)
*网站域名:----- *网站首页:----/index.html 下列代码放入index.html vue加百度统计代码(亲测有效)