Centos7安装RabbitMQ3.8.11

Centos7安装RabbitMQ3.8.11

安装Erlong

RabbitMQ是erlong语言编写的,故安装前需先安装erlong语言环境,并且RabbitMQ版本有对应的erlong版本要求。

RabbitMQ和Erlong/OTP兼容性列表

下表提供了当前支持的RabbitMQ版本系列的Erlang兼容性列表。

RabbitMQ版本 最低要求的Erlong/OTP 最大支持的Erlong/OTP 笔记
3.8.11 22.3 23.x 建议使用Erlang 23.x
erlang22.x放弃了对HiPE的支持

Erlong23.2.3下载地址:https://github.com/erlang/otp/releases/tag/OTP-23.2.3/

Centos7安装RabbitMQ3.8.11_第1张图片

RabbitMQ3.8.11下载地址:https://www.rabbitmq.com/install-rpm.html#downloads

Centos7安装RabbitMQ3.8.11_第2张图片

[root@iZbp1jaz33icbt3708j6yyZ opt]# ll
-rw-r--r-- 1 root root  99256874 Jan 28 17:15 otp_src_23.2.3.tar.gz
-rw-r--r-- 1 root root  15816534 Jan 28 14:12 rabbitmq-server-3.8.11-1.el7.noarch_2.rpm
[root@iZbp1jaz33icbt3708j6yyZ opt]# tar -zxvf otp_src_23.2.3.tar.gz -C /usr/local/
[root@iZbp1jaz33icbt3708j6yyZ opt]# cd /usr/local/
[root@iZbp1jaz33icbt3708j6yyZ local]# cd otp_src_23.2.3/
[root@iZbp1jaz33icbt3708j6yyZ otp_src_23.2.3]# ./otp_build autoconf
[root@iZbp1jaz33icbt3708j6yyZ otp_src_23.2.3]# ./configure && make && make install
[root@iZbp1jaz33icbt3708j6yyZ otp_src_23.2.3]# cd
Erlang/OTP 23 [erts-11.1.7] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]

Eshell V11.1.7  (abort with ^G)
1> 

进入erlong命令行表示安装成功

安装RabbitMQ

安装RabbitMQ之前必须先安装Erlong,否则会安装报错

[root@iZbp1jaz33icbt3708j6yyZ ~]# rpm -Uvh https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.11/rabbitmq-server-3.8.11-1.el7.noarch.rpm --nodeps
Retrieving https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.11/rabbitmq-server-3.8.11-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.9Howbu: Header V4 RSA/SHA256 Signature, key ID 6026dfca: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:rabbitmq-server-3.8.11-1.el7     ################################# [100%]
[root@iZbp1jaz33icbt3708j6yyZ ~]#

安装成功

如果遇到erlang已安装且版本正确,但是RabbitMQ检测失败的情况,可以追加参数 —nodeps (不验证软件包依赖)

启动RabbitMQ

[root@iZbp1jaz33icbt3708j6yyZ ~]# systemctl enable rabbitmq-server
Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
[root@iZbp1jaz33icbt3708j6yyZ ~]# systemctl start rabbitmq-server
[root@iZbp1jaz33icbt3708j6yyZ ~]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
   Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2021-01-30 10:30:16 CST; 13s ago
 Main PID: 17325 (beam.smp)
   Status: "Initialized"
   CGroup: /system.slice/rabbitmq-server.service
           ├─17325 /usr/local/lib/erlang/erts-11.1.7/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -- -root /usr/local/lib/erlang -progname erl -- -home /v...
           ├─17340 erl_child_setup 32768
           ├─17365 /usr/local/lib/erlang/erts-11.1.7/bin/epmd -daemon
           ├─17384 inet_gethost 4
           └─17385 inet_gethost 4

