5.4、RabbitMQ安装部署
5.4.1、简介
RabbitMQ是一款知名的开源消息列队系统,为企业提供消息的发布、订阅、点对点传输等消息服务。
RabbitMQ在企业开发中十分常见,课程为大家演示快速搭建RabbitMQ环境。
5.4.2、安装
RabbitMQ在yum仓库中的版本比较老,所以我们需要手动构建yum仓库。
1、准备yum仓库
① 准备gpgkey密钥
# root执行
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
rpm --import https://packagecloud.io/rabbitmq/erlang/gpgkey
rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
② 准备仓库文件
# root执行
vim /etc/yum.repos.d/rabbitmq.repo
③ 在rabbitmq.repo中填入如下内容
##
## Zero dependency Erlang
##
[rabbitmq_erlang]
name=rabbitmq_erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[rabbitmq_erlang-source]
name=rabbitmq_erlang-source
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
##
## RabbitMQ server
##
[rabbitmq_server]
name=rabbitmq_server
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[rabbitmq_server-source]
name=rabbitmq_server-source
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
2、安装RabbitMQ
# root执行
yum -y install erlang rabbitmq-server
3、启动
# root执行
# 使用systemctl管控,服务名:rabbitmq-server
systemctl enable rabbitmq-server # 开机自启
systemctl disable rabbitmq-server # 关闭开机自启
systemctl start rabbitmq-server # 启动
systemctl stop rabbitmq-server # 关闭
systemctl status rabbitmq-server # 查看状态
4、放行防火墙,RabbitMQ使用5672、15672、25672的3个端口
# 以下操作2选1即可
# 方式1:关闭防火墙
systemctl stop firewalld #关闭防火墙
systemctl disable firewalld #停止防火墙开机自启
# 方式2:放行5672、15672、25672端口的外部访问
firewall-cmd --add-port=5672/tcp --permanent # 放行tcp规则下的5672端口,永久生效
firewall-cmd --add-port=15672/tcp --permanent # 放行tcp规则下的15672端口,永久生效
firewall-cmd --add-port=25672/tcp --permanent # 放行tcp规则下的25672端口,永久生效
firewall-cmd --reload # 重新加载防火墙规则
5、启动RabbitMQ的WEB管理控制台
rabbitmq-plugins enable rabbitmq_management
6、添加admin用户,并赋予权限
rabbitmqctl add_user admin 'admin' # rabbitmqctl add_user admin 'admin用户的密码'
rabbitmqctl set_permissions -p "/" "admin" ".*" ".*" ".*"
rabbitmqctl set_user_tags admin administrator
7、浏览器打开管理控制台
http://192.168.88.88:15672