RabbitMq 集群配置
1. RabbitMQ 所需的附属安装包
1.1 openGL安装
执行命令:
[root@localhost local]# yum install mesa-libGL-devel mesa-libGLU-devel freeglut-devel gcc glibc-devel make ncurses-devel openssl-devel autoconf xmlto libtool automake -y
1.2 erlang 安装
下载 erlang http://erlang.org/download/otp_src_18.2.1.tar.gz
解压 otp_src_18.2.1.tar.gz 到 /usr/local 下
[root@localhost local]# tar -xvf otp_src_18.2.1.tar.gz
进入解压后目录 执行命令:
[root@localhost local]# cd otp_src_18.2.1
[root@localhost otp_src_18.2.1]# ./configure --prefix=/usr/local/erlang_7.2.1 --enable-threads --enable-halfword-emulator --enable-smp-support --enable-kernel-poll --enable-sctp --enable-native-libs --enable-shared-zlib --enable-m64-build --enable-silent-rules
执行命令:[root@localhost otp_src_18.2.1]# make && make install
给erlang_7.2.1 文件夹创建 软连接
[root@localhost local]# cd ../
[root@localhost local]# ln -s erlang_7.2.1 erlang_7.2.1_ln
配置erlang环境变量
编辑 /etc/profile
[root@localhost local]# vim /etc/profile ( 按i 进入编辑模式,在末尾处添加 一下内容)
#set environment
ERL_HOME=/usr/local/erlang_7.2.1
PATH=$ERL_HOME/bin:$PATH
export ERL_HOME PATH
按“Esc”键,再按“Shift+:”,在“:”后输入“wq”
[root@localhost local]# source /etc/profile
测试是否安装成功
[root@localhost local]# erl
出现如下图表示成功

按“ctrl + z”键,退出
1.3 python 安装
[root@localhost local]# yum install python python-devel -y
1.4 simplejson 安装
下载 simplejson https://pypi.python.org/pypi/simplejson
最新版本为 3.8.2 ,选择版本下载
解压 simplejson-3.8.2.tar.gz 到 /usr/local 下
[root@localhost local]# tar -xvf simplejson-3.8.2.tar.gz
[root@localhost local]# cd simplejson-3.8.2
[root@localhost simplejson-3.8.2]# python setup.py build
[root@localhost simplejson-3.8.2]# python setup.py install
测试安装是否成功
[root@localhost local]# python
出现如下图表示成功

按“ctrl + z”键,退出
2 . RabbitMQ 安装
2.1 RabbitMQ 第一种安装方式 (解压即可用)
下载 rabbitmq-server
http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.0/rabbitmq-server-generic-unix-3.6.0.tar.xz
安装解压 tar.xz 工具
[root@localhost local]# yum -y install xz
解压 rabbitmq-server-generic-unix-3.6.0.tar.xz 到 /usr/local 下
[root@localhost local]# xz -d rabbitmq-server-generic-unix-3.6.0.tar.xz
[root@localhost local]# tar -xvf rabbitmq-server-generic-unix-3.6.0.tar
[root@localhost local]# mv rabbitmq_server-3.6.0 rabbitmq-server-3.6.0
配置rabbitmq环境变量
编辑 /etc/profile
[root@localhost local]# vim /etc/profile ( 按i 进入编辑模式,在path 基础上添加 变量)
#set environment
RABBITMG_HOME=/usr/local/rabbitmg-server-3.6.0
ERL_HOME=/usr/local/erlang_7.2.1
PATH=$RABBITMG_HOME/sbin:$ERL_HOME/bin:$PATH
export PATH ERL_HOME
按“Esc”键,再按“Shift+:”,在“:”后输入“wq”
[root@localhost local]# source /etc/profile
[root@localhost local]# cd rabbitmq-server-3.6.0/sbin/
启用管理方式(用网页方式管理MQ)
[root@localhost sbin]# ./rabbitmq-plugins enable rabbitmq_management
[root@localhost sbin]# ./rabbitmq-server -detached
设置端口号 可以外部访问
[root@localhost sbin]# /sbin/iptables -I INPUT -p tcp --dport 5672 -j ACCEPT
[root@localhost sbin]# /sbin/iptables -I INPUT -p tcp --dport 15672 -j ACCEPT
[root@localhost sbin]# /etc/rc.d/init.d/iptables save
[root@localhost sbin]# /etc/init.d/iptables restart
访问 http://ip:15672/#/ 看是否有rabbitMQ管理登录页面

