Installing RabbitMQ on a local vcap

Assuming you have already done the https://github.com/cloudfoundry/vcap song and dance. I always have a terriable time trying to get items to work on cloudfoundry.com so decided to see how much of RabbitMQ is available in vcap. Here is a hack to getting RabbitMQ running. I could totally have a baked install and thus the reason why I went down this dark path.

Update and install the following decencies
cd ~/cloudfoundry/vcap
git pull
gem install bundler –no-rdock –no-ri
rake bundler:install
gem install amqp –version ‘0.7.1’
gem install daemons –version ‘1.1.0’
gem install thin –version ‘1.2.8’
cd ~
gem update vmc

Edit ~/cloudfoundry/vcap/bin/vcap and add rabbit as a service

Fire up the services by cd ~/cloudfoundry/vcap && bin/vcap start

Set target and login
vmc target api.vcap.me
vmc login –email blahblah@blahblah.com –passwd blahblahblah

BTW, if you forgot your username or password it can be found in ~/cloudfoundry/vcap/cloud_controller/db/cloudcontroller.sqlite3 . Just rip this file apart or add a new hash for the password.
Check to see the runtimes are correctly available


Check out the following sample to package up
git clone https://github.com/rabbitmq/rabbitmq-cloudfoundry-samples.git
cd ~/rabbitmq-cloudfoundry-samples/spring && mvn package && cd target && vmc push

You can follow http://support.cloudfoundry.com/entries/20322602-getting-started-with-the-rabbitmq-service-from-a-spring-application to deploy the app correctly.

Before you actually create the service you want to check the logs out… This is the issue I had with a local vcap and rabbit. The user and vhost never get added to rabbitmq, doing this manually will make the service work. Make sure to tail the logs before running the vmc create-service. That way you can pull out the actual username/password/vhost that vcap will try to send to rabbitmqctl.

tail -f ~/cloudfoundry/vcap/cloud_controller/log/development.log
vmc create-service rabbitmq
vmc bind-service rabbitmq-XXXXX rabbit-simple


After creating the service the logs will display the username/password/vhost but when you bind the service to an application the username and password change and you need to add those by hand with rabbitmqctl

The first set of username/password will not be used, after binding you need the current ones. In this case they were
user: uz25LQnFmJTrC
pass: pfah5U5dFiSRo
vhost: vf883c025ec524e55b11b0db4dcce928e

At this point you can add the data by hand, restart rabbitmq (sometimes queues decided to get eaten) and you should be ready to go.
sudo rabbitmqctl add_user uz25LQnFmJTrC pfah5U5dFiSRo
sudo rabbitmqctl add_vhost vf883c025ec524e55b11b0db4dcce928e
sudo rabbitmqctl set_permissions -p vf883c025ec524e55b11b0db4dcce928e uz25LQnFmJTrC “.*” “.*” “.*”
sudo /etc/init.d/rabbitmq-server restart




Some useful logs to keep tailed
~/cloudfoundry/vcap/cloud_controller/log/development.log
/var/log/rabbitmq/*

Did I need to go to all this trouble, probably not, but it was fun to investigate what vcap is made and how things are done internally. Since all the code looks like its in place, my guess on how to properly enable rabbit service is to find out what should triggers the calls to ~/cloudfoundry/vcap/services/rabbit/lib/rabbit_service/rabbit_node.rb and debug why the calls are actually failing to contact the local rabbitmq service.

Useful links
http://support.cloudfoundry.com/entries/20346977-rabbitmq-cloud-foundry-cloud-messaging-that-just-works
https://github.com/rabbitmq/rabbitmq-cloudfoundry-samples
http://support.cloudfoundry.com/entries/20322602-getting-started-with-the-rabbitmq-service-from-a-spring-application
https://github.com/cloudfoundry/vcap
http://support.cloudfoundry.com/entries/20012337-getting-started-guide-command-line-vmc-users
https://raw.github.com/cloudfoundry/vcap/master/setup/install
http://support.cloudfoundry.com/entries/20052116-rabbit-on-local-instance-of-vcap
http://www.rabbitmq.com/admin-guide.html
http://www.rabbitmq.com/man/rabbitmqctl.1.man.html

About financecoding
I enjoy coding in dart.

11 Responses to Installing RabbitMQ on a local vcap

  1. Simon So says:

    Hi,

    I am not sure why you didn’t run into this permission error when rabbit_node tries to run the rabbitmq-server. rabbitmq-server needs to be run as user rabbitmq. Do you “sudo bin/vcap start” or your account “adam” is an administrative account?

    Thanks,
    Simon

    rabbit_gateway : RUNNING
    rabbit_node : STOPPED
    LOG:
    I, [2011-08-17T00:54:47.408044 #15654] INFO — : RMQaaS-Node: Initializing
    D, [2011-08-17T00:54:47.460094 #15654] DEBUG — : RMQaaS-Node: Connected to node mbus
    /usr/lib/rabbitmq/bin/rabbitmq-server: 64: cannot create /var/log/rabbitmq/rabbit@vmlin-simonso-sasl.log.1: Permission denied
    W, [2011-08-17T00:54:47.544563 #15654] WARN — : rabbitmqctl error: Activating RabbitMQ plugins …
    ERROR: Could not delete dir /var/lib/rabbitmq/mnesia/rabbit@vmlin-simonso-plugins-expand ({cannot_delete,
    “/var/lib/rabbitmq/mnesia/rabbit@vmlin-simonso-plugins-expand/rabbit.rel”,
    eacces})

    Only root or rabbitmq should run rabbitmq-server

    F, [2011-08-17T00:54:47.544723 #15654] FATAL — : Error Code: 31307, Error Message: Could not start rabbitmq server
    /home/sso/cloudfoundry/vcap/services/rabbit/lib/rabbit_service/rabbit_node.rb:304:in `start_server’
    /home/sso/cloudfoundry/vcap/services/rabbit/lib/rabbit_service/rabbit_node.rb:56:in `pre_send_announcement’
    /home/sso/cloudfoundry/vcap/services/base/lib/base/node.rb:56:in `on_connect_node’
    /home/sso/cloudfoundry/vcap/services/base/lib/base/base.rb:36:in `block in initialize’
    /home/sso/.rvm/gems/ruby-1.9.2-p180/gems/nats-0.4.8/lib/nats/client.rb:456:in `call’
    /home/sso/.rvm/gems/ruby-1.9.2-p180/gems/nats-0.4.8/lib/nats/client.rb:456:in `block in connection_completed’
    /home/sso/.rvm/gems/ruby-1.9.2-p180/gems/nats-0.4.8/lib/nats/client.rb:413:in `call’
    /home/sso/.rvm/gems/ruby-1.9.2-p180/gems/nats-0.4.8/lib/nats/client.rb:413:in `receive_data’
    /home/sso/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine’
    /home/sso/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run’
    /home/sso/cloudfoundry/vcap/services/rabbit/bin/rabbit_node:93:in `’

  2. Pingback: Activer RabbitMQ sur cloud foundry standalone | Alexander blog

  3. ramonskie says:

    did any one solved the permission problem?

  4. Is it really that simple? By just having the gems of Oracle database for example that means this little edits will bind the service?

  5. George says:

    I cannot seem to get this to work with a Chef based installation of vcap. The normal installation is very much broken so Chef seems to be the most reasonable choice at the moment.

    Has anyone had success in getting RabbitMQ to work with a Chef-based vcap installation?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: