CentOS 7搭建RabbitMQ环境

Updated on in 欲留色枯槁 with 0 views and 0 comments

1 Erlang 安装 (22.3.4.1 版本)

1.1 在线安装

这里选用的 Erlang 是 rabbitMQ 官方提供的精简包,只有 rabbitMQ 运行所必须的环境

1.1.1 配置软件仓库和签名密钥

1vi /etc/yum.repos.d/rabbitmq-erlang.repo

To use Erlang 22.x on CentOS 7:

1[rabbitmq-erlang]
2name=rabbitmq-erlang
3baseurl=https://dl.bintray.com/rabbitmq-erlang/rpm/erlang/22/el/7
4gpgcheck=1
5gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
6repo_gpgcheck=0
7enabled=1

To use Erlang 22.x on CentOS 8:

1[rabbitmq-erlang]
2name=rabbitmq-erlang
3baseurl=https://dl.bintray.com/rabbitmq-erlang/rpm/erlang/22/el/8
4gpgcheck=1
5gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
6repo_gpgcheck=0
7enabled=1

1.1.2 安装

1yum install erlang

来自:https://github.com/rabbitmq/erlang-rpm 的 readme.md

1.2 离线安装

1.2.1 准备

下载需要的密钥和对应的安装包

密钥下载地址:https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc

安装包下载地址:https://github.com/rabbitmq/erlang-rpm/releases/download/v22.3.4.1/erlang-22.3.4.1-1.el7.x86_64.rpm

上传到服务器,进入到目录,这里上传到 /usr 目录

1cd /usr

1.2.2 配置密钥

1sudo rpm --import rabbitmq-release-signing-key.asc

1.2.3 安装

1rpm -ivh erlang-22.3.4.1-1.el7.x86_64.rpm

1.3 验证

显示版本号,并进入控制台,即成功。

1erl

退出,“.”不能忘记

1halt().

2 安装 RabbitMQ (3.8.4 版本)

2.1 在线安装

2.1.1 导入签名密钥

1sudo rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc

2.1.2 配置软件仓库

/etc/yum.repos. 目录下添加。repo 文件(例如 rabbitmq.repo),在文件中添加以下内容,并保存

1vi /etc/yum.repos.d/rabbitmq.repo

The following example sets up a repository that will install RabbitMQ 3.8 and targets CentOS 8:

1[bintray-rabbitmq-server]
2name=bintray-rabbitmq-rpm
3baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/8/
4gpgcheck=0
5repo_gpgcheck=0
6enabled=1

On CentOS 7 the baseurl line would be slightly different:

1[bintray-rabbitmq-server]
2name=bintray-rabbitmq-rpm
3baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/
4gpgcheck=0
5repo_gpgcheck=0
6enabled=1

2.1.3 安装

https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server 中查找对应的版本,这里使用的是 CentOS 7 ,所以安装地址是:

https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/noarch/rabbitmq-server-3.8.4-1.el7.noarch.rpm

1yum install https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/noarch/rabbitmq-server-3.8.4-1.el7.noarch.rpm

2.2 离线安装

2.2.1 准备

下载对应的安装包(若选用离线,密钥在安装 erlang 的时候已经配置过,故这里可不再次配置)

rabbitmq 以及其依赖包

socat 下载地址:http://mirror.centos.org/centos/7/os/x86_64/Packages/socat-1.7.3.2-2.el7.x86_64.rpm

rabbitmq 下载地址:https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/noarch/rabbitmq-server-3.8.4-1.el7.noarch.rpm

2.2.2 安装

将下载的安装包上传服务器,这里上传到 /usr 目录

1cd /usr
2
3rpm -ivh socat-1.7.3.2-2.el7.x86_64.rpm
4
5rpm -ivh rabbitmq-server-3.8.4-1.el7.noarch.rpm

2.3 安装路径

默认是:/usr/lib/rabbitmq

1whereis rabbitmq

2.4 开启守护进程

使用 rpm 安装,默认是关闭守护进程的,需要开启

1chkconfig rabbitmq-server on

2.5 启动/停止

1# start it back
2service rabbitmq-server start
3
4# stop the local node
5service rabbitmq-server stop
6
7# check on service status as observed by service manager
8service rabbitmq-server status

2.6 放行端口

 1systemctl status firewalld
 2
 3firewall-cmd --list-ports
 4
 5firewall-cmd --zone=public --add-port=5672/tcp --permanent
 6firewall-cmd --zone=public --add-port=15672/tcp --permanent
 7firewall-cmd --zone=public --add-port=15674-15675/tcp --permanent
 8firewall-cmd --zone=public --add-port=1883/tcp --permanent
 9
10firewall-cmd --reload

2.7 用户管理

查看所有用户

1rabbitmqctl list_users

添加一个用户

1rabbitmqctl add_user admin 123456

配置权限

1rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" 

查看用户权限

1rabbitmqctl list_user_permissions admin 

设置 tag

1rabbitmqctl set_user_tags admin administrator 

删除用户(安全起见,删除默认用户)

1rabbitmqctl delete_user guest

重启即可用新账号登录

2.8 启用插件

2.8.1 Web 管理

1rabbitmq-plugins enable rabbitmq_management

访问:http://{ip}:15672/

默认账号密码:guest guest(这个账号只允许本机访问)

2.8.2 MQTT

启动 MQTT 插件

1rabbitmq-plugins enable rabbitmq_mqtt

创建账号

1rabbitmqctl add_user mqtt-user mqtt-password
2rabbitmqctl set_permissions -p / mqtt-user ".*" ".*" ".*"
3rabbitmqctl set_user_tags mqtt-user management

具体可查看:https://www.rabbitmq.com/mqtt.html

2.8.3 Web STOMP

1rabbitmq-plugins enable rabbitmq_web_stomp

具体可查看:https://www.rabbitmq.com/web-stomp.html

2.8.4 Web MQTT

1rabbitmq-plugins enable rabbitmq_web_mqtt

具体可查看:https://www.rabbitmq.com/web-mqtt.html

2.8.5 TRACING

1rabbitmq-plugins enable rabbitmq_tracing

消息记录追踪插件


标题:CentOS 7搭建RabbitMQ环境
作者:kangaroo1122
地址:https://www.kangaroohy.com/articles/2020/06/07/1591545309473.html
声明:如非特别说明,版权归kangaroo1122 所有,转载请注明出处,谢谢!
签名:No pains, no gains.