Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy a RabbitMQ service in CentOS 7

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In order to solve the problem of how to deploy a RabbitMQ service in CentOS 7, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a simpler and easier way.

RabbitMQ installation

# 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: 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 startup error: Failed to start RabbitMQ broker

Du Niang resolution: the host hostname is misconfigured. The original hostname is vdevops.org, but it is changed to vdevops. Modify the hostname setting in the hosts file.

# 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: 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.

Firewall Settin

[root@linuxprobe~] # firewall-cmd-add-port=5672/tcp-permanent success [root@linuxprobe~] # firewall-cmd-reload success

To use RabbitMQ, add users first

[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.

To use RabbitMQ, also add a virtual host

[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.

To grant permissions to the user of the virtual host, please configure as follows

# 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: using 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

Client access

Http://vdevops:15672/

Rabbitmqadmin usage

You can configure RabbitMQ to use rabbitmqadminlife

Download rabbitmqadmin on Web UI. Log in to Web UI and move to "http:// (hostname or IP address): 15672 / cli", and then display the following screen, where you can download rabbitmqadmin, right-click here to save rabbitmqadmin.txt, and then upload to the server to change to rabbitmqadmin and add execution permissions

Upload rabbitmqadmin to the RabbitMQ server and set the appropriate permissions. This example shows the following settings

[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 | k2rhpzCrZBKkY5WRhUWrGm5DCkkg= | administrator | | linuxprobe | PrunYxK1QXIYrJpek5i Banner RPjn5SME= | administrator | +-+-- +- -+ [root@vdevops bin] # cd [root@vdevops ~] # rabbitmqadmin list users +-+-- +-+ | name | password_hash | tags | +- -+-- +-+ | guest | k2rhpzCrZBKkY5WRhUWrGm5DCkg= | administrator | | linuxprobe | PrunYxK1QXIYrJpek5i RPjn5SME= | administrator | +-+ -+ [root@vdevops ~] # rabbitmqadmin list vhosts +-+-+ | name | tracing | +-+-+ | / | False | | / my_vhost | False | +-+-+ rabbitmqadmin Use more tutorials: 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 Worldlings' 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 LinuxProbearer' 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 | +- -+-+ about CentOS 7 This is the answer to the question of how to deploy a RabbitMQ service in I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report