Jan 30 10:30:13 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: ##########  Licensed under the MPL 2.0. Website: https://rabbitmq.com
Jan 30 10:30:13 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: Doc guides: https://rabbitmq.com/documentation.html
Jan 30 10:30:13 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: Support:    https://rabbitmq.com/contact.html
Jan 30 10:30:13 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: Tutorials:  https://rabbitmq.com/getstarted.html
Jan 30 10:30:13 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: Monitoring: https://rabbitmq.com/monitoring.html
Jan 30 10:30:13 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: Logs: /var/log/rabbitmq/[email protected]
Jan 30 10:30:13 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: /var/log/rabbitmq/rabbit@iZbp1jaz33icbt3708j6yyZ_upgrade.log
Jan 30 10:30:13 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: Config file(s): (none)
Jan 30 10:30:16 iZbp1jaz33icbt3708j6yyZ rabbitmq-server[17325]: Starting broker... completed with 0 plugins.
Jan 30 10:30:16 iZbp1jaz33icbt3708j6yyZ systemd[1]: Started RabbitMQ broker.
[root@iZbp1jaz33icbt3708j6yyZ ~]# 

RabbitMQ启动成功!

Web插件安装

[root@iZbp1jaz33icbt3708j6yyZ ~]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@iZbp1jaz33icbt3708j6yyZ:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@iZbp1jaz33icbt3708j6yyZ...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch

started 3 plugins.
[root@iZbp1jaz33icbt3708j6yyZ ~]# 

访问管理页面

http://IP:15672

账号和密码默认都是guest

Centos7安装RabbitMQ3.8.11_第3张图片

提示当前只能本地访问,需要配置远程用户才能远程访问。

配置远程用户

[root@iZbp1jaz33icbt3708j6yyZ ~]# vim /etc/rabbitmq/rabbitmq.config
[{
     rabbit, [{
     loopback_users, []}]}].
[root@iZbp1jaz33icbt3708j6yyZ ~]# 

重启RabbitMQ

[root@iZbp1jaz33icbt3708j6yyZ ~]# systemctl restart rabbitmq-server

访问管理页面

Centos7安装RabbitMQ3.8.11_第4张图片

创建管理用户

#添加用户(用户admin,密码admin)
[root@iZbp1jaz33icbt3708j6yyZ ~]# rabbitmqctl add_user admin admin
Adding user "admin" ...

#设置用户角色(admin为管理员)
[root@iZbp1jaz33icbt3708j6yyZ ~]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...

#设置用户权限(接受来自所有Host的所有操作)
[root@iZbp1jaz33icbt3708j6yyZ ~]# rabbitmqctl  set_permissions -p "/" admin '.*' '.*' '.*'
Setting permissions for user "admin" in vhost "/" ...

#查看用户权限
[root@iZbp1jaz33icbt3708j6yyZ ~]# rabbitmqctl list_user_permissions admin
Listing permissions for user "admin" ...
vhost    configure    write    read
/    .*    .*    .*
[root@iZbp1jaz33icbt3708j6yyZ ~]#

RabbitMQ常用命令

# 添加用户
rabbitmqctl add_user <username> <password>  

# 删除用户
rabbitmqctl delete_user <username>  

# 修改用户密码
rabbitmqctl change_password <username> <newpassword>  

# 清除用户密码(该用户将不能使用密码登陆,但是可以通过SASL登陆如果配置了SASL认证)
rabbitmqctl clear_password <username> 

# 设置用户tags(相当于角色,包含administrator,monitoring,policymaker,management)
rabbitmqctl set_user_tags <username> <tag>

# 列出所有用户
rabbitmqctl list_users  

# 创建一个vhosts
rabbitmqctl add_vhost <vhostpath>  

# 删除一个vhosts
rabbitmqctl delete_vhost <vhostpath>  

# 列出vhosts
rabbitmqctl list_vhosts [<vhostinfoitem> ...]  

# 针对一个vhosts给用户赋予相关权限;
rabbitmqctl set_permissions [-p <vhostpath>] <user> <conf> <write> <read>  

# 清除一个用户对vhosts的权限;
rabbitmqctl clear_permissions [-p <vhostpath>] <username>  

# 列出哪些用户可以访问该vhosts;
rabbitmqctl list_permissions [-p <vhostpath>]   

# 列出用户访问权限;
rabbitmqctl list_user_permissions <username>

你可能感兴趣的:(rabbitmq)