RabbitMQ是一个开源的AMQP实现,服务器端用Erlang语言编写,支持多种客户端,如:Python、Ruby、.NET、Java、JMS、C、PHP、ActionScript、XMPP、STOMP等,支持AJAX。用于在分布式系统中存储转发消息,在易用性、扩展性、高可用性等方面表现不俗。
AMQP,即Advanced Message Queuing Protocol,高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中间件设计。消息中间件主要用于组件之间的解耦,消息的发送者无需知道消息使用者的存在,反之亦然。AMQP的主要特征是面向消息、队列、路由(包括点对点和发布/订阅)、可靠性、安全。
1、RabbitMQ是Erlang语言编写的,所以在安装RabbitMQ之前,需要先安装Erlang。但是在搭建RabbitMQ环境过程中,会因为RabbitMQ 和 Erlang的版本问题导致环境一直搭建不起来, 以下是RabbitMQ与Erlang的版本对应关系,所以这里我下载的RabbitMQ的版本为 3.8.16,Erlang的版本为24.0
也可以去官网查看RabbitMQ 和 Erlang的版本问题,网址:https://www.rabbitmq.com/which-erlang.html#erlang-repositories
2、进入Erlang官网,点击导航栏中的DOWNLOADS下载链接,进入Erlang下载页面,官网链接:https://www.erlang.org/
3、点击OTP 24.0 Source File 链接进行下载
4、进入RabbitMQ官网,点击右边的RabbitMQ 3.8.16链接,官网链接:https://www.rabbitmq.com/
5、找到RabbitMQ 3.8.16 release 下的 RabbitMQ downloads链接并点击,进入到RabbitMQ的下载页面
6、在右边的In This Section 下找到 Install:Generic binary build下载链接并点击,进入到Linux版的RabbitMQ下载页面中
7、找到Download下的 rabbitmq-server-generic-unix-3.7.16.tar.xz下载链接并点击,开始进行下载RabbitMQ
[root@localhost ~]# cd software //进入到software目录下
[root@localhost software]# ls //查看software目录
otp_src_24.0.tar.gz rabbitmq-server-generic-unix-3.8.16.tar.xz
[root@localhost software ]# tar -zxvf otp_src_24.0.tar.gz //解压Erlang
[root@localhost software]# xz -d rabbitmq-server-generic-unix-3.8.16.tar.xz //解压RabbitMQ
[root@localhost software ]# tar -xvf rabbitmq-server-generic-unix-3.8.16.tar
[root@localhost software]# ls //再次查看software 目录
otp_src_24.0 otp_src_24.0.tar.gz rabbitmq_server-3.8.16 rabbitmq-server-generic-unix-3.8.16.tar
在/usr/local/software 目录下创建一个rabbitmq_software文件夹,便于我们管理安装的RabbitMQ软件,并把我们解压好的文件移动到rabbitmq_software目录下
[root@localhost software]# mkdir -p /usr/local/software/rabbitmq_software //创建一个rabbitmq_software文件夹
//把我们解压好的文件移动到rabbitmq_software目录下
[root@localhost software]# mv otp_src_24.0 /usr/local/software/rabbitmq_software/
[root@localhost software]# mv rabbitmq_server-3.8.16 /usr/local/software/rabbitmq_software/
[root@localhost software]# cd /usr/local/software/rabbitmq_software/
[root@localhost rabbitmq_software]# ls
otp_src_24.0 rabbitmq_server-3.8.16
1、安装Erlang编译所依赖的环境
yum install make gcc gcc-c++ build-essential openssl openssl-devel unixODBC unixODBC-devel kernel-devel m4 ncurses-devel
2、在 /usr/local 目录下创建一个erlang文件夹,因为erlang编译安装默认是装在/usr/local下的bin和lib中,这里我们将他统一装到/usr/local/erlang中,方便查找和使用
[root@localhost rabbitmq_software]# mkdir -p /usr/local/erlang
3、编译erlang
[root@localhost rabbitmq_software]# cd otp_src_24.0/ //进入到Erlang目录下
//编译Erlang,这里由于不需要用java编译器编译,所以后面添加了 --without-javac
[root@localhost otp_src_24.0]# ./configure --prefix=/usr/local/erlang --without-javac
[root@localhost otp_src_24.0]# make && make install
5、配置环境变量
[root@localhost otp_src_22.0]# vim /etc/profile //编辑环境配置文件
//添加如下配置信息
export ERLANG_HOME=/usr/local/erlang
export PATH=${ERLANG_HOME}/bin:${PATH}
[root@localhost otp_src_24.0]# source /etc/profile //重新读取配置文件
6、创建软连
[root@localhost otp_src_22.0]# ln -s /usr/local/erlang/bin/erl /usr/local/bin/erl
1、配置RabbitMQ环境变量
[root@localhost otp_src_24.0]# vim /etc/profile //编辑环境配置文件
//添加如下配置信息
export RABBITMQ_HOME=/usr/local/software/rabbitmq_software/rabbitmq_server-3.8.16
export PATH=${RABBITMQ_HOME}/sbin:${PATH}
[root@localhost otp_src_24.0]# source /etc/profile //重新读取配置文件
2、开启Web管理界面插件,便于访问RabbitMQ
[root@localhost otp_src_22.0]# cd /usr/local/software/rabbitmq_software/rabbitmq_server-3.8.16/sbin
[root@localhost sbin]# ./rabbitmq-plugins enable rabbitmq_management //开启web管理界面插件
可视化界面请参考我另一篇博客:https://blog.csdn.net/SuperChen12356/article/details/117115287
附上etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_181
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
export ERLANG_HOME=/usr/local/erlang
export PATH=${ERLANG_HOME}/bin:${PATH}
# 添加如下配置信息
export RABBITMQ_HOME=/usr/local/software/rabbitmq_software/rabbitmq_server-3.8.16
export PATH=${RABBITMQ_HOME}/sbin:${PATH}
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge