CentOS 7中怎么部署一个RabbitMQ服务
发表于:2025-01-23 作者:千家信息网编辑
千家信息网最后更新 2025年01月23日,CentOS 7中怎么部署一个RabbitMQ服务,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。RabbitMQ 安装# Insta
千家信息网最后更新 2025年01月23日CentOS 7中怎么部署一个RabbitMQ服务
CentOS 7中怎么部署一个RabbitMQ服务,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
RabbitMQ 安装
# Install from EPEL [root@vdevops~]# yum --enablerepo=epel -y install rabbitmq-server [root@vdevops~]# systemctl start rabbitmq-server [root@vdevops /]# journalctl -xe Nov 12 01:30:01 vdevops.org CROND[3856]: (root) CMD (/usr/lib64/sa/sa1 1 1) Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: DIAGNOSTICS Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: =========== Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: attempted to contact: [rabbit@vdevops] Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: rabbit@vdevops: Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: * unable to connect to epmd (port 4369) on vdevops: timeout (timed out) Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: current node details: Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - node name: rabbitmqctl3831@vdevops Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - home dir: /var/lib/rabbitmq Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - cookie hash: s++dDMtIhAufFItw+ercBw== Nov 12 01:30:04 vdevops.org polkitd[1007]: Unregistered Authentication Agent for unix-process:3798:36632 (system bus name :1.23, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected f Nov 12 01:30:04 vdevops.org systemd[1]: rabbitmq-server.service: control process exited, code=exited status=2 Nov 12 01:30:04 vdevops.org systemd[1]: Failed to start RabbitMQ broker. -- Subject: Unit rabbitmq-server.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit rabbitmq-server.service has failed. -- -- The result is failed. Nov 12 01:30:04 vdevops.org systemd[1]: Unit rabbitmq-server.service entered failed state. Nov 12 01:30:04 vdevops.org systemd[1]: rabbitmq-server.service failed. Nov 12 01:30:42 vdevops.org systemd[1]: Got automount request for /proc/sys/fs/binfmt_misc, triggered by 3860 (find) Nov 12 01:30:42 vdevops.org systemd[1]: Mounting Arbitrary Executable File Formats File System... -- Subject: Unit proc-sys-fs-binfmt_misc.mount has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit proc-sys-fs-binfmt_misc.mount has begun starting up. Nov 12 01:30:42 vdevops.org systemd[1]: Mounted Arbitrary Executable File Formats File System. -- Subject: Unit proc-sys-fs-binfmt_misc.mount has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit proc-sys-fs-binfmt_misc.mount has finished starting up. -- -- The start-up result is done.
rabbitmq-server启动报错:Failed to start RabbitMQ broker
度娘解析:主机hostname配置错误,原本hostname为vdevops.org,更改为vdevops,修改hosts文件中hostname设置
# Install from EPEL [root@vdevops~]# yum --enablerepo=epel -y install rabbitmq-server [root@vdevops~]# systemctl start rabbitmq-server [root@vdevops /]# journalctl -xe Nov 12 01:30:01 vdevops.org CROND[3856]: (root) CMD (/usr/lib64/sa/sa1 1 1) Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: DIAGNOSTICS Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: =========== Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: attempted to contact: [rabbit@vdevops] Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: rabbit@vdevops: Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: * unable to connect to epmd (port 4369) on vdevops: timeout (timed out) Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: current node details: Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - node name: rabbitmqctl3831@vdevops Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - home dir: /var/lib/rabbitmq Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - cookie hash: s++dDMtIhAufFItw+ercBw== Nov 12 01:30:04 vdevops.org polkitd[1007]: Unregistered Authentication Agent for unix-process:3798:36632 (system bus name :1.23, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected f Nov 12 01:30:04 vdevops.org systemd[1]: rabbitmq-server.service: control process exited, code=exited status=2 Nov 12 01:30:04 vdevops.org systemd[1]: Failed to start RabbitMQ broker. -- Subject: Unit rabbitmq-server.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit rabbitmq-server.service has failed. -- -- The result is failed. Nov 12 01:30:04 vdevops.org systemd[1]: Unit rabbitmq-server.service entered failed state. Nov 12 01:30:04 vdevops.org systemd[1]: rabbitmq-server.service failed. Nov 12 01:30:42 vdevops.org systemd[1]: Got automount request for /proc/sys/fs/binfmt_misc, triggered by 3860 (find) Nov 12 01:30:42 vdevops.org systemd[1]: Mounting Arbitrary Executable File Formats File System... -- Subject: Unit proc-sys-fs-binfmt_misc.mount has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit proc-sys-fs-binfmt_misc.mount has begun starting up. Nov 12 01:30:42 vdevops.org systemd[1]: Mounted Arbitrary Executable File Formats File System. -- Subject: Unit proc-sys-fs-binfmt_misc.mount has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit proc-sys-fs-binfmt_misc.mount has finished starting up. -- -- The start-up result is done.
防火墙设置
[root@linuxprobe~]# firewall-cmd --add-port=5672/tcp --permanent success [root@linuxprobe~]# firewall-cmd --reload success
要使用RabbitMQ,请先添加用户
[root@vdevops ~]# rabbitmqctl add_user linuxprobe password Creating user "linuxprobe" ... ...done. [root@vdevops ~]# rabbitmqctl list_users Listing users ... guest [administrator] linuxprobe [] ...done. # granting admin role to a user is like follows [root@vdevops ~]# rabbitmqctl change_password linuxprobe strongpassword Changing password for user "linuxprobe" ... ...done. # granting admin role to a user is like follows [root@vdevops ~]# rabbitmqctl set_user_tags linuxprobe administrator Setting tags for user "linuxprobe" to [administrator] ... ...done. # deleting a user is like follows [root@vdevops ~]# rabbitmqctl delete_user linuxprobe Deleting user "linuxprobe " ... ...done.
要使用RabbitMQ,也要添加虚拟主机
[root@vdevops ~]# rabbitmqctl add_vhost /my_vhost Creating vhost "/my_vhost" ... ...done. [root@vdevops ~]# rabbitmqctl list_vhosts Listing vhosts ... / /my_vhost ...done. [root@vdevops ~]# rabbitmqctl delete_vhost /my_vhost Deleting vhost "/my_vhost" ... ...done.
给虚拟主机的用户授予权限,请如下配置
# rabbitmqctl set_permissions [-p vhost] [user] [permission ? (modify) (write) (read)] [root@vdevops ~]# rabbitmqctl set_permissions -p /my_vhost linuxprobe ".*" ".*" ".*" Setting permissions for user "linuxprobe" in vhost "/my_vhost" ... ...done. # [root@vdevops ~]# rabbitmqctl list_user_permissions linuxprobe Listing permissions for user "linuxprobe" ... /my_vhost .* .* .* ...done. # deleting permission of a specific user is like follows [root@vdevops ~]# rabbitmqctl clear_permissions -p /my_vhost linuxprobe Clearing permissions for user "linuxprobe" in vhost "/my_vhost" ... ...done.
RabbitMQ:使用Web UI
[root@vdevops ~]# rabbitmq-plugins enable rabbitmq_management The following plugins have been enabled: mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent rabbitmq_management Plugin configuration has changed. Restart RabbitMQ for changes to take effect. [root@vdevops ~]# systemctl restart rabbitmq-server
客户端访问
http://vdevops:15672/
rabbitmqadmin使用
可以配置RabbitMQ使用rabbitmqadmin命
在Web UI上下载rabbitmqadmin。 登录到Web UI并移动到"http://(主机名或IP地址):15672 / cli",然后显示以下屏幕,您可以在这里下载rabbitmqadmin,点击here右键保存rabbitmqadmin.txt,然后上传到服务器上面更改为rabbitmqadmin,并添加执行权限
将rabbitmqadmin上传到RabbitMQ服务器并设置合适的权限,此示例显示如下设置
[root@localhost ~]# ll /usr/local/bin/rabbitmqadmin -rwxr-xr-x. 1 root root 36112 Nov 11 17:23 /usr/local/bin/rabbitmqadmin [root@vdevops bin]# rabbitmqadmin list users +------------+------------------------------+---------------+ | name | password_hash | tags | +------------+------------------------------+---------------+ | guest | k2rhpzCrZBKkY5WRhUWrGm5DCkg= | administrator | | linuxprobe | P+YxK1QXIYrJpek5i//rPjn5SME= | administrator | +------------+------------------------------+---------------+ [root@vdevops bin]# cd [root@vdevops ~]# rabbitmqadmin list users +------------+------------------------------+---------------+ | name | password_hash | tags | +------------+------------------------------+---------------+ | guest | k2rhpzCrZBKkY5WRhUWrGm5DCkg= | administrator | | linuxprobe | P+YxK1QXIYrJpek5i//rPjn5SME= | administrator | +------------+------------------------------+---------------+ [root@vdevops ~]# rabbitmqadmin list vhosts +-----------+---------+ | name | tracing | +-----------+---------+ | / | False | | /my_vhost | False | +-----------+---------+ rabbitmqadmin 更多使用教程参考:http://www.rabbitmq.com/management-cli.html [root@vdevops ~]# rabbitmqadmin declare user name=centos password=password tags=administrator user declared [root@vdevops ~]# rabbitmqadmin declare permission vhost=/vhost01 user=centos configure=".*" write=".*" read=".*" *** vhost_or_user_not_found [root@vdevops ~]# rabbitmqadmin declare vhost name=/vhost01 vhost declared [root@vdevops ~]# rabbitmqadmin declare permission vhost=/vhost01 user=centos configure=".*" write=".*" read=".*" permission declared [root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password declare queue name=my_queue01 queue declared [root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password publish routing_key=my_queue01 payload='Hello RabbitMQ World!' exchange=amq.default Message published [root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password get queue=my_queue01 requeue=false +-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+ <>| routing_key | exchange | message_count | payload | payload_bytes | payload_encoding | properties | redelivered | +-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+ | my_queue01 | | 0 | Hello RabbitMQ World! | 21 | string | | False | +-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+ [root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password publish routing_key=my_queue01 payload='Hello LinuxProbe!' exchange=amq.default Message published [root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password get queue=my_queue01 requeue=false +-------------+----------+---------------+-------------------+---------------+------------------+------------+-------------+ | routing_key | exchange | message_count | payload | payload_bytes | payload_encoding | properties | redelivered | +-------------+----------+---------------+-------------------+---------------+------------------+------------+-------------+ | my_queue01 | | 0 | Hello LinuxProbe! | 17 | string | | False | +-------------+----------+---------------+-------------------+---------------+------------------+------------+-------------+
关于CentOS 7中怎么部署一个RabbitMQ服务问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。
服务
主机
更多
权限
问题
配置
服务器
用户
虚拟主机
帮助
解答
合适
易行
简单易行
上下
内容
原本
地址
客户
客户端
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全底层
网络技术大专还需要考计算机吗
中国的虚拟网络安全案例
vm虚拟机 服务器
阿里云盘代理服务器
php 备份数据库
网络技术应用与研究
windows服务器安全
互联网科技公司总部
服务器可以设置超级管理员吗
查询在线数据库检索
如何查询自己的数据库版本
海关数据库有哪些数据
软件开发需要的许可证
安卓软件开发如何收费
vivo天气用的是什么的数据库
内蒙古水果蔬菜配送软件开发
无线网不能看电视连不上服务器
软件开发人员35岁后的出路
智慧类项目如何选择本地服务器
小米和华为软件开发哪个好
数据库表怎么加唯一索引
百度网盘数据库基地
对软件开发岗位理解
守护网络安全图片
女巫来了搜索不出服务器列表
河南网络安全审计硬件
怎样登录数据库
维护网络安全的主要挑战
济宁联想服务器代理