当前位置:   article > 正文

CentoS7安装RabbitMQ&安装延迟队列插件_rabbitmq开通插件 centos7

rabbitmq开通插件 centos7

1.添加rabbitmq yum源

yum源配置文件夹(/etc/yum.repos.d)下添加rabbitmq.repo,文件内容如下:

# In /etc/yum.repos.d/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
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
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=1
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
  • 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
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57

猜测:使用这个yum之后,可以解决Erlang版本和操作系统版本问题。

2.yum安装rabbitmq

#更新yum源
yum update -y

#install these dependencies from standard OS repositories
yum install socat logrotate -y

#安装erlang和rabbitmq
yum install erlang rabbitmq-server -y
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

3.查看安装版本

#查看Erlang
erl -v
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]
Eshell V12.1.5  (abort with ^G)
1>
1>halt().

#查看rabbitmq,可能要启动后才能使用rabbitmqctl
rabbitmqctl version
3.9.10
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

4.启动rabbitmq

#启动
systemctl start rabbitmq-server

#查看状态
systemctl status rabbitmq-server
  • 1
  • 2
  • 3
  • 4
  • 5

5.防火墙开放端口访问

需要开放5672与15672端口,15672端口为管理界面使用

#添加5672及15672
firewall-cmd --permanent --zone=public --add-port=5672/tcp
firewall-cmd --permanent --zone=public --add-port=15672/tcp

#重新加载防火墙数据
firewall-cmd --reload
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

6.启用WEB管理页面插件

sudo /sbin/rabbitmq-plugins enable rabbitmq_management
  • 1

7.添加访问用户

#查询安装默认的用户(一般有一个guest 用户和一个administrator管理员用户)
rabbitmqctl list_users

#其中admin 是用户名,123456是密码
rabbitmqctl add_user admin 123456

#通过命令给用户增加角色权限 
rabbitmqctl set_user_tags admin administrator

#给用户增加所有访问权限 
rabbitmqctl  set_permissions -p "/" admin '.*' '.*' '.*'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

番外篇:安装延迟队列

1、获取延迟队列插件

官方下载:https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases

2、插件安装启用

#将文件上传至RabbitMQ的插件目录下,按照以上步骤操作的文件目录是:/usr/lib/rabbitmq/lib/rabbitmq_server-3.10.0/plugins
#如果没有此目录,那就使用find命令进行查找
find / -name rabbitmq

#文件上传后,到RabbitMQ的bin目录下启动插件
rabbitmq-plugins enable rabbitmq_delayed_message_exchange

#最后一步,重启RabbitMQ
systemctl restart rabbitmq-server
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

3、检查插件是否安装成功

登录至RabbitMQ的WEB管理后台,检查Exchanges–>Add a new exchange --> type是否有X-delayed-message选项


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/678211
推荐阅读
相关标签
  

闽ICP备14008679号