RabbitMQ Cluster 2019(1)Cluster on 2 Nodes Version 3.7.15

RabbitMQCluster2019(1)Clusteron2NodesVersion3.7.15

InstallationonUbuntu

DownloadtheErlangsourcefile

>wgethttp://erlang.org/download/otp_src_22.0.tar.gz

Unzipandprepareinstall

>tarzxvfotp_src_22.0.tar.gz

>exportLANG=C

Runtheconfiguration

>./configure--prefix=/usr/erlang

Installtherequirementagain

>sudoapt-getinstallfop

Runconfigagain

>./configure--prefix=/usr/erlang--without-wx

Addmoredependencies

>sudoapt-getinstallautomakeautoconflibreadline-devlibncurses-dev

>sudoapt-getinstalllibssl-devlibyaml-devlibxslt-devlibffi-devlibtoolunixodbc-dev

>sudoapt-getinstalllibwxgtk3.0-devlibgl1-mesa-devlibglu1-mesa-devlibssh-devxsltprocfop

>sudoapt-getinstalllibxml2-utils

Configagainwithsuccessfuloutput

>./configure--prefix=/usr/erlang

>make

>sudomakeinstall

Linkthebintoclasspath

>sudoln-s/usr/erlang/bin/erl/usr/bin/erl

VerifytheErlangversion

>erl-version

Erlang(SMP,ASYNC_THREADS,HIPE)(BEAM)emulatorversion10.4

FindthelatestversionofrabbitMQfromhere

https://www.rabbitmq.com/install-generic-unix.html

Igetthefileintheinstallationdirectoryrabbitmq-server-generic-unix-3.7.15.tar.xz

Unzipandinstallonmymachine

>tarxvfJrabbitmq-server-generic-unix-3.7.15.tar.xz

>mvrabbitmq_server-3.7.15~/tool/rabbitmq-3.7.15

Preparetheworkingdirectory

>sudoln-s/home/carl/tool/rabbitmq-3.7.15/opt/rabbitmq-3.7.15

>sudoln-s/opt/rabbitmq-3.7.15/opt/rabbitmq

Starttheserviceonmyubuntu-mastermachine

>sudosbin/rabbitmq-server

Checkstatus

>sudosbin/rabbitmqctlstatus

Listusers

>sudosbin/rabbitmqctllist_users

Listingusers...

usertags

guest[administrator]

Addusers

>sudosbin/rabbitmqctladd_usercarltest

>sudosbin/rabbitmqctlset_user_tagscarladministrator

Settingtagsforuser"carl"to[administrator]...

>sudosbin/rabbitmqctlset_permissions-p/carl".*"".*"".*"

Settingpermissionsforuser"carl"invhost"/"...

>sudosbin/rabbitmqctllist_users

Listingusers...

usertags

carl[administrator]

guest[administrator]

Checktheportnumbers

>netstat-lntu

ActiveInternetconnections(onlyservers)

ProtoRecv-QSend-QLocalAddressForeignAddressState

tcp000.0.0.0:43690.0.0.0:*LISTEN

tcp00127.0.0.53:530.0.0.0:*LISTEN

tcp000.0.0.0:220.0.0.0:*LISTEN

tcp00127.0.0.1:377950.0.0.0:*LISTEN

tcp000.0.0.0:256720.0.0.0:*LISTEN

tcp00127.0.0.1:33060.0.0.0:*LISTEN

tcp600:::4369:::*LISTEN

tcp600:::22:::*LISTEN

tcp600:::5672:::*LISTEN

udp00127.0.0.53:530.0.0.0:*

udp000.0.0.0:680.0.0.0:*

Itissaidtheseportsareused

Defaultportis5672

4369Erlangclustering

5672mainport

AddtoPath

exportPATH="/opt/rabbitmq/sbin:$PATH"

>sudochmod777~/.erlang.cookie

>sudochmod400~/.erlang.cookie

