Tech Tips

  1. Uncategorized
  2. 278 view

[RabbitMQ]How to install RabbitMQ in Ubuntu, run sample app and management screen

Contents

Goal

Do following:
  1. Install RabbitMQ in Ubuntu(12.04)
  2. Run sample ruby client
  3. Run Web UI

Environment

  • OS
    • Linux version 3.2.0-64-generic (buildd@kissel) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #97-Ubuntu SMP Wed Jun 4 22:04:21 UTC 2014
  • RabbitMQ
    • 3.5
  • ruby
    • 2.1.2p95

Procedure

1. Install RabbitMQ in Ubuntu

We need to add one line to source list.
Following command add one line to source list, add signature to apt, install with apt-get install and check running status.
sudo vim /etc/apt/sources.list.d/rabbitmq.list
=====
deb http://www.rabbitmq.com/debian/ testing main
=====

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

# apt-get
sudo apt-get update
sudo apt-get install rabbitmq-server

# Check status
sudo /etc/init.d/rabbitmq-server status
=====
Status of node rabbit@www1242up ...
[{pid,21208},
 {running_applications,[{rabbit,"RabbitMQ","3.5.0"},
                        {mnesia,"MNESIA  CXC 138 12","4.5"},
                        {os_mon,"CPO  CXC 138 46","2.2.7"},
                        {xmerl,"XML parser","1.2.10"},
                        {sasl,"SASL  CXC 138 11","2.1.10"},
                        {stdlib,"ERTS  CXC 138 10","1.17.5"},
                        {kernel,"ERTS  CXC 138 10","2.14.5"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:3:3] [rq:3] [async-threads:30] [kernel-poll:true]\n"},
 {memory,[{total,28074848},
          {connection_readers,0},
          {connection_writers,0},
          {connection_channels,0},
          {connection_other,2704},
          {queue_procs,2704},
          {queue_slave_procs,0},
          {plugins,0},
          {other_proc,9304344},
          {mnesia,60560},
          {mgmt_db,0},
          {msg_index,34680},
          {other_ets,776160},
          {binary,8632},
          {code,14672972},
          {atom,1363353},
          {other_system,1848739}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,840266547},
 {disk_free_limit,50000000},
 {disk_free,165005750272},
 {file_descriptors,[{total_limit,924},
                    {total_used,3},
                    {sockets_limit,829},
                    {sockets_used,1}]},
 {processes,[{limit,1048576},{used,125}]},
 {run_queue,0},
 {uptime,20}]
=====

2. Run sample ruby client

bunny allows us to write client code easily.
At first I’ll write Gemfile.
source "https://rubygems.org"

gem "bunny", ">= 1.7.0"
Next is client code.
#!/usr/bin/env ruby
# encoding: utf-8

require "rubygems"
require "bunny"

conn = Bunny.new
conn.start

ch = conn.create_channel
q  = ch.queue("bunny.examples.hello_world", :auto_delete => true)
x  = ch.default_exchange

q.subscribe do |delivery_info, metadata, payload|
  puts "Received #{payload}"
end

x.publish("Hello!", :routing_key => q.name)

sleep 1.0
conn.close
Let’s run the client with following command.
bundle install
=====
Fetching gem metadata from https://rubygems.org/...
Resolving dependencies...
Installing amq-protocol 1.9.2
Installing bunny 1.7.0
Using bundler 1.7.4
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
=====

ls
=====
client.rb  Gemfile  Gemfile.lock
=====

bundle exec ruby client.rb
=====
Received Hello!
=====
It looks work.

3. Run management screen(Web UI)

RabbitMQ can use plugins.
Management screen is one of the plugins.
I’ll enable the plugin with following commands.
sudo rabbitmq-plugins list
=====
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status:   * = running on rabbit@www1242up
 |/
[  ] amqp_client                       3.5.0
[  ] cowboy                            0.5.0-rmq3.5.0-git4b93c2d
[  ] eldap                             3.5.0-gite309de4
[  ] mochiweb                          2.7.0-rmq3.5.0-git680dba8
[  ] rabbitmq_amqp1_0                  3.5.0
[  ] rabbitmq_auth_backend_ldap        3.5.0
[  ] rabbitmq_auth_mechanism_ssl       3.5.0
[  ] rabbitmq_consistent_hash_exchange 3.5.0
[  ] rabbitmq_federation               3.5.0
[  ] rabbitmq_federation_management    3.5.0
[  ] rabbitmq_management               3.5.0
[  ] rabbitmq_management_agent         3.5.0
[  ] rabbitmq_management_visualiser    3.5.0
[  ] rabbitmq_mqtt                     3.5.0
[  ] rabbitmq_shovel                   3.5.0
[  ] rabbitmq_shovel_management        3.5.0
[  ] rabbitmq_stomp                    3.5.0
[  ] rabbitmq_test                     3.5.0
[  ] rabbitmq_tracing                  3.5.0
[  ] rabbitmq_web_dispatch             3.5.0
[  ] rabbitmq_web_stomp                3.5.0
[  ] rabbitmq_web_stomp_examples       3.5.0
[  ] sockjs                            0.3.4-rmq3.5.0-git3132eb9
[  ] webmachine                        1.10.3-rmq3.5.0-gite9359c7
=====

sudo rabbitmq-plugins enable rabbitmq_management
=====
The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management

Applying plugin configuration to rabbit@... started 6 plugins.
=====

sudo rabbitmq-plugins list
=====
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status:   * = running on rabbit@www1242up
 |/
[e*] amqp_client                       3.5.0
[  ] cowboy                            0.5.0-rmq3.5.0-git4b93c2d
[  ] eldap                             3.5.0-gite309de4
[e*] mochiweb                          2.7.0-rmq3.5.0-git680dba8
[  ] rabbitmq_amqp1_0                  3.5.0
[  ] rabbitmq_auth_backend_ldap        3.5.0
[  ] rabbitmq_auth_mechanism_ssl       3.5.0
[  ] rabbitmq_consistent_hash_exchange 3.5.0
[  ] rabbitmq_federation               3.5.0
[  ] rabbitmq_federation_management    3.5.0
[E*] rabbitmq_management               3.5.0
[e*] rabbitmq_management_agent         3.5.0
[  ] rabbitmq_management_visualiser    3.5.0
[  ] rabbitmq_mqtt                     3.5.0
[  ] rabbitmq_shovel                   3.5.0
[  ] rabbitmq_shovel_management        3.5.0
[  ] rabbitmq_stomp                    3.5.0
[  ] rabbitmq_test                     3.5.0
[  ] rabbitmq_tracing                  3.5.0
[e*] rabbitmq_web_dispatch             3.5.0
[  ] rabbitmq_web_stomp                3.5.0
[  ] rabbitmq_web_stomp_examples       3.5.0
[  ] sockjs                            0.3.4-rmq3.5.0-git3132eb9
[e*] webmachine                        1.10.3-rmq3.5.0-gite9359c7
=====

#Check port number
netstat -l
=====
Proto Recv-Q Send-Q Local Address           Foreign Address         State
...
tcp        0      0 *:15672                 *:*                     LISTEN
...
=====

#Allow the port
sudo ufw allow 15672
=====
Rule added
Rule added (v6)
=====

# Add user setting
sudo vim /etc/rabbitmq/rabbitmq.config
=====
[{rabbit, [{loopback_users, []}]}].
=====

# Restart
sudo /etc/init.d/rabbitmq-server restart
If you access “http://targethost:15672”, you can reach the following page.
20150314_rabbitmq_login
Initial account is username => guest, password => guest.
You can check queue and server resource status in the screen.
20150314_rabbitmq_webui

Refenrece

Uncategorized recent post

  1. Run Amazon FreeRTOS on M5Stack Core2 for AWS …

  2. Udacity Self-Driving Car Engineer Nanodegree …

  3. Install sbt 1.0.0 and run sample template

  4. Visualization of Neural Network and its Train…

  5. [Machine Learning]Created docker image includ…

関連記事

Comment

  1. No comments yet.

  1. No trackbacks yet.

PAGE TOP