01 November 2014

Overall, RabbitMQ and the AMQP protocol is easy to understand and config. RabbitMQ official site provides helpful guide and examples. Below is a quick script notes of how I played. Format it to a better article if had time.

1. tryout rabbitmq for openstack
    1. rabbitmq HA
        single node, durable queue (write on disk, but no fsync, so still can lose)
        cluster mode, no mirror message, but two rabbitmqs 
                      mirror the messages

        openstack nova:
            rabbit_ha_queues=True/False – to turn queue mirroring on.

    2. following rabbitmq guide on openstack ha manual:

       following https://www.rabbitmq.com/clustering.html:

        1. when joining a cluster, must use hostname

            $ rabbitmqctl join_cluster rabbit@
            Clustering node 'rabbit@openstack-03' with 'rabbit@' ...
            Error: {cannot_discover_cluster,"The nodes provided are either offline or not running"}
            $ rabbitmqctl join_cluster rabbit@openstack-01
            Clustering node 'rabbit@openstack-03' with 'rabbit@openstack-01' ...

        n. try out
            0. user and permission
               rabbitmqctl add_user ...
               rabbitmqctl set_permissions ...
               rabbitmqctl set_user_tags ...
            0.5. connections
               import pika
               connection = pika.BlockingConnection(pika.ConnectionParameters(host='', credentials=pika.PlainCredentials('test', 'password')))
               channel = connection.channel()
            1. create and list queues
                queue_declare(), exchange_declare()
            2. mirror & kill on rabbit
                done by kill -9 ...
            3. topics & message topic
            4. the web ui management plugin
                  browser open: 
                  why I don't have rabbitmq-plugins
                      ls /usr/lib/rabbitmq/lib/rabbitmq_server-3.1.5/sbin/rabbitmq-plugins
                      /usr/lib/rabbitmq/lib/rabbitmq_server-3.1.5/sbin/rabbitmq-plugins enable rabbitmq_management
                      # to restart
                      rabbitmqctl stop
                      rabbitmq-server -detached
                      rabbitmqctl start_app
                      rabbitmqctl cluster_status
                  how to see rabbitmq version: rabbitmqctl status
    3. rabbitmq concepts
       what is virtualhost

    4. from mirantis: ha for mysql, rabbitmq

    5. play with official examples: http://www.rabbitmq.com/tutorials/tutorial-one-python.html
        "hello world"
        "work queues"
        After all, `bind` and `routing_key` is the key

Also, when configuring cluster, don’t forget the .erlang.cookie file.

Rabbit in Openstack

In all service using RabbitMQ HA Cluster, config like below (following Openstack HA Manual)


You can see that we don’t need haproxy here, because openstack service will select rabbitmq node to connect upon failure.

Create an Issue or comment below