>sudochown-Rcarl~/.erlang.cookie

>sudochgrp-Rcarl~/.erlang.cookie

Enableplugins

>sudosbin/rabbitmq-pluginsenablerabbitmq_management

Enablingpluginsonnoderabbit@ubuntu-master:

rabbitmq_management

Thefollowingpluginshavebeenconfigured:

rabbitmq_management

rabbitmq_management_agent

rabbitmq_web_dispatch

Applyingpluginconfigurationtorabbit@ubuntu-master...

Thefollowingpluginshavebeenenabled:

rabbitmq_management

rabbitmq_management_agent

rabbitmq_web_dispatch

started3plugins.

SetUpSecondMachineubuntu-dev2

Adddependencies

>sudoapt-getinstallautomakeautoconflibreadline-devlibncurses-dev

>sudoapt-getinstalllibssl-devlibyaml-devlibxslt-devlibffi-devlibtoolunixodbc-dev

>sudoapt-getinstalllibwxgtk3.0-devlibgl1-mesa-devlibglu1-mesa-devlibssh-devxsltprocfop

>sudoapt-getinstalllibxml2-utils

Installerlang

DownloadtheErlangsourcefile

>wgethttp://erlang.org/download/otp_src_22.0.tar.gz

Unzipandprepareinstall

>tarzxvfotp_src_22.0.tar.gz

>exportLANG=C

Runtheconfiguration

>./configure--prefix=/usr/erlang

>make

>sudomakeinstall

Linkthebintoclasspath

>sudoln-s/usr/erlang/bin/erl/usr/bin/erl

VerifytheErlangversion

>erl-version

Erlang(SMP,ASYNC_THREADS,HIPE)(BEAM)emulatorversion10.4

Igetthefileintheinstallationdirectoryrabbitmq-server-generic-unix-3.7.15.tar.xz

Unzipandinstallonmymachine

>tarxvfJrabbitmq-server-generic-unix-3.7.15.tar.xz

>mvrabbitmq_server-3.7.15~/tool/rabbitmq-3.7.15

Preparetheworkingdirectory

>sudoln-s/home/carl/tool/rabbitmq-3.7.15/opt/rabbitmq-3.7.15

>sudoln-s/opt/rabbitmq-3.7.15/opt/rabbitmq

AddtoPath

exportPATH="/opt/rabbitmq/sbin:$PATH"

Starttheserviceoncetogeneratethecookie

>sudosbin/rabbitmq-server

>sudochmod777~/.erlang.cookie

>sudochmod400~/.erlang.cookie

>sudochown-Rcarl~/.erlang.cookie

>sudochgrp-Rcarl~/.erlang.cookie

Enableplugins

>sudosbin/rabbitmq-pluginsenablerabbitmq_management

Enablingpluginsonnoderabbit@ubuntu-master:

rabbitmq_management

Thefollowingpluginshavebeenconfigured:

rabbitmq_management

rabbitmq_management_agent

rabbitmq_web_dispatch

Applyingpluginconfigurationtorabbit@ubuntu-master...

Thefollowingpluginshavebeenenabled:

rabbitmq_management

rabbitmq_management_agent

rabbitmq_web_dispatch

started3plugins.

Startontheubuntu-masterandubuntu-dev2machines

>sudoRABBITMQ_NODE_PORT=5672RABBITMQ_SERVER_START_ARGS="-rabbitmq_managementlistener[{port,15672}]"RABBITMQ_NODENAME=rabbit1sbin/rabbitmq-server-detached

>sudoRABBITMQ_NODE_PORT=5672RABBITMQ_SERVER_START_ARGS="-rabbitmq_managementlistener[{port,15672}]"RABBITMQ_NODENAME=rabbit2sbin/rabbitmq-server-detached

Checkstatusonthesemachines

>rabbitmqctl-nrabbit1cluster_status

