Centos7下RabbitMQ的安装与配置

时间:2024-07-01 22:34:08

具体按照步骤以此为准

  • 第一步:安装最新版的erlang依赖

通过github设置版本号:https://github.com/rabbitmq/erlang-rpm

vi /etc/yum.repos.d/rabbitmq_erlang.repo
[rabbitmq_erlang]
name=rabbitmq_erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/$basearch
repo_gpgcheck=
gpgcheck=
enabled=
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
sslverify=
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire= [rabbitmq_erlang-source]
name=rabbitmq_erlang-source
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/SRPMS
repo_gpgcheck=
gpgcheck=
enabled=
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
sslverify=
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=
  • 第二步:查看线上版本号是否生效,如果生效执行安装即可
yum info erlange

执行安装命令

yum install erlang
  • 第三步:安装RabbitMQ服务
https://bintray.com/rabbitmq/rpm/download_file?file_path=rabbitmq-server%2Fv3.7.x%2Fel%2F8%2Fnoarch%2Frabbitmq-server-3.7.22-1.el8.noarch.rpm

MQ基本操作

启动RabbitMQ服务
#service rabbitmq-server start
状态查看
#rabbitmqctl status
启用插件
#rabbitmq-plugins enable rabbitmq_management
重启服务
#service rabbitmq-server restart
添加帐号:name 密码:passwd
#rabbitmqctl add_user name passwd
赋予其administrator角色
#rabbitmqctl set_user_tags name administrator
设置权限
#rabbitmqctl set_permissions -p / name ".*" ".*" ".*"
#后台方式启动
rabbitmq-server -detached 开启rabbitmq 服务

参考博客:https://blog.****.net/weixin_37641832/article/details/85266867#commentsedit

1.下载安装依赖环境

wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -ivh erlang-solutions-1.0-.noarch.rpm
yum install erlang
yum install socat

2.下载安装RabbitMQ

wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm
yum install rabbitmq-server-3.6.-.el7.noarch.rpm

3.开启web管理后台

cd /usr/sbin/
./rabbitmq-plugins enable rabbitmq_management

4.配置RabbitMQ

  • 创建用户名和密码
./rabbitmqctl add_user admin admin123
  • 查看用户角色列表
./rabbitmqctl list_users
  • 设置用户角色
./rabbitmqctl  set_user_tags  admin  administrator
  • 设置用户权限
./rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
  • 登陆web端输入用户名和密码访问

访问地址