`
sillycat
  • 浏览: 2539532 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

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

 
阅读更多
RabbitMQ Cluster 2019(1)Cluster on 2 Nodes Version 3.7.15

Installation on Ubuntu
Download the Erlang source file
> wget http://erlang.org/download/otp_src_22.0.tar.gz

Unzip and prepare install
> tar zxvf otp_src_22.0.tar.gz
> export LANG=C

Run the configuration
> ./configure --prefix=/usr/erlang

Install the requirement again
> sudo apt-get install fop

Run config again
>./configure --prefix=/usr/erlang --without-wx

Add more dependencies
> sudo apt-get install automake autoconf libreadline-dev libncurses-dev
> sudo apt-get install libssl-dev libyaml-dev libxslt-dev libffi-dev libtool unixodbc-dev
> sudo apt-get install libwxgtk3.0-dev libgl1-mesa-dev  libglu1-mesa-dev libssh-dev xsltproc fop
> sudo apt-get install libxml2-utils

Config again with successful output
> ./configure --prefix=/usr/erlang
> make
> sudo make install

Link the bin to class path
> sudo ln -s /usr/erlang/bin/erl /usr/bin/erl

Verify the Erlang version
> erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 10.4

Find the latest version of rabbitMQ from here
https://www.rabbitmq.com/install-generic-unix.html
I get the file in the installation directory  rabbitmq-server-generic-unix-3.7.15.tar.xz

Unzip and install on my machine
> tar xvfJ rabbitmq-server-generic-unix-3.7.15.tar.xz
> mv rabbitmq_server-3.7.15 ~/tool/rabbitmq-3.7.15

Prepare the working directory
> sudo ln -s /home/carl/tool/rabbitmq-3.7.15 /opt/rabbitmq-3.7.15
> sudo ln -s /opt/rabbitmq-3.7.15 /opt/rabbitmq

Start the service on my ubuntu-master machine
> sudo sbin/rabbitmq-server

Check status
> sudo sbin/rabbitmqctl status

List users
> sudo sbin/rabbitmqctl list_users
Listing users ...
user tags
guest [administrator]

Add users
> sudo sbin/rabbitmqctl add_user carl test
> sudo sbin/rabbitmqctl set_user_tags carl administrator
Setting tags for user "carl" to [administrator] ...
> sudo sbin/rabbitmqctl set_permissions -p / carl ".*" ".*" ".*"
Setting permissions for user "carl" in vhost "/" ...

> sudo sbin/rabbitmqctl list_users
Listing users ...
user tags
carl [administrator]
guest [administrator]


Check the port numbers
> netstat -lntu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State     
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN    
tcp        0      0 127.0.0.1:37795         0.0.0.0:*               LISTEN    
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN    
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN    
tcp6       0      0 :::4369                 :::*                    LISTEN    
tcp6       0      0 :::22                   :::*                    LISTEN    
tcp6       0      0 :::5672                 :::*                    LISTEN    
udp        0      0 127.0.0.53:53           0.0.0.0:*                         
udp        0      0 0.0.0.0:68              0.0.0.0:*   

It is said these ports are used
Default port is 5672
4369 Erlang clustering
5672 main port

Add to Path
export PATH="/opt/rabbitmq/sbin:$PATH"

> sudo chmod 777 ~/.erlang.cookie
> sudo chmod 400 ~/.erlang.cookie
> sudo chown -R carl ~/.erlang.cookie
> sudo chgrp -R carl ~/.erlang.cookie

Enable plugins
> sudo sbin/rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@ubuntu-master:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@ubuntu-master...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
started 3 plugins.


Set Up Second Machine ubuntu-dev2
Add dependencies
> sudo apt-get install automake autoconf libreadline-dev libncurses-dev
> sudo apt-get install libssl-dev libyaml-dev libxslt-dev libffi-dev libtool unixodbc-dev
> sudo apt-get install libwxgtk3.0-dev libgl1-mesa-dev  libglu1-mesa-dev libssh-dev xsltproc fop
> sudo apt-get install libxml2-utils

Install erlang
Download the Erlang source file
> wget http://erlang.org/download/otp_src_22.0.tar.gz

Unzip and prepare install
> tar zxvf otp_src_22.0.tar.gz
> export LANG=C

Run the configuration
> ./configure --prefix=/usr/erlang
> make
> sudo make install

Link the bin to class path
> sudo ln -s /usr/erlang/bin/erl /usr/bin/erl

Verify the Erlang version
> erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 10.4

I get the file in the installation directory  rabbitmq-server-generic-unix-3.7.15.tar.xz

Unzip and install on my machine
> tar xvfJ rabbitmq-server-generic-unix-3.7.15.tar.xz
> mv rabbitmq_server-3.7.15 ~/tool/rabbitmq-3.7.15

Prepare the working directory
> sudo ln -s /home/carl/tool/rabbitmq-3.7.15 /opt/rabbitmq-3.7.15
> sudo ln -s /opt/rabbitmq-3.7.15 /opt/rabbitmq

Add to Path
export PATH="/opt/rabbitmq/sbin:$PATH"

Start the service once to generate the cookie
> sudo sbin/rabbitmq-server

> sudo chmod 777 ~/.erlang.cookie
> sudo chmod 400 ~/.erlang.cookie
> sudo chown -R carl ~/.erlang.cookie
> sudo chgrp -R carl ~/.erlang.cookie

Enable plugins
> sudo sbin/rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@ubuntu-master:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@ubuntu-master...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
started 3 plugins.

Start on the ubuntu-master and ubuntu-dev2 machines
> sudo RABBITMQ_NODE_PORT=5672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" RABBITMQ_NODENAME=rabbit1 sbin/rabbitmq-server -detached

> sudo RABBITMQ_NODE_PORT=5672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" RABBITMQ_NODENAME=rabbit2 sbin/rabbitmq-server -detached

Check status on these machines
> rabbitmqctl -n rabbit1 cluster_status
Cluster status of node rabbit1@ubuntu-master ...
[{nodes,[{disc,['rabbit1@ubuntu-master']}]},
{running_nodes,['rabbit1@ubuntu-master']},
{cluster_name,<<"rabbit1@ubuntu-master">>},
{partitions,[]},
{alarms,[{'rabbit1@ubuntu-master',[]}]}]

> rabbitmqctl -n rabbit2 cluster_status
Cluster status of node rabbit2@ubuntu-dev2 ...
[{nodes,[{disc,['rabbit2@ubuntu-dev2']}]},
{running_nodes,['rabbit2@ubuntu-dev2']},
{cluster_name,<<"rabbit2@ubuntu-dev2">>},
{partitions,[]},
{alarms,[{'rabbit2@ubuntu-dev2',[]}]}]


Visit the consoles
http://ubuntu-master:15672/
http://ubuntu-dev2:15672/

The default username and password for console is guest/guest, but I can not login and prompt “User can only log in via localhost"
https://stackoverflow.com/questions/23669780/rabbitmq-3-3-1-can-not-login-with-guest-guest

List the users on both servers
> rabbitmqctl -n rabbit1 list_users

> rabbitmqctl -n rabbit2 list_users

Add users/tags/permissions on both services
> rabbitmqctl -n rabbit2 cluster_status
> rabbitmqctl -n rabbit2 list_users
> rabbitmqctl -n rabbit2 add_user carl test
> rabbitmqctl -n rabbit2 set_user_tags carl administrator
> rabbitmqctl -n rabbit2 set_permissions -p / carl ".*" ".*" ".*"

> rabbitmqctl -n rabbit1 list_users
> rabbitmqctl -n rabbit1 add_user carl test
> rabbitmqctl -n rabbit1 set_user_tags carl administrator
> rabbitmqctl -n rabbit1 set_permissions -p / carl ".*" ".*" ".*"

Then, I can use carl/test to login in both consoles.

Stop the second node and join the first cluster
> sudo sbin/rabbitmqctl -n rabbit2 stop_app

Ask the second node to join the first cluster
> sudo sbin/rabbitmqctl -n rabbit2 join_cluster rabbit1@ubuntu-master

I guess it is because of this
CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)

Copy and put the cookie string from first cluster to the second one
> cat ~/.erlang.cookie
PSEZGZISxxxxxxxNS

> sudo sbin/rabbitmqctl -n rabbit2 join_cluster rabbit1@ubuntu-master
Clustering node rabbit2@ubuntu-dev2 with rabbit1@ubuntu-master

Start the application again
> sudo sbin/rabbitmqctl -n rabbit2 start_app

Check the cluster status
> sbin/rabbitmqctl -n rabbit1 cluster_status
Cluster status of node rabbit1@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',[]}]}]

Cluster Solution
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://sillycat.iteye.com/blog/1567052
https://www.erlang.org/
https://github.com/asdf-vm/asdf-erlang/issues/83


分享到:
评论

相关推荐

    rabbitmq-server-3.7.15.zip

    RabbitMQ 3.7.15是该软件的一个稳定版本,而Erlang则是RabbitMQ的基础运行环境,因为RabbitMQ是用Erlang编程语言编写的。 Erlang是一种并发性极强的函数式编程语言,由Ericsson公司开发,特别适合构建高可用性和...

    RabbitMQ Cluster.docx

    新节点加入时,通常需要使用`rabbitmq-cluster join`命令来指定现有的集群节点,而移除节点则需要使用`rabbitmqctl`工具,这可能涉及数据迁移和状态更新。如果节点出现故障并需要重新加入集群,它必须先被正确地停止...

    rabbitmq-server-windows-3.7.15.zip

    这个“rabbitmq-server-windows-3.7.15.zip”文件是RabbitMQ服务器在Windows操作系统上的3.7.15版本的安装包。这个版本在当时是一个稳定版本,提供了许多关键特性和改进。 1. **AMQP协议**:AMQP是一种开放式标准,...

    rabbitmq-server-3.7.15-1.el7.noarch.rpm

    rabbitmq-server-3.7.15-1.el7.noarch.rpm

    k8s部署rabbitmq-cluster集群配置文件和docker镜像文件

    k8s部署rabbitmq-cluster集群配置文件和docker镜像文件,配合文章学习用,有需要可以下载,无需修改直接部署即可

    rabbitmq集群环境搭建

    ### RabbitMQ 集群环境搭建知识点 #### 一、RabbitMQ集群环境搭建概述 在分布式系统中,为了提高消息处理能力与系统的可靠性,通常会采用RabbitMQ集群架构。RabbitMQ集群允许消息发布者将消息发送到任意一个集群...

    docker-rabbitmq-cluster集群搭建

    docker-rabbitmq-cluster集群搭建docker-rabbitmq-cluster集群搭建

    rabbitmq-server-3.7.15.rar

    标题中的"rabbitmq-server-3.7.15.rar"指的是RabbitMQ服务器的3.7.15版本的压缩包文件,适用于Windows 64位操作系统。 RabbitMQ的核心概念包括: 1. **Broker**: RabbitMQ服务器本身就是一个消息代理,负责接收、...

    rabbitmq-server-3.7.15.exe

    RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件)。RabbitMQ服务器是用Erlang语言编写的,而集群和故障转移是构建在开放电信平台框架上的。所有主要的编程语言均有与代理接口...

    rabbitmq-server-3.7.15安装包

    rabbitmq-server-3.7.15安装包以及依赖文件,包含erlang-20.3.6-1.el7.centos.x86_64.rpm、socat-1.7.3.2-2.el7.x86_64.rpm、rabbitmq-server-3.7.15-1.el7.noarch.rpm

    rabbitmq-c vs2019工程

    标题中的“rabbitmq-c vs2019工程”指的是一个基于C++的RabbitMQ客户端库项目,该库已经适配了Visual Studio 2019。RabbitMQ是一种广泛使用的开源消息代理软件,它实现了Advanced Message Queuing Protocol (AMQP)...

    rabbitmq_cluster.zip

    rabbitmq安装文件名(放在files文件夹内) rabbitmq_rpm: rabbitmq-server-3.7.6-1.el7.noarch.rpm rabbitmq端口 rabbitmq_port: 5673 rabbitmq管理端口 manage_port: 15673 配置用户名 username: bailh 配置密码 ...

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

    Linux系统的rabbitmq服务,从官网下载速度贼慢。或者使用在Linux系统中wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.15/rabbitmq-server-generic-unix-3.7.15.tar.xz下载

    rabbitmq-server-windows-3.6.12.zip

    RabbitMQ 3.6.12 is a maintenance release. Upgrades and Compatibility See the "Upgrading clusters" section of the ...To upgrade a RabbitMQ cluster, follow the instructions in RabbitMQ documentation.

    kubernetes-rabbitmq-cluster:适用于kubernetes的可部署的Rabbitmq集群

    2. **环境变量和配置**:RabbitMQ的配置可以通过Kubernetes的环境变量传递,例如设置节点间的心跳时间、集群名称等。此外,还可以使用ConfigMap或Secret来管理RabbitMQ的erlang cookie,以确保集群间的节点能够相互...

    rabbitmq-server-3.7.15-1.el6.noarch.rpm

    rabbitmq-server-3.7.15-1.el6.noarch

    rabbitmq离线安装必须rpm.zip

    2.yum install ./rabbitmq-server-3.7.15-1.el7.noarch.rpm; 3.yum install ./rabbitmq-server-3.7.15-1.el7.noarch.rpm; 4./sbin/service rabbitmq-server start; 若2报错yum install ./socat-1.7.3.2-2.el7...

    chef-rabbitmq-cluster:厨师食谱,用于配置rabbitmq-cluster。 (Opscode Rabbitmq食谱的包装食谱。)

    ubuntu / trusty64 ubuntu / precise64 厨师/centos-6.5 主厨/debian-7.7属性钥匙类型描述默认['rabbitmq'] ['cluster'] 布尔型['rabbitmq'] ['cluster'] = true,并且需要['rabbitmq'] ['erlang_cookie']来配置...

Global site tag (gtag.js) - Google Analytics