Clusterstatusofnoderabbit1@ubuntu-master...

[{nodes,[{disc,['rabbit1@ubuntu-master']}]},

{running_nodes,['rabbit1@ubuntu-master']},

{cluster_name,<<"rabbit1@ubuntu-master">>},

{partitions,[]},

{alarms,[{'rabbit1@ubuntu-master',[]}]}]

>rabbitmqctl-nrabbit2cluster_status

Clusterstatusofnoderabbit2@ubuntu-dev2...

[{nodes,[{disc,['rabbit2@ubuntu-dev2']}]},

{running_nodes,['rabbit2@ubuntu-dev2']},

{cluster_name,<<"rabbit2@ubuntu-dev2">>},

{partitions,[]},

{alarms,[{'rabbit2@ubuntu-dev2',[]}]}]

Visittheconsoles

http://ubuntu-master:15672/

http://ubuntu-dev2:15672/

Thedefaultusernameandpasswordforconsoleisguest/guest,butIcannotloginandprompt“Usercanonlyloginvialocalhost"

https://stackoverflow.com/questions/23669780/rabbitmq-3-3-1-can-not-login-with-guest-guest

Listtheusersonbothservers

>rabbitmqctl-nrabbit1list_users

>rabbitmqctl-nrabbit2list_users

Addusers/tags/permissionsonbothservices

>rabbitmqctl-nrabbit2cluster_status

>rabbitmqctl-nrabbit2list_users

>rabbitmqctl-nrabbit2add_usercarltest

>rabbitmqctl-nrabbit2set_user_tagscarladministrator

>rabbitmqctl-nrabbit2set_permissions-p/carl".*"".*"".*"

>rabbitmqctl-nrabbit1list_users

>rabbitmqctl-nrabbit1add_usercarltest

>rabbitmqctl-nrabbit1set_user_tagscarladministrator

>rabbitmqctl-nrabbit1set_permissions-p/carl".*"".*"".*"

Then,Icanusecarl/testtologininbothconsoles.

Stopthesecondnodeandjointhefirstcluster

>sudosbin/rabbitmqctl-nrabbit2stop_app

Askthesecondnodetojointhefirstcluster

>sudosbin/rabbitmqctl-nrabbit2join_clusterrabbit1@ubuntu-master

Iguessitisbecauseofthis

CLItoolfailstoauthenticatewiththeserver(e.g.duetoCLItool'sErlangcookienotmatchingthatoftheserver)

Copyandputthecookiestringfromfirstclustertothesecondone

>cat~/.erlang.cookie

PSEZGZISxxxxxxxNS

>sudosbin/rabbitmqctl-nrabbit2join_clusterrabbit1@ubuntu-master

Clusteringnoderabbit2@ubuntu-dev2withrabbit1@ubuntu-master

Starttheapplicationagain

>sudosbin/rabbitmqctl-nrabbit2start_app

Checktheclusterstatus

>sbin/rabbitmqctl-nrabbit1cluster_status

Clusterstatusofnoderabbit1@ubuntu-master...

[{nodes,[{disc,['rabbit1@ubuntu-master','rabbit2@ubuntu-dev2']}]},

{running_nodes,['rabbit2@ubuntu-dev2','rabbit1@ubuntu-master']},

{cluster_name,<<"rabbit1@ubuntu-master">>},

{partitions,[]},

{alarms,[{'rabbit2@ubuntu-dev2',[]},{'rabbit1@ubuntu-master',[]}]}]

ClusterSolution

https://objcoding.com/2018/10/19/rabbitmq-cluster/

https://blog.csdn.net/WoogeYu/article/details/51119101

https://juejin.im/entry/5c0fb747e51d4505fe6c4b71

https://www.jianshu.com/p/6376936845ff

References:

https://www.rabbitmq.com/install-debian.html

https://www.erlang.org/

https://github.com/asdf-vm/asdf-erlang/issues/83

相关推荐