1.下载
rabbit下载
当前最新版是3.9,这里我用的是3.8.26
官网 :https://www.rabbitmq.com/download.html
选择版本:https://github.com/rabbitmq/rabbitmq-server/releases
erlang下载
注意24版本的erlang只支持Linux8。这里我就只用23了
https://packagecloud.io/rabbitmq/erlang
https://packagecloud.io/rabbitmq/erlang/packages/el/7/erlang-23.3.4.10-1.el7.x86_64.rpm
2.安装
先安装erlang依赖再安装rabbit
#安装命令按照顺序执行等待即可
rpm -ivh erlang-21.3.8.21-1.el7.x86_64.rpm yum install socat -y rpm -ivh rabbitmq-server-3.8.8-1.el7.noarch.rpm
安装示例
#erlang [root@dlb dlb]# rpm -ivh erlang-23.3.4.10-1.el7.x86_64.rpm warning: erlang-23.3.4.10-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY Preparing... ################################# [100%] Updating / installing... 1:erlang-23.3.4.10-1.el7 ################################# [100%]
#官方要求安装的依赖 输入命令等待 [root@dlb dlb]# yum install socat -y
#.......
[root@dlb dlb]# rpm -ivh rabbitmq-server-3.8.26-1.el7.noarch.rpm warning: rabbitmq-server-3.8.26-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 6026dfca: NOKEY Preparing... ################################# [100%] Updating / installing... 1:rabbitmq-server-3.8.26-1.el7 ################################# [100%]
到这里软件算是安装完毕,测试稍后
3.安装web管理界面
安装了这个可以在Windows端的浏览器查看rabbit的信息
默认情况下,是没有安装web端的客户端插件,需要安装才可以生效
[root@dlb dlb]# rabbitmq-plugins enable rabbitmq_management Enabling plugins on node rabbit@iZbp1e0fmgc5gof1ly9cmlZ: rabbitmq_management ......
注意关闭防火墙,或者打开端口号:15672否则访问不到
status firewalld #查看防火墙状态 systemctl stop firewalld #关闭防火墙 systemctl disable firewalld
4.启动
# 启动服务 systemctl start rabbitmq-server # 查看服务状态 systemctl status rabbitmq-server # 开机自启动 systemctl enable rabbitmq-server # 停止服务 systemctl stop rabbitmq-server # 重启服务 systemctl restart rabbitmq-server
服务启动和关闭需要一点点时间等待
启动示例
[root@iZbp1e0fmgc5gof1ly9cmlZ dlb]# systemctl start rabbitmq-server #启动 [root@iZbp1e0fmgc5gof1ly9cmlZ dlb]# 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-12-25 20:28:46 CST; 27s ago Main PID: 4451 (beam.smp) Status: "Initialized" CGroup: /system.slice/rabbitmq-server.service ├─4451 /usr/lib64/erlang/erts-11.2.2.9/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 51... ├─4466 erl_child_setup 32768 ├─4492 /usr/lib64/erlang/erts-11.2.2.9/bin/epmd -daemon ├─4515 inet_gethost 4 └─4516 inet_gethost 4
5.登录管理界面
网页打开ip:15672
如图所示需要账号密码,默认的账号密码都是:guest
但这个限制本地登录
添加用户
# 创建用户 账号 admin 密码123456 rabbitmqctl add_user admin 123456 # 设置用户角色admin为管理员 rabbitmqctl set_user_tags admin administrator # 为用户添加资源权限 # set_permissions [-p <vhostpath>] <user> <conf> <write> <read> rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" # 添加配置、写、读权限 #查看用户列表 [root@iZbp1e0fmgc5gof1ly9cmlZ dlb]# rabbitmqctl list_users
操作示例
[root@iZbp1e0fmgc5gof1ly9cmlZ dlb]# rabbitmqctl add_user admin 1223344 Adding user "admin" ... Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more. [root@iZbp1e0fmgc5gof1ly9cmlZ dlb]# rabbitmqctl set_user_tags admin administrator Setting tags for user "admin" to [administrator] ... [root@iZbp1e0fmgc5gof1ly9cmlZ dlb]# rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" Setting permissions for user "admin" in vhost "/" ...
使用刚刚创建的账号密码登录
用户级别:
-
administrator:可以登录控制台、查看所有信息、可以对 rabbitmq 进行管理
-
monitoring:监控者 登录控制台,查看所有信息
-
policymaker:策略制定者 登录控制台,指定策略
-
managment:普通管理员 登录控制台
关闭应用的命令为:rabbitmqctl stop_app
清除的命令为:rabbitmqctl reset
重新启动命令为:rabbitmqctl start_app