服务器配置
系统环境:CentOS 7
由于RabbitMQ依赖erlang, 所以需要先安装erlang
下载erlang
下载地址
http://erlang.org/download/
linux下载命令
wget http://erlang.org/download/otp_src_20.3.tar.gz
解压
tar zxvf otp_src_20.3.tar.gz
安装ncurses-devel
yum install ncurses-devel
编译安装
cd /home/erlang/otp_src_20.3
./configure--prefix=/usr/local/erlang
make -j 4
make install -j 4
erlang加入PATH变量
vi /etc/profile
#set erlang environment
export PATH=$PATH:/usr/local/erlang/bin
使配置生效
source /etc/profile
检测Erlang是否安装成功
erl
安装rabbitmq
下载rabbitmq地址
http://www.rabbitmq.com/releases/rabbitmq-server/
linux下载命令
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-generic-unix-3.6.15.tar.xz
解压
xz -d rabbitmq-server-generic-unix-3.6.15.tar.xz
tar xvf rabbitmq-server-generic-unix-3.6.15.tar
RabbitMQ加入PATH变量
vi /etc/profile
#set rabbitmq environment
export PATH=$PATH:/usr/local/rabbitmq/sbin
使配置生效
source /etc/profile
创建存放日志和数据库的目录
mkdir -p /var/log/rabbitmq
mkdir -p /var/log/rabbitmq/mnesia/rabbit
修改配置可以建文件
/etc/rabbitmq/rabbitmq.config
/etc/rabbitmq/rabbitmq-env.cfg
/etc/rabbitmq需要自己手动建,如果不需要修改配置则不用新建这两个文件,如果新建了配置文件则启动rabbitmq-server时读取此配置文件,如果配置文件为空则节点会启动失败。
启动与停止(RabbitMQ加入PATH变量后)
rabbitmq-server //启动 RabbitMQ服务
rabbitmqctl stop //停止RabbitMQ服务
rabbitmqctl start_app //启动application
rabbitmqctl stop_app //停止application
查看状态
cd /usr/local/rabbitmq/sbin
./rabbitmqctl status
修改/etc/profile
添加环境变量
#SET erlang environment
export PATH=$PATH:/usr/local/erlang/bin
#set rabbitmq environment
export PATH=$PATH:/usr/local/rabbitmq/sbin
配置RabbitMQ管理界面
cd /usr/local/rabbitmq/sbin
./rabbitmq-plugins enable rabbitmq_management
打开浏览器访问
http://[server-name]:15672
例:http://172.16.18.22:55672/
启动报错
问题描述:
Job for rabbitmq-server.service failed because the control process exited with error code. See “systemctl status rabbitmq-server.service” and “journalctl -xe” for details.
修改主机名【修改为mycomputer】
# 修改HOSTNAME(永久改)
vi /etc/sysconfig/network
# network内容
NETWORKING=yes
HOSTNAME=mycomputer
vi /etc/hosts
# hosts内容
127.0.0.1 mycomputer
rpm方式安装rabbitmq
下载rabbitmq
http://www.rabbitmq.com/download.html
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.5/rabbitmq-server-3.7.5-1.el7.noarch.rpm
安装rabbitmq
rpm -ivh rabbitmq-server-3.7.5-1.el7.noarch.rpm
启动和停止
systemctl start rabbitmq-server
systemctl stop rabbitmq-server
查看服务器状态
rabbitmqctl status
配置RabbitMQ管理界面
anagement plugin默认就在RabbitMQ的发布版本中,只需要enable就可以了,执行以下命令
sudo rabbitmq-plugins enable rabbitmq_management
在web浏览器中输入地址:http://127.0.0.1:15672/
输入默认账号: guest 密码: guest
http://192.168.247.131:15672/#/
相关图片
相关命令
设置新用户: star/star
rabbitmqctl add_user star star
rabbitmqctl list_users
rabbitmqctl set_user_tags star administrator
查看所有队列消息
rabbitmqctl list_queues
查看所有交换机
rabbitmqctl list_exchanges
在后台启动Rabbit node
rabbitmq-server -detached