◉◡◉ 您好,欢迎到访伊成个人站!

centos7中安装rabbitmq

写在前面

安装rabbitmq之前必须先安装一些必要的依赖,这里安装的环境是在centos7中进行。

官方网址:https://www.rabbitmq.com/download.html

安装步骤

1.将下载好的文件上传到服务器(这里我上传到了 /usr/local/software )

2.先安装erlang,然后安装 rabbitmq-server

1
2
3
4
5
6
[root@localhost software]# rpm -ivh erlang-21.3.1-1.el7.x86_64.rpm
警告:erlang-21.3.1-1.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID 6026dfca: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:erlang-21.3.1-1.el7 ################################# [100%]
[root@localhost software]#

继续安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[root@localhost software]# yum install socat -y
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.ustc.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/3): extras/7/x86_64/primary_db | 250 kB 00:00:00
(2/3): docker-ce-stable/7/x86_64/primary_db | 114 kB 00:00:00
(3/3): updates/7/x86_64/primary_db | 22 MB 00:00:02
正在解决依赖关系
--> 正在检查事务
---> 软件包 socat.x86_64.0.1.7.3.2-2.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================================================================================
Package 架构 版本 源 大小
================================================================================================================================================
正在安装:
socat x86_64 1.7.3.2-2.el7 base 290 k

事务概要
================================================================================================================================================
安装 1 软件包

总下载量:290 k
安装大小:1.1 M
Downloading packages:
socat-1.7.3.2-2.el7.x86_64.rpm | 290 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : socat-1.7.3.2-2.el7.x86_64 1/1
验证中 : socat-1.7.3.2-2.el7.x86_64 1/1

已安装:
socat.x86_64 0:1.7.3.2-2.el7

完毕!
[root@localhost software]#
1
2
3
4
5
6
[root@localhost software]# rpm -ivh rabbitmq-server-3.8.8-1.el7.noarch.rpm
警告:rabbitmq-server-3.8.8-1.el7.noarch.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 6026dfca: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:rabbitmq-server-3.8.8-1.el7 ################################# [100%]
[root@localhost software]#

看到以上的消息,说明安装成功了。先说说常用的命令,如下:

1
2
3
4
5
6
7
8
9
10
11
# 添加开机启动rabbitmq服务命令
chkconfig rabbitmq-server on

# 启动服务命令
[root@localhost software]# systemctl start rabbitmq-server

# 查看服务状态
[root@localhost software]# systemctl status rabbitmq-server

# 停止服务
[root@localhost software]# systemctl stop rabbitmq-server

3.安装web页面插件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost software]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@localhost:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@localhost...
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch

set 3 plugins.
Offline change; changes will take effect at broker restart.

4.重启rabbitmq-server,输入对应IP:15672即可访问页面,如果访问不了,可能是没有关闭防火墙;也可以把对应的端口开放即可。

1
2
3
4
[root@localhost software]# firewall-cmd --zone=public --add-port=15672/tcp --permanent
success
[root@localhost software]#
[root@localhost software]# firewall-cmd --reload

5.输入默认的用户名和密码 guest ,发现登录不了提示 User can only log in via loacalhost,重新添加一个用户赋权限即可,具体操作如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 创建用户
rabbitmqctl add_user admin 123

# 设置用户角色
[root@localhost software]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...

# 设置用户权限
[root@localhost software]# rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "/" ...
[root@localhost software]#

# 当前用户和角色
[root@localhost software]# rabbitmqctl list_users
Listing users ...
user tags
admin [administrator]
guest [administrator]

使用 admin 密码 123 则可以登录进去了!


The end.

支付宝打赏 微信打赏