RABBITMQ Cluster Construction

Source: Internet
Author: User
Tags rabbitmq

??

Lab Environment:

Operating system for Centos 7.2

IP HostName

192.168.190.132 node132

192.168.190.139 node139

192.168.190.140 node140

??

RABBITMQ related ports

??

  • 4369 (EPMD)
  • 5672, 5671 (AMQP 0-9-1 and 1.0 without and with TLS)
  • 25672. This port used by Erlang distribution for Inter-node and CLI tools communication and are allocated from a Dynami C Range (limited to a single port by default, computed as AMQP port + 20000). SeeNetworkingGuide fordetails.
  • 15672 (if management plugin is enabled)
  • 61613, 61614 (if STOMP is enabled)
  • 1883, 8883 (if MQTT is enabled)

    ??

    The appropriate port to turn on firewall settings

    ??

    ??

    Add EPEL Source

    ??

    [email protected] ~]# RPM-UVH https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

    Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

    Warning:/var/tmp/rpm-tmp.2hdpsr:header V3 rsa/sha256 Signature, key ID 352c64e5:nokey

    Preparing ... ################################# [100%]

    Updating/installing ...

    1:epel-release-7-8 ################################# [100%]

    ??


    Add Erlang Source

    ??

    [email protected] ~]# RPM-UVH http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm

    Retrieving http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm

    Preparing ... ################################# [100%]

    Updating/installing ...

    1:erlang-solutions-1.0-1 ################################# [100%]

    --2016-11-29 06:34:38--Http://packages.erlang-solutions.com/rpm/centos/erlang_solutions.repo

    Resolving packages.erlang-solutions.com (packages.erlang-solutions.com) ... 31.172.186.53

    Connecting to Packages.erlang-solutions.com (packages.erlang-solutions.com) |31.172.186.53|:80 ... Connected.

    HTTP request sent, awaiting response ... OK

    length:245

    Saving to: ' Erlang_solutions.repo '

    ??

    100%[==========================================================================>] 245--.-K/s in 0s

    ??

    2016-11-29 06:34:39 (27.5 mb/s)-' Erlang_solutions.repo ' saved [245/245]

    ??


    installation RabbitMQ

    software version:http://www.rabbitmq.com/releases/rabbitmq-server

    ??

    [email protected] ~]# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/ rabbitmq-server-3.6.6-1.el7.noarch.rpm

    [email protected] ~]# rpm--import HTTPS://WWW.RABBITMQ.COM/RABBITMQ-SIGNING-KEY-PUBLIC.ASC

    [email protected] ~]# yum Install rabbitmq-server-3.6.6-1.el7.noarch.rpm

    ??

    Start the service

    [email protected] ~]# systemctl enable Rabbitmq-server.service

    [email protected] ~]# systemctl start Rabbitmq-server.service

    ??


    enabled RabbitMQ Monitoring Plugins

    [email protected] ~]# rabbitmq-plugins enable Rabbitmq_management

    The following plugins has been enabled:

    Mochiweb

    Webmachine

    Rabbitmq_web_dispatch

    Amqp_client

    Rabbitmq_management_agent

    Rabbitmq_management

    ??

    Applying plugin configuration to [email protected] started 6 plugins.

    [email protected] ~]# NETSTAT-APN | grep 15672

    TCP 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 4119/beam.smp

    ??


    RabbitMQ User Management

    ??

    Add User (user name root, password Admin)

    [[email protected] ~]# rabbitmqctl add_user Admin Admin

    ??

    Set User Role (set Admin user as Admin role)

    [email protected] ~]# rabbitmqctl set_user_tags Admin Administrator

    Setting tags for the user "admin" to [Administrator] ...

    ??

    Set user permissions (set Admin user Configuration, write, read permissions)

    [email protected] ~]# rabbitmqctl set_permissions-p/admin ". *". * "". * "

    Setting permissions for the user "admin" in Vhost "/" ...

    ??

    Delete User (delete guest user)

    [email protected] ~]# rabbitmqctl Delete_user Guest

    ??

    ??

    RabbitMQ Cluster Configuration

    The cluster configuration is based on the completion of the single-machine configuration

    The following takes node140 as an example, node132 needs to do the same

      • Add /etc/hosts Articles

    in the node132 , node139 , node140 In the /etc/hosts file, respectively:

    192.168.190.132 node132
    192.168.190.139 node139
    192.168.190.140 node140

    ??

      • Set each node Cookies

    RABBITMQ the cluster is dependent on the Erlang cluster to work, you must first build the Erlang cluster environment. the nodes in Erlang 's cluster are implemented by a magic?cookie , which is stored in ?/var/lib/rabbitmq/.erlang.cookie? , the file is - the permissions. Therefore, you must ensure that each node cookie is consistent, otherwise the node cannot communicate

    ??

    [email protected] /]# echo-n "Azvoczyzzbvflbptbxu" >/var/lib/rabbitmq/.erlang.cookie

    [email protected] ~]# chown Rabbitmq:root/var/lib/rabbitmq/.erlang.cookie

    [email protected] /]# chmod 600/var/lib/rabbitmq/.erlang.cookie

    [email protected] /]# Cat/var/lib/rabbitmq/.erlang.cookie

    Azvoczyzzbvflbptbxu

    ??

    Start the service

    [email protected] ~]# systemctl start Rabbitmq-server.service

    [email protected] ~]# rabbitmq-server-detached

    ??

    Open firewall

    [email protected] ~]# firewall-cmd--permanent--add-port={4369/tcp,25672/tcp}

    Success

    [email protected] ~]# firewall-cmd--reload

    Success

    ??

  • Join the cluster

    The default is the disk node, if it is a memory node, you need to add --ram Parameters

    ??

    [email protected] ~]# rabbitmqctl Stop_app

    stopping node [email protected] ...

    [email protected] ~]# rabbitmqctl join_cluster [email protected]

    Clustering node [email protected] with [email protected] ...

    [email protected] ~]# rabbitmqctl Start_app

    Starting node [email protected] ...

  • Set mirroring Policy

    ??

    [[email protected] ~]# rabbitmqctl set_policy ha-all "^" ' {"Ha-mode": "All", "Ha-sync-mode": "Automatic"} '

    Setting policy "Ha-all" for the pattern "^" to "{\" ha-mode\ ": \" all\ ", \" ha-sync-mode\ ": \" Automatic\ "}" with priority "0" ...

    ??


    enabled RabbitMQ Monitoring Plugins

    if cluster is set up, rabbitmq_management overview nodes part of the Web management tool, see " node Statistics not available " information that the Web Management plug-in is not enabled on this node.

    [email protected] ~]# rabbitmq-plugins enable Rabbitmq_management

    ??

    once the cluster is configured, you can RabbitMQ execute the following command on any node to see if the cluster configuration was successful.

    [email protected] ~]# rabbitmqctl cluster_status

    ??

    Other nodes need to do the same

    ??

    ??

    Login Site http://192.168.190.139:15672/

    ??

    ??

    ??

    ??

    ??

    Reference URL: http://www.rabbitmq.com/clustering.html

    Problems encountered during installation:

    This/var/lib/rabbitmq/.erlang.cookie file needs to modify the file owner and file permissions for RW, otherwise the RABBITMQ service cannot start;

    ??

    ??

    ??

    ??

    ??

    ??

    ??

    ??

    ??

    ??

    ??

    ??

    ??

    ??

RABBITMQ Cluster Construction

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.