RabbitMQ is the most widely deployed open source message broker.
如官方文档所说,mq是系统间消息传递的优质载体;本文旨在项目中引入和测试demo时避免些许的坑。但本文仅是作者的总结,如有歧义请移步官方文档。
1. 安装ERLANG
因为rabbitmq是基于erlang语言写的,
所以安装mq前必须保证环境中已经安装了erlang。
如已经安装,请跳过此步。
1.1 准备工作
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
rpm --import http://packages.erlang-solutions.com/rpm/erlang_solutions.asc
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
//导入 key
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
//安装 RPMforge
rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm
1.2 安装erlang
yum install erlang
1.3 检验
erl -version
1.4 手动安装
1 下载文件:otp_src_x.tar.gz (https://www.rabbitmq.com/)
2 tar zxvf otp_src_x.tar.gz
3 yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
4 cd otp_src_x
./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-java
make && make install
5 vim /etc/profile:
在 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL 后添加:
ERL_PATH=/usr/local/erlang/bin
PATH=$ERL_PATH:$PATH
1.5 WINDOWS安装
2. 安装RabbitMQ Server
2.1 下载RabbitMQ Server
打开RabbitMQ的下载页面(http://www.rabbitmq.com/download.html)
选择对应平台的二进制发行包下载
比如rabbitmq-server-3.5.1-1.noarch.rpm
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.1/rabbitmq-server-3.5.1-1.noarch.rpm
2.2 安装RabbitMQ Server
rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
yum install rabbitmq-server-3.5.1-1.noarch.rpm
2.3 手动安装RabbitMQ Server
下载:http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.6/rabbitmq-server-generic-unix- 2.8.6.tar.gz
tar xvzf rabbitmq-server-generic-unix-2.8.6.tar.gz
2.4 启动RabbitMQ
1 root权限下执行:
chkconfig rabbitmq-server on
2 启动rabbitMQ服务:
../rabbit_server-x.x.x/sbin/service rabbitmq-server start
2.5 安装Web管理界面插件
1 安装:
../rabbit_server-x.x.x/sbin/rabbitmq-plugins enable rabbitmq_management
2 安装成功后会显示如下内容:
The following plugins have been enabled:
mochiweb
webmachine
rabbitmq_web_dispatch
amqp_client
rabbitmq_management_agent
rabbitmq_management
Plugin configuration has changed. Restart RabbitMQ for changes to take effect.
2.6 登录Web管理界面
安装好插件并开启服务后,可以浏览器输入localhost:15672,账号密码均输入guest账号即可登录。
如果显示找不到主机,请在hosts文件中添加:
vi /etc/hosts
127.0.0.1 localhost
但RabbitMQ默认账号guest不允许远程ip登录,可以添加其他账户,并赋administrator权限即可使用新账号远程登录。可以参考链接。
2.7 RabbitMQ Server 拓展
开启log
../rabbit_server-x.x.x/sbin/rabbitmq-plugins enable rabbitmq_tracing
网友评论