添加用户 admin /admin 在页面访问
[root@localhost sbin]# ./rabbitmqctl add_user admin admin
[root@localhost sbin]# ./rabbitmqctl set_user_tags admin administrator
[root@localhost sbin]# ./rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
使用 admin 使用户即可登录
2.2 RabbitMQ 第二种安装方式 (下载源码包自己编译)
下载 rabbitmq-server
http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.0/rabbitmq-server-3.6.0.tar.xz
安装解压 tar.xz 工具
[root@localhost local]# yum -y install xz
解压 rabbitmq-server-generic-unix-3.3.0.tar.gz 到 /usr/local 下
[root@localhost local]# xz -d rabbitmq-server-3.6.0.tar.xz
[root@localhost local]# tar -xvf rabbitmq-server-3.6.0.tar
配置rabbitmq环境变量
编辑 /etc/profile
[root@localhost local]# vim /etc/profile ( 按i 进入编辑模式,在path 基础上添加 变量)
#set environment
RABBITMG_HOME=/usr/local/rabbitmg-server-3.6.0
ERL_HOME=/usr/local/erlang_7.2.1
PATH=$RABBITMG_HOME/sbin:$ERL_HOME/bin:$PATH
export PATH ERL_HOME
按“Esc”键,再按“Shift+:”,在“:”后输入“wq”
[root@localhost local]# source /etc/profile
如果未安装 rsyn 先安装, 否则源码编译 rabbitmq 报错
[root@localhost local]# yum -y install rsync
[root@localhost local]# cd rabbitmq-server-3.6.0/
[root@rabbitmq-server-3.6.0]# make TARGET_DIR=/usr/local/rabbitmq-server-3.6.0 SBIN_DIR=/usr/local/rabbitmq-server-3.6.0/sbin MAN_DIR=/usr/local/rabbitmq-server-3.6.0/man DOC_INSTALL_DIR=/usr/local/rabbitmq-server-3.6.0/doc instal
创建rabbitmq网页管理文件夹
[root@localhost rabbitmq-server-3.6.0]# mkdir /etc/rabbitmq
启用管理方式(用网页方式管理MQ)
[root@localhost rabbitmq-server-3.6.0]# cd scripts/
[root@localhost scripts]# ./rabbitmq-plugins enable rabbitmq_management
[root@localhost scripts]# ./rabbitmq-server -detached
配置端口号 可以外部访问
[root@localhost scripts]# iptables -I INPUT -p tcp --dport 5672 -j ACCEPT
[root@localhost scripts]# iptables -I INPUT -p tcp --dport 15672 -j ACCEPT
[root@localhost scripts]# /etc/rc.d/init.d/iptables save
[root@localhost scripts]# /etc/init.d/iptables restart
访问 http://ip:15672/#/ 看是否有rabbitMQ管理登录页面

添加用户 admin /admin 在页面访问
[root@localhost scripts]# ./rabbitmqctl add_user admin admin
[root@localhost scripts]# ./rabbitmqctl set_user_tags admin administrator
[root@localhost scripts]# ./rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
使用 admin 使用户即可登录
至此 rabbitMQ 单机版 安装完成
**************************** END*************************************
RabbitMQ集群搭建
在另一台电脑搭建rabbitMQ
编辑 hosts 添加集群ip地址 先在node2 配置
[root@localhost sbin]# vim /etc/hosts
127.0.0.1 node2
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.31.139 node2
192.168.31.140 node1
[root@localhost sbin]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=node2
[root@localhost sbin]# iptables -I INPUT -p tcp --dport 4369 -j ACCEPT
[root@localhost sbin]# iptables -I INPUT -p tcp --dport 25672 -j ACCEPT
[root@localhost sbin]# /etc/rc.d/init.d/iptables save
[root@localhost sbin]# /etc/rc.d/init.d/iptables restart
编辑 hosts 添加集群ip地址 再在node1 配置
[root@localhost sbin]# vim /etc/hosts
127.0.0.1 node1
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.31.140 node1
192.168.31.139 node2
[root@localhost sbin]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=node1
[root@localhost sbin]# iptables -I INPUT -p tcp --dport 4369 -j ACCEPT
[root@localhost sbin]# iptables -I INPUT -p tcp --dport 25672 -j ACCEPT
[root@localhost sbin]# /etc/rc.d/init.d/iptables save
[root@localhost sbin]# /etc/rc.d/init.d/iptables restart
1.如上配置完成后重启两电脑
2. 首先将node1的文件(/root/.erlang.cookie)内容copy到node2的相应位置
[root@localhost ~]# cat .erlang.cookie
将cookie 值 复制 在另一台电脑 执行如下命令
[root@localhost ~]# echo ‘scookie value’> .erlang.cookie
- 启动node1的rabbitmq
[root@localhost ~]# cd /usr/local/rabbitmq-server-3.6.0/sbin/
[root@localhost sbin]# ./rabbitmq-server -detached
4. 在node2上执行
[root@localhost sbin]# ./rabbitmqctl stop_app
[root@localhost sbin]# ./rabbitmqctl reset
[root@localhost sbin]# ./rabbitmqctl join_cluster rabbit@node1
登录 node1 如图 ,集群配置完成

再执行如下命令 启动node2
[root@localhost sbin]# ./rabbitmqctl start_app

**************************** END*************************************
Haproxy 负载均衡
在服务器上 安装 haproxy
[root@localhost local]# yum install haproxy
安装完成后 编辑 /etc/haproxy/haproxy.cfg 文件
[root@localhost local]# vim /etc/haproxy/haproxy.cfg
后台 按i 进入编辑模式 在文件最后添加如下 配置
#配置监听rabbitmq
listen rabbitmq_cluster 0.0.0.0:5672
mode tcp
Balance roundrobin
server node1 192.168.31.140:5672 check inter 2000 rise 2 fall 3
server node2 192.168.31.139:5672 check inter 2000 rise 2 fall 3
#配置监听页面
listen stats
mode http
bind *:1080
stats enable
stats hide-version
stats uri /stats
stats realm haproxy_stats
stats auth admin:admin
保存退出编辑模式
进入 haproxy 启动 haprox
[root@localhost local]# cd /usr/sbin
[root@localhost sbin]# ./haproxy -f /etc/haproxy/haproxy.cfg
可能会有警告 PS :无视就行

打开配置监听页面窗口 1080
[root@localhost sbin]# iptables -I INPUT -p tcp --dport 1080 -j ACCEPT
[root@localhost sbin]# /etc/rc.d/init.d/iptables save
[root@localhost sbin]# /etc/rc.d/init.d/iptables restart
访问监听页面 http://ip/stats ip为 配置负载均衡服务器的ip地址
输入密码后即可看到监听页面

**************************** END*************************************
RabbitMq 集群配置的更多相关文章
- rabbitmq集群配置
原文地址:http://www.360doc.com/content/14/0911/17/15077656_408713893.shtml 按照文章中的方式成功建立了两台机器的集群. 但文章中加入集 ...
- Rabbitmq集群安装配置
Rabbitmq集群安装与配置 一.rabbitmq安装环境准备 1.安装环境准备 这里,我们以两个节点为例进行安装,一个节点为内存节点,另一个节点为硬盘节点,具体可根据自己需要分配节点. 安装系统 ...
- Springboot 1.5.x 集成基于Centos7的RabbitMQ集群安装及配置
RabbitMQ简介 RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件). RabbitMQ是一套开源(MPL)的消息队列服务软件,是由LShift提供的一 ...
- RabbitMQ(三) 集群配置
RabbitMQ--集群配置 之前不管是搞Redis.SQL.Mongo还是其他的东西,一律都没说过集群要怎么搞,电脑实在是带不动.说透彻点就是懒,懒得搭也懒得写,今日深刻意识到错误,做学问是不能懒的 ...
- RabbitMq 集群搭建
实验环境: 操作系统为 Centos 7.2 IP hostName 192.168.190.132 node132 192.168.190.139 node139 192.168.190.1 ...
- CentOS7安装RabbitMQ集群
实验环境 RabbitMQ 集群 server1.example.com IP: 10.10.10.11 Node: diskserver2.example.com IP: 10.1 ...
- 用 HAproxy 搭建 RabbitMQ 集群
构建参考: [ Rabbitmq cluster setup with HAproxy ] [ python demo ] RabbitMQ Cluster 遇到的问题 python pika 作为c ...
- RabbitMQ集群搭建和使用
一.环境准备 1.选择RabbitMQ的版本 http://www.rabbitmq.com/changelog.html 注: 不同版本的Linux选择的RabbitMQ版本也不同,参照 http: ...
- centos7 rabbitmq集群搭建+高可用
环境 [root@node1 ~]# cat /etc/redhat-release CentOS Linux release (Core) [root@node1 ~]# uname -r -.el ...
随机推荐
- WMSWebServiceExtension 使用,支持压缩
using System;using System.Collections.Generic;using System.IO.Compression;using System.Diagnostics;u ...
- sqlalchemy
#!/usr/bin/env python #coding:utf8 from sqlalchemy import create_engine,and_,or_,func,Table from sql ...
- Create a geoprocessing tool to buffer a layer and retrieve messages____sync
using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropSer ...
- SQL Server 2008数据库日志收缩
GO ALTER DATABASE MCS SET RECOVERY SIMPLE--设置简单恢复模式 GO DBCC SHRINKFILE (MCS_Log, 1) GO ALTER DATABAS ...
- :before和 :after
:before和:after的作用就是在指定的元素内容(而不是元素本身)之前或者之后插入一个包含content属性指定内容的行内元素,最基本的用法如下: #example:before { conte ...
- HTML解析原理
Web页面运行在各种各样的浏览器当中,浏览器载入.渲染页面的速度直接影响着用户体验 简单地说,页面渲染就是浏览器将html代码根据CSS定义的规则显示在浏览器窗口中的这个过程.先来大致了解一下浏览器都 ...
- 转——JAVA中calendar,date,string 的相互转换和详细用法
package cn.outofmemory.codes.Date; import java.util.Calendar; import java.util.Date; public class Ca ...
- projecteuler Summation of primes
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two milli ...
- 超牛的VS菜单
所有菜单都重复了,Google到了解决办法:devenv /resetuserdata 但好不容易装好额ReSharper又不见了
- app 支付宝 支付 alipaySdk
function pay(P1: JString; P2: Boolean): JString; cdecl; function fetchOrderInfoFromH5PayUrl(P1: J ...