Difference between revisions of "AMQP server: RabbitMQ"

(Created page with " ----------------------------- Requirements ----------------------------- # PostgreSQL + Python sudo apt-get install postgresql python3 sudo apt-get install python3-amqplib ...")
 
Line 1: Line 1:
 +
[[Category:Linux]]
 +
[[Category:Development]]
  
-----------------------------
+
RabbitMQ is an excellent low-level messaging server. You can use it with different technologies.
Requirements
 
-----------------------------
 
  
# PostgreSQL + Python
 
sudo apt-get install postgresql python3
 
sudo apt-get install python3-amqplib
 
  
-----------------------------
+
 
Repository
+
=Requirements=
-----------------------------
+
 
 +
You need PostgreSQL + Python
 +
 
 +
<syntaxhighlight lang="bash">
 +
apt-get install postgresql python3
 +
apt-get install python3-amqplib
 +
</syntaxhighlight>
 +
 
 +
 
 +
 
 +
=Installation=
 +
 
 +
 
 +
==Add repository==
 +
 
 +
You must add a new repository for RabbitMQ.
 +
* Even though the name is "testing" it's actually the latest stable version
 +
* They use "testing" as this is not in the "main" Ubuntu repo yet.
 +
 
 
[source: http://www.rabbitmq.com/install-debian.html]
 
[source: http://www.rabbitmq.com/install-debian.html]
  
# Add rabbitMQ repository
 
sudo vim /etc/apt/sources.list
 
  
 +
<syntaxhighlight lang="bash">
 +
vim /etc/apt/sources.list
 +
<syntaxhighlight>
 +
 +
 +
Add the new repository
 +
 +
<syntaxhighlight lang="bash">
 
deb http://www.rabbitmq.com/debian/ testing main
 
deb http://www.rabbitmq.com/debian/ testing main
 +
</syntaxhighlight>
  
  
--- !!! Even the name is "testing" it's actually the latest stable version
+
Add repo key
--- They use "testing" as this is not in the "main" distro repo yet.
 
  
 
+
<syntaxhighlight lang="bash">
# Add repo key
 
 
wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
 
wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
 
sudo apt-key add rabbitmq-signing-key-public.asc
 
sudo apt-key add rabbitmq-signing-key-public.asc
 +
</syntaxhighlight>
 +
 +
 +
Update package list
  
# Update package list
+
<syntaxhighlight lang="bash">
 
sudo apt-get update
 
sudo apt-get update
 +
</syntaxhighlight>
 +
  
  
-----------------------------
+
==Binary installation==
RabbitMQ installation
 
-----------------------------
 
  
# server installation
+
<syntaxhighlight lang="bash">
sudo apt-get install rabbitmq-server amqp-tools  
+
apt-get install rabbitmq-server amqp-tools  
 +
</syntaxhighlight>
  
  
-----------------------------
+
 
Enable plugins
+
==Enable plugins==
-----------------------------
+
 
# Start server
+
Enable RabbitMQ command line client
service rabbitmq-server start
+
 
# enable command line client
+
<syntaxhighlight lang="bash">
 
rabbitmq-plugins enable amqp_client
 
rabbitmq-plugins enable amqp_client
# Enable web console
+
</syntaxhighlight>
 +
 
 +
 
 +
Enable web console
 +
 
 +
<syntaxhighlight lang="bash">
 
rabbitmq-plugins enable rabbitmq_management
 
rabbitmq-plugins enable rabbitmq_management
#restart rabbit rabbitmq-server service
+
</syntaxhighlight>
 +
 
 +
 
 +
Restart server to take on your changes
 +
 
 +
<syntaxhighlight lang="bash">
 
service rabbitmq-server restart
 
service rabbitmq-server restart
 +
</syntaxhighlight>
  
Default ports:
 
Web console: 15672
 
AMQP Messages: 5672
 
  
  
-----------------------------
+
Now you can access RabbitMQ using the default ports:
User creation
+
* Web console: TCP 15672, http://localhost:15672/
-----------------------------
+
* AMQP Messages: TCP 5672
  
## add admin user
 
rabbitmqctl add_user rtd <Strong password>
 
  
# set user rights
+
 
 +
==Create administration user==
 +
 
 +
Create new user, replace ''rtd'' by your username.
 +
 
 +
<syntaxhighlight lang="bash">
 +
rabbitmqctl add_user rtd  strong_password
 +
</syntaxhighlight>
 +
 
 +
 
 +
Set user rights
 +
 
 +
<syntaxhighlight lang="bash">
 
rabbitmqctl set_user_tags rtd administrator
 
rabbitmqctl set_user_tags rtd administrator
 
rabbitmqctl set_permissions -p / rtd ".*" ".*" ".*"
 
rabbitmqctl set_permissions -p / rtd ".*" ".*" ".*"
 +
</syntaxhighlight>
  
# Remove default admin user  
+
 
 +
Remove default guest user  
 +
 
 +
<syntaxhighlight lang="bash">
 
rabbitmqctl delete_user guest
 
rabbitmqctl delete_user guest
 +
</syntaxhighlight>
  
# restart service
+
 
 +
Restart service to take on your changes
 +
 
 +
<syntaxhighlight lang="bash">
 
service rabbitmq-server restart
 
service rabbitmq-server restart
 +
</syntaxhighlight>
 +
 +
 +
 +
=Advanced configuration=
 +
 +
==Change port number==
 +
 +
source: https://www.rabbitmq.com/configure.html
 +
  
-----------------------------
+
If activeMq is install, stop it
Change port
 
-----------------------------
 
[source: https://www.rabbitmq.com/configure.html]
 
  
# if activeMq is install, stop it
+
<syntaxhighlight lang="bash">
 
service activemq stop
 
service activemq stop
 +
</syntaxhighlight>
  
 
sudo vim /etc/rabbitmq/rabbitmq-env.conf
 
sudo vim /etc/rabbitmq/rabbitmq-env.conf

Revision as of 14:58, 11 July 2014


RabbitMQ is an excellent low-level messaging server. You can use it with different technologies.


Requirements

You need PostgreSQL + Python

apt-get install postgresql python3
apt-get install python3-amqplib


Installation

Add repository

You must add a new repository for RabbitMQ.

  • Even though the name is "testing" it's actually the latest stable version
  • They use "testing" as this is not in the "main" Ubuntu repo yet.

[source: http://www.rabbitmq.com/install-debian.html]


vim /etc/apt/sources.list
<syntaxhighlight>


Add the new repository

<syntaxhighlight lang="bash">
deb http://www.rabbitmq.com/debian/ testing main


Add repo key

wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc


Update package list

sudo apt-get update


Binary installation

apt-get install rabbitmq-server amqp-tools


Enable plugins

Enable RabbitMQ command line client

rabbitmq-plugins enable amqp_client


Enable web console

rabbitmq-plugins enable rabbitmq_management


Restart server to take on your changes

service rabbitmq-server restart


Now you can access RabbitMQ using the default ports:


Create administration user

Create new user, replace rtd by your username.

rabbitmqctl add_user rtd  strong_password


Set user rights

rabbitmqctl set_user_tags rtd administrator
rabbitmqctl set_permissions -p / rtd ".*" ".*" ".*"


Remove default guest user

rabbitmqctl delete_user guest


Restart service to take on your changes

service rabbitmq-server restart


Advanced configuration

Change port number

source: https://www.rabbitmq.com/configure.html


If activeMq is install, stop it

service activemq stop

sudo vim /etc/rabbitmq/rabbitmq-env.conf

  1. Add the following at the beggining of the file

NODE_PORT=5673

  1. restart services

service rabbitmq-server restart service activemq start



Firewall


  1. open firewall ports

vi /etc/init.d/firewall

  1. add this rules
  2. rabbitMq

$IPT -A INPUT -p tcp --dport 15672 -j ACCEPT $IPT -A INPUT -p tcp --dport 5673 -j ACCEPT


  1. Output

DO NOT FILTER OUTPUT since RabbitMQ port is dynamic. :(



Update startup


cd /etc/init.d/ update-rc.d rabbitmq-server defaults



Sources: https://www.rabbitmq.com/management-cli.html https://www.rabbitmq.com/configure.html https://www.rabbitmq.com/tutorials/tutorial-two-python.html