RABIBTMQ installation and cluster configuration-linux

Source: Internet
Author: User
Tags rabbitmq

Installing RABBITMQ

RabbitMQ is a popular open source Message Queuing system developed in Erlang language, so it is necessary to install Erlang dependencies and Erlang first.

  1. Install the basic environment that Erlang relies on and install it in Yum mode:

    yum -y installgcc glibc-devel makencurses-devel openssl-devel autoconf
  2. Download and install Erlang, which uses erlang-r15b-02.1.el6.x86_64.rpm, copies it to a virtual machine and installs it in Yum mode:

    yum -y installerlang-R15B-02.1.el6.x86_64.rpm
  3. Test the Erlang environment, enter the ERL


  4. Download RABBITMQ official Server Edition and install
    Address: http://www.rabbitmq.com/install-rpm.html
    This is the rabbitmq-server-3.3.5-1.noarch.rpm version, which is uploaded to the virtual machine via the XFTP software or other means, and is installed using the Yum method:

    yum -y installrabbitmq-server-3.3.5-1.noarch.rpm
Start RABBITMQ
  1. Starting Rabbitmq-server through System services

    If it doesn't start properly, you can troubleshoot by logging

    Alternatively, you can see whether the RABBITMQ service has started with the Chkconfig command:

    chkconfig --list rabbitmq-server
  2. Open the RABBITMQ Web management plugin
    First look at the plugin list for information about:

    rabbitmq-plugins list

    To start the Web management plug-in:

    rabbitmq-plugins enablerabbitmq_management

    If the plugin is successfully started, use the service rabbitmq-server Restart command to restart the RABBITMQ services for it to take effect.

  3. Accessing the Web Management plug-in interface
    Open the Web interface through the browser, the address is http://ip:15672/mgmt/, the default user name and password are guest.
    If you cannot access the RABBITMQ log information, there are two possible reasons: Port 15672 is occupied and the firewall is turned on.
    To turn off the firewall with the following command, it is recommended to turn it on automatically:

    service iptables stopchkconfig iptables off
  4. Guest account cannot log on to Web admin interface
    For security reasons, RABBITMQ from 3.3, the guest user is only allowed to log on via localhost by default.
    You can remove these access restrictions by creating a Rabbitmq.config file.

    vi /etc/rabbitmq/rabbitmq.config# 内容如下[{rabbit,     [        %%%% Network Connectivity        %% ====================        %%        %% By default, RabbitMQ will listen on all interfaces, using        %% the standard (reserved) AMQP port.        %%        {tcp_listeners, [5672]},        {loopback_users, ["admin"]}    ]}].
Build RABBITMQ Cluster

RABBITMQ clusters are dependent on Erlang's clusters to work, so you must first build a clustered environment of Erlang.

The nodes in Erlang's cluster are implemented by a magic cookie, which is stored in the. Erlang.cookie,

  1. Set node cookie
    Cookie file under/VAR/LIB/RABBITMQ

    Place the contents of the. erlang.cookie file for that node (such as "xxxxxxxxxxxxx "string) copied to all other nodes in the same file,

    chmod 700. Erlang.cookie Code class= "Bash functions" >echo -n " Xxxxxxxxxxxxx " > .erlang.cookie  chmod 400. Erlang.cookie

    Note: When copying a string, do not use such useless information as the sky grid

     

  2. Ensure that host names between nodes can be resolved with each other
    Add all machines in the cluster (IP address hostname) separately to the hosts file for each machine:


  3. Nodes make up a cluster
    Start the Rabbitmq-server service first, run the nodes of each machine, and view the status:

    service rabbitmq-server startrabbitmqctl stoprabbitmq-server -detached rabbitmqctl status

    Assuming there are three machines, Node1, Node2, Node3, then Node2 and Node3 and Node1 are clustered (i.e., in Node2 and Node3 two machines):

    rabbitmqctl stop_app rabbitmqctl join_cluster [email protected]rabbitmqctl start_app

    After the configuration is complete, you can perform rabbitmqctl cluster_status on any node machine to see if the cluster configuration is successful:

  4. Set up a mirroring queue policy

    Execute the following policy on any node, setting all queues as mirror queues, that is, the queues are replicated to each node, and the state of each node remains consistent. When a new node joins the cluster, the queue is mirrored to that node.

    rabbitmqctl set_policy ha-all "^"‘{"ha-mode":"all"}‘
  5. Node exits the cluster

    Take the Node1 node, for example, if you need to exit the cluster

    rabbitmqctl stop_apprabbitmqctl rest
Create a clustered user

Due to the subsequent deployment of Buildplatform, the RABBITMQ account used is admin and the password is 123456.

So here we need to create a user first, with two main methods:

  1. Web Administration page creation
    After logging into the Web management interface using the Guest account, click on the Admin tab, which originally had only one guest account,
    Create a new Admin account here, set the password, and select tags named [Admin]:

    Click on the Virtual Host tab on the right side of the page to enter the link to the Chinese box:

    Locate the Set Permission section and add the Admin user to the current permissions:


  2. Command-line mode creation

    Create Admin user
    rabbitmqctl add_user admin 123456
    Set Admin user Administrator role
    rabbitmqctl set_user_tags admin administrator
    View created Users
    rabbitmqctl list_users
    give Admin user permission
    rabbitmqctl  set_permissions -p /  admin ‘.*‘‘.*‘‘.*‘

    The above command ensures that user admin has all the resource configuration, write, and read permissions in this virtual host in order to manage the resources in it

Recommended

It is highly recommended that the RABBITMQ service be set to boot from:

chkconfig rabbitmq-server on

RABIBTMQ installation and cluster configuration-linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.