Learn how to install RabbitMQ Server on CentOS 8 with this step-by-step guide. Set up a reliable message broker to efficiently handle your messaging needs. Follow the instructions to install, configure, and start using RabbitMQ on your Linux system. #centlinux #linux #rabbitmq
Table of Contents
What is RabbitMQ?
RabbitMQ is an open-source message broker software designed to manage the exchange of information between different applications, services, or systems. It facilitates communication by implementing the Advanced Message Queuing Protocol (AMQP) but also supports other protocols like STOMP, MQTT, and HTTP.
Here are some key features of RabbitMQ:
- Message Queuing: It allows messages to be queued until the receiving party is ready to process them, ensuring reliable delivery even if the receiver is temporarily unavailable.
- Durability and Reliability: RabbitMQ offers mechanisms to ensure messages are not lost, even in the event of a server crash, through persistent storage and acknowledgments.
- Scalability: It can handle a high throughput of messages and can be scaled both vertically and horizontally to meet growing demands.
- Flexible Routing: Messages can be routed through exchanges and bindings in various ways, supporting complex routing scenarios like direct, fanout, topic, and headers exchanges.
- Clustering and Federation: RabbitMQ supports clustering to distribute load across multiple nodes and federation to link brokers across different networks.
- Management and Monitoring: It comes with a web-based management interface and tools for monitoring and controlling various aspects of the message broker.
RabbitMQ is commonly used in microservices architectures, data processing pipelines, real-time messaging applications, and anywhere asynchronous communication is needed to decouple producers and consumers, enhancing the efficiency, reliability, and maintainability of systems.
The RabbitMQ source code is available on GitHub Repository and it is distributed under Mozilla Public License.
Read Also: How to install RabbitMQ on Rocky Linux 9
RabbitMQ vs Redis
RabbitMQ and Redis are both popular tools used for messaging and data management, but they serve different purposes and have distinct features. Here’s a comparison of RabbitMQ and Redis:
RabbitMQ
- Purpose: RabbitMQ is primarily a message broker designed for reliable message delivery and complex routing patterns.
- Protocols: Implements AMQP and supports other protocols like STOMP, MQTT, and HTTP.
- Messaging Patterns: Supports various messaging patterns, including point-to-point, publish/subscribe, and complex routing with exchanges.
- Reliability: Offers features like message acknowledgments, durable queues, and persistent storage to ensure message reliability and delivery guarantees.
- Clustering and Federation: Supports clustering to distribute load and ensure high availability, as well as federation for linking brokers across different networks.
- Use Cases: Suitable for distributed systems, microservices architectures, job queuing, and scenarios where message reliability and complex routing are critical.
Redis
- Purpose: Redis is primarily an in-memory data structure store used for caching, real-time analytics, and as a message broker.
- Data Structures: Supports various data structures like strings, lists, sets, sorted sets, hashes, bitmaps, and hyperloglogs.
- Speed: Extremely fast due to its in-memory nature, making it suitable for low-latency use cases.
- Messaging Patterns: Provides a publish/subscribe messaging pattern but lacks the complex routing and reliability features of RabbitMQ.
- Persistence: Offers optional persistence, allowing data to be saved to disk, but primarily focuses on in-memory storage for speed.
- Use Cases: Ideal for caching, session storage, real-time data analytics, leaderboards, and scenarios requiring high-speed data access and manipulation.
Key Differences
- Message Reliability: RabbitMQ excels in scenarios requiring message durability and reliability, with acknowledgments and persistent storage. Redis, while offering optional persistence, is designed for speed and may not provide the same level of message reliability.
- Complex Routing: RabbitMQ supports complex message routing and patterns through exchanges and bindings, making it suitable for sophisticated messaging needs. Redis offers simpler publish/subscribe functionality without advanced routing capabilities.
- Performance: Redis is optimized for high-speed data access and low-latency operations, making it ideal for caching and real-time analytics. RabbitMQ, while performant, focuses more on reliable message delivery and complex routing.
- Use Cases: Choose RabbitMQ for scenarios requiring robust message brokering, complex routing, and high reliability. Opt for Redis when you need fast data access, caching, and simpler publish/subscribe messaging.
In summary, RabbitMQ and Redis serve different roles in a system architecture. RabbitMQ is a specialized message broker with a focus on reliability and routing, while Redis is a versatile in-memory data store optimized for speed and real-time data access.
Recommended Online Training: RabbitMQ: The Complete Guide with Software Architecture Applications
Environment Specification:
We are using a minimal CentOS 8 virtual machine with following specifications.
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Operating System – CentOS 8.3
- Hostname – rabbitmq-01.centlinux.com
- IP Address – 192.168.116.230 /24
Update Your Linux Operating System
Use a ssh client to connect with rabbitmq-01.centlinux.com server as Linux root user.
Update software packages in your Linux operating system to the latest stable releases by using dnf command.
You may read our previous article, if you want to completely upgrade CentOS 7 to CentOS 8 operating system.
# dnf update -y
Check the Linux operating system and Kernel version of the virtual machine in use here.
# cat /etc/redhat-release CentOS Linux release 8.3.2011 # uname -r 4.18.0-240.1.1.el8_3.x86_64
Installing EPEL Yum Repository
Some of the required software packages by the message-broker software are available in EPEL (Extra Packages for Enterprise Linux) yum repository.
Therefore, you are required to enable / install EPEL yum repository on your Linux server before installing RabbitMQ.
# dnf install -y epel-release
Install RabbitMQ Yum Repository
To install a latest version of RabbitMQ software, you can either compile the source code for your preferred Linux distro, or you can add the official yum repository to install the message-broker software from pre-compiled RPM packages.
This software provides a bash script for automated installation of their official yum repository.
Execute the following command to install RabbitMQ yum repository on your Linux server.
# curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
Build cache for newly installed yum repositories.
# dnf makecache CentOS Linux 8 - AppStream 3.5 kB/s | 4.3 kB 00:01 CentOS Linux 8 - BaseOS 4.3 kB/s | 3.9 kB 00:00 CentOS Linux 8 - Extras 1.5 kB/s | 1.5 kB 00:00 Extra Packages for Enterprise Linux Modular 8 - 27 kB/s | 104 kB 00:03 Extra Packages for Enterprise Linux 8 - x86_64 88 kB/s | 8.7 MB 01:40 rabbitmq_rabbitmq-server 99 B/s | 833 B 00:08 rabbitmq_rabbitmq-server-source 152 B/s | 819 B 00:05 Metadata cache created.
Install RabbitMQ Server on CentOS 8
Now, you can easily install RabbitMQ on CentOS 8 by using a dnf command. All the dependencies will be resolved automatically because you have already setup the EPEL yum repository on your Linux server.
# dnf install -y rabbitmq-server
Enable and start RabbitMQ service as follows.
# systemctl enable --now rabbitmq-server.service Created symlink /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service â /usr/lib/systemd/system/rabbitmq-server.service.
Verify the status of RabbitMQ service.
# systemctl status rabbitmq-server.service
Installing RabbitMQ Management Console
Although RabbitMQ software contains sufficient CLI (command line) tools for administration of message-broker server.
But you can optionally install the RabbitMQ management console to perform GUI based administration.
Execute following command to install RabbitMQ management console on your Linux server.
# rabbitmq-plugins enable rabbitmq_management Enabling plugins on node rabbit@rabbitmq-01: rabbitmq_management The following plugins have been configured: rabbitmq_management rabbitmq_management_agent rabbitmq_web_dispatch Applying plugin configuration to rabbit@rabbitmq-01... The following plugins have been enabled: rabbitmq_management rabbitmq_management_agent rabbitmq_web_dispatch started 3 plugins.
Verify that the RabbitMQ management console service is running on default port 15672.
# ss -tulpn | grep 15672 tcp LISTEN 0 128 0.0.0.0:15672 0.0.0.0:* users:(("beam.smp",pid=2949,fd=98))
To allow incoming traffic to RabbitMQ management console, you are required to allow the default service port 15672/tcp in Linux firewall.
Further, RabbitMQ uses port 5672/tcp for AMQP protocol based queues. Therefore, you should also enable it in the Linux Firewall.
Execute the following command to allow required ports in Linux firewall.
# firewall-cmd --permanent --add-port={5672,15672}/tcp success # firewall-cmd --reload success
Create Admin User for RabbitMQ Management Console
RabbitMQ software shipped with a default user guest with password guest. This guest user has administrative privileges but it can only be login to message-broker server from localhost.
Therefore, we need to create another admin user to access RabbitMQ management console remotely.
First, check the already available users on message-broker server.
# rabbitmqctl list_users Listing users ... user tags guest [administrator]
Now, execute following command at Linux command line to create a new user for administration of RabbitMQ server.
# rabbitmqctl add_user admin Str0ngP@ssw0rd Adding user "admin" ... # rabbitmqctl set_user_tags admin administrator Setting tags for user "admin" to [administrator] ...
Open URL http://rabbitmq-01.centlinux.com:15672/ in a web browser.
Login as admin user that you have created in previous steps.
After successful login, you may reach at the dashboard of RabbitMQ Management UI. You can perform complete administration of your message-broker server from here.
We strongly recommend that you should buy and read RabbitMQ in Depth (PAID LINK) by Manning Publications to grow your knowledge in this area and to learn to use the RabbitMQ server for your applications.
Final Thoughts
Setting up RabbitMQ Server on CentOS 8 can greatly enhance your system’s messaging capabilities, ensuring reliable and efficient communication between your applications. By following the proper installation and configuration steps, you can leverage RabbitMQ’s powerful features to improve your overall system performance.
If you need expert assistance with installing RabbitMQ Server on CentOS 8, I offer professional services to help you get started. From initial setup to advanced configuration, I can ensure your RabbitMQ installation is optimized for your specific needs.
Visit my Fiverr profile to learn more about my services and how I can assist you in setting up RabbitMQ Server on CentOS 8. Let’s work together to enhance your system’s messaging infrastructure!