If you’re trying to install RabbitMQ on CentOS 6 using an RPM file and you’re encountering an error, don’t worry it’s a common issue. This usually happens when the version of Erlang installed on your system doesn’t meet the requirements for RabbitMQ or when there are mismatched dependencies.
I will walk you through the error you’re facing, explain why it’s happening, and provide solutions to get RabbitMQ installed and running on your CentOS machine.
Error Code
Here’s the error you encountered while trying to install RabbitMQ:
[root@osboxes CentOS]# rpm -Uvh rabbitmq-server-3.5.3-1.noarch.rpm
warning: rabbitmq-server-3.5.3-1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 056e8e56: NOKEY
error: Failed dependencies:
erlang >= R13B-03 is needed by rabbitmq-server-3.5.3-1.noarch
Breakdown of the Error:
- Warning: The warning
NOKEY
means that the package signature isn’t verified because it lacks the required key for verification. This is not necessarily a problem unless you’re concerned about the security of the package source. - Error: The critical error is
Failed dependencies: erlang >= R13B-03 is needed
. RabbitMQ requires a version of Erlang that isR13B-03
or higher, but it seems that the system is either not recognizing the installed version of Erlang, or the version installed isn’t the one RabbitMQ needs.
Why Is Erlang Not Recognized?
Looking at the output of your terminal, it shows that Erlang is installed:
[root@osboxes CentOS]# which erl
/usr/bin/erl
[root@osboxes CentOS]#
[root@osboxes CentOS]# erl
Erlang/OTP 17 [erts-6.0] [source-07b8f44] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V6.0 (abort with ^G)
1>
However, RabbitMQ isn’t picking up Erlang, even though version 17 is installed. This could be due to misconfigured environment variables or an incorrect installation path for Erlang.
Verify Erlang Version
The first step is to verify that the Erlang version installed on your system is compatible with RabbitMQ 3.5.3. RabbitMQ 3.5.x requires Erlang version 17.0 or higher. You can check your version by running:
erl -version
Since your output shows Erlang version 17, this should meet the minimum version requirement. The problem, however, is likely due to RabbitMQ not detecting Erlang correctly.
Set the ERLANG_HOME Environment Variable
RabbitMQ relies on the ERLANG_HOME
environment variable to locate Erlang. If this variable isn’t set correctly, RabbitMQ may not be able to detect the installed version of Erlang, even if it’s present on the system.
Here’s how you can set the ERLANG_HOME
variable:
- Edit the Bash Profile: Open the
.bash_profile
file to set the environment variable:
nano ~/.bash_profile
- Add the ERLANG_HOME Variable: Add the following line to the file:
export ERLANG_HOME=/usr/lib64/erlang
Ensure that the path to Erlang (/usr/lib64/erlang
) matches the location where Erlang is installed on your system. You can check the location by running:
whereis erlang
- Source the Profile: After saving the file, run the following command to apply the changes:
source ~/.bash_profile
- Verify the Environment Variable: Finally, ensure the variable is set correctly by running:
echo $ERLANG_HOME
It should output the path where Erlang is installed.
Use the Correct Erlang Version
If RabbitMQ still can’t detect the installed version of Erlang, you may need to install a different Erlang version that’s compatible with RabbitMQ 3.5.3. Here’s how you can upgrade or install the required Erlang version:
- Install Erlang from the Erlang Solutions Repository: CentOS 6 users can install the required version of Erlang using the Erlang Solutions repository
wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
dpkg -i erlang-solutions_2.0_all.deb
yum install erlang
- Upgrade Erlang: If you continue facing issues, you might need to upgrade Erlang to a newer version. You can either use a package manager or download the latest version from the official Erlang website.
Re-run the RabbitMQ Installation
After ensuring that the ERLANG_HOME
variable is correctly set and that the right version of Erlang is installed, retry the RabbitMQ installation:
rpm -Uvh rabbitmq-server-3.5.3-1.noarch.rpm
Alternative RabbitMQ Installation Methods
If you’re still facing issues, you can consider using one of these alternative installation methods:
- Install RabbitMQ from the Official Repository: Instead of manually installing the RPM file, you can install RabbitMQ from the official RabbitMQ repository. This method simplifies the process, as it handles dependencies for you. Follow the official RabbitMQ installation guide for detailed steps.
- Use Docker: If your system supports Docker, you can quickly set up RabbitMQ in a container. This bypasses the need to deal with package dependencies on your system. To run RabbitMQ in a Docker container, you can use the following command:
docker run -d --name rabbitmq -p 15672:15672 -p 5672:5672 rabbitmq:management
Additional Practice Functionality
Once RabbitMQ is up and running, you can practice by adding more functionality:
- Test RabbitMQ Installation: After installation, you can check if RabbitMQ is running by visiting the RabbitMQ management web UI at
http://localhost:15672
. The default login credentials areguest
for both the username and password. - Create a Queue and Send Messages: You can practice creating a queue and sending messages through RabbitMQ. Here’s a command to create a queue using the RabbitMQ CLI:
rabbitmqctl add_queue my_queue
To send a message, use:
rabbitmqctl send_message my_queue "Hello, RabbitMQ!"
- Integrate RabbitMQ with Python: Use the
pika
library to integrate RabbitMQ into a Python project. Here’s an example of how to publish and consume messages:
import pika # Establish connection and channel connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() # Declare a queue channel.queue_declare(queue='hello') # Send a message channel.basic_publish(exchange='', routing_key='hello', body='Hello World!') print("Sent 'Hello World!'") # Close the connection connection.close()
Conclusion
By following these steps, you should be able to resolve the Erlang dependency issue and successfully install RabbitMQ on your CentOS 6 machine. Once you’ve got RabbitMQ running, you can experiment with more advanced features, such as message queuing and integration with various programming languages like Python.