CentOS7安装RabbitMQ

2019-06-26 14:34:49 浏览数 (1)

RabbitMQ简介

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

一、单机部署

1.安装erlang

1.1.创建erlang.repo库

代码语言:shell复制
[root@VM_147_130_centos ~]# curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packagecloud.io/install/repositories/rabbitmq/erlang/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
Loaded plugins: fastestmirror, langpacks
rabbitmq_erlang-source/signature                                                                                                                         |  819 B  00:00:00     
Retrieving key from https://packagecloud.io/rabbitmq/erlang/gpgkey
Importing GPG key 0xDF309A0B:
 Userid     : "https://packagecloud.io/rabbitmq/erlang (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
 Fingerprint: 2ebd e413 d3ce 5d35 bcd1 5b7c 71c6 3471 df30 9a0b
 From       : https://packagecloud.io/rabbitmq/erlang/gpgkey
rabbitmq_erlang-source/signature                                                                                                                         |  951 B  00:00:00 !!! 
rabbitmq_erlang-source/primary                                                                                                                           |  175 B  00:00:02     
Loading mirror speeds from cached hostfile
Package pygpgme-0.3-9.el7.x86_64 already installed and latest version
Nothing to do
Installing yum-utils...
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-34.el7 will be updated
---> Package yum-utils.noarch 0:1.1.31-50.el7 will be an update
--> Processing Dependency: yum >= 3.4.3-143 for package: yum-utils-1.1.31-50.el7.noarch
--> Running transaction check
---> Package yum.noarch 0:3.4.3-132.el7.centos.0.1 will be updated
---> Package yum.noarch 0:3.4.3-161.el7.centos will be an update
--> Processing Dependency: rpm >= 4.11.3-22 for package: yum-3.4.3-161.el7.centos.noarch
--> Processing Dependency: python-urlgrabber >= 3.10-8 for package: yum-3.4.3-161.el7.centos.noarch
--> Running transaction check
---> Package python-urlgrabber.noarch 0:3.10-7.el7 will be updated
---> Package python-urlgrabber.noarch 0:3.10-9.el7 will be an update
---> Package rpm.x86_64 0:4.11.3-17.el7 will be updated
--> Processing Dependency: rpm = 4.11.3-17.el7 for package: rpm-libs-4.11.3-17.el7.x86_64
--> Processing Dependency: rpm = 4.11.3-17.el7 for package: rpm-python-4.11.3-17.el7.x86_64
---> Package rpm.x86_64 0:4.11.3-35.el7 will be an update
--> Running transaction check
---> Package rpm-libs.x86_64 0:4.11.3-17.el7 will be updated
--> Processing Dependency: rpm-libs(x86-64) = 4.11.3-17.el7 for package: rpm-build-libs-4.11.3-17.el7.x86_64
---> Package rpm-libs.x86_64 0:4.11.3-35.el7 will be an update
---> Package rpm-python.x86_64 0:4.11.3-17.el7 will be updated
---> Package rpm-python.x86_64 0:4.11.3-35.el7 will be an update
--> Running transaction check
---> Package rpm-build-libs.x86_64 0:4.11.3-17.el7 will be updated
---> Package rpm-build-libs.x86_64 0:4.11.3-35.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================
 Package                                         Arch                                 Version                                            Repository                        Size
================================================================================================================================================================================
Updating:
 yum-utils                                       noarch                               1.1.31-50.el7                                      os                               121 k
Updating for dependencies:
 python-urlgrabber                               noarch                               3.10-9.el7                                         os                               108 k
 rpm                                             x86_64                               4.11.3-35.el7                                      os                               1.2 M
 rpm-build-libs                                  x86_64                               4.11.3-35.el7                                      os                               106 k
 rpm-libs                                        x86_64                               4.11.3-35.el7                                      os                               277 k
 rpm-python                                      x86_64                               4.11.3-35.el7                                      os                                83 k
 yum                                             noarch                               3.4.3-161.el7.centos                               os                               1.2 M

Transaction Summary
================================================================================================================================================================================
Upgrade  1 Package ( 6 Dependent packages)

Total download size: 3.1 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/7): python-urlgrabber-3.10-9.el7.noarch.rpm                                                                                                           | 108 kB  00:00:00     
(2/7): rpm-build-libs-4.11.3-35.el7.x86_64.rpm                                                                                                           | 106 kB  00:00:00     
(3/7): rpm-libs-4.11.3-35.el7.x86_64.rpm                                                                                                                 | 277 kB  00:00:00     
(4/7): rpm-python-4.11.3-35.el7.x86_64.rpm                                                                                                               |  83 kB  00:00:00     
(5/7): rpm-4.11.3-35.el7.x86_64.rpm                                                                                                                      | 1.2 MB  00:00:00     
(6/7): yum-utils-1.1.31-50.el7.noarch.rpm                                                                                                                | 121 kB  00:00:00     
(7/7): yum-3.4.3-161.el7.centos.noarch.rpm                                                                                                               | 1.2 MB  00:00:00     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                           9.2 MB/s | 3.1 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : rpm-4.11.3-35.el7.x86_64                                                                                                                                    1/14 
  Updating   : rpm-libs-4.11.3-35.el7.x86_64                                                                                                                               2/14 
  Updating   : rpm-build-libs-4.11.3-35.el7.x86_64                                                                                                                         3/14 
  Updating   : rpm-python-4.11.3-35.el7.x86_64                                                                                                                             4/14 
  Updating   : python-urlgrabber-3.10-9.el7.noarch                                                                                                                         5/14 
  Updating   : yum-3.4.3-161.el7.centos.noarch                                                                                                                             6/14 
  Updating   : yum-utils-1.1.31-50.el7.noarch                                                                                                                              7/14 
  Cleanup    : yum-utils-1.1.31-34.el7.noarch                                                                                                                              8/14 
  Cleanup    : yum-3.4.3-132.el7.centos.0.1.noarch                                                                                                                         9/14 
  Cleanup    : rpm-python-4.11.3-17.el7.x86_64                                                                                                                            10/14 
  Cleanup    : python-urlgrabber-3.10-7.el7.noarch                                                                                                                        11/14 
  Cleanup    : rpm-build-libs-4.11.3-17.el7.x86_64                                                                                                                        12/14 
  Cleanup    : rpm-4.11.3-17.el7.x86_64                                                                                                                                   13/14 
  Cleanup    : rpm-libs-4.11.3-17.el7.x86_64                                                                                                                              14/14 
  Verifying  : python-urlgrabber-3.10-9.el7.noarch                                                                                                                         1/14 
  Verifying  : rpm-libs-4.11.3-35.el7.x86_64                                                                                                                               2/14 
  Verifying  : rpm-python-4.11.3-35.el7.x86_64                                                                                                                             3/14 
  Verifying  : yum-utils-1.1.31-50.el7.noarch                                                                                                                              4/14 
  Verifying  : rpm-4.11.3-35.el7.x86_64                                                                                                                                    5/14 
  Verifying  : yum-3.4.3-161.el7.centos.noarch                                                                                                                             6/14 
  Verifying  : rpm-build-libs-4.11.3-35.el7.x86_64                                                                                                                         7/14 
  Verifying  : yum-utils-1.1.31-34.el7.noarch                                                                                                                              8/14 
  Verifying  : rpm-libs-4.11.3-17.el7.x86_64                                                                                                                               9/14 
  Verifying  : rpm-4.11.3-17.el7.x86_64                                                                                                                                   10/14 
  Verifying  : rpm-build-libs-4.11.3-17.el7.x86_64                                                                                                                        11/14 
  Verifying  : yum-3.4.3-132.el7.centos.0.1.noarch                                                                                                                        12/14 
  Verifying  : rpm-python-4.11.3-17.el7.x86_64                                                                                                                            13/14 
  Verifying  : python-urlgrabber-3.10-7.el7.noarch                                                                                                                        14/14 

Updated:
  yum-utils.noarch 0:1.1.31-50.el7                                                                                                                                              

Dependency Updated:
  python-urlgrabber.noarch 0:3.10-9.el7  rpm.x86_64 0:4.11.3-35.el7  rpm-build-libs.x86_64 0:4.11.3-35.el7  rpm-libs.x86_64 0:4.11.3-35.el7  rpm-python.x86_64 0:4.11.3-35.el7 
  yum.noarch 0:3.4.3-161.el7.centos     

Complete!
Generating yum cache for rabbitmq_erlang...
Importing GPG key 0xDF309A0B:
 Userid     : "https://packagecloud.io/rabbitmq/erlang (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
 Fingerprint: 2ebd e413 d3ce 5d35 bcd1 5b7c 71c6 3471 df30 9a0b
 From       : https://packagecloud.io/rabbitmq/erlang/gpgkey
Generating yum cache for rabbitmq_erlang-source...

The repository is setup! You can now install packages.

1.2.安装erlang

代码语言:shell复制
[root@VM_147_130_centos ~]# yum install erlang
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package erlang.x86_64 0:22.0.3-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================
 Package                               Arch                                  Version                                       Repository                                      Size
================================================================================================================================================================================
Installing:
 erlang                                x86_64                                22.0.3-1.el7                                  rabbitmq_erlang                                 18 M

Transaction Summary
================================================================================================================================================================================
Install  1 Package

Total download size: 18 M
Installed size: 33 M
Is this ok [y/d/N]: y
Downloading packages:
erlang-22.0.3-1.el7.x86_64.rpm                                                                                                                           |  18 MB  00:00:07     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : erlang-22.0.3-1.el7.x86_64                                                                                                                                   1/1 
  Verifying  : erlang-22.0.3-1.el7.x86_64                                                                                                                                   1/1 

Installed:
  erlang.x86_64 0:22.0.3-1.el7                                                                                                                                                  

Complete!

2.安装rabbitmq-server

2.1.创建rabbitmq-server.repo库

代码语言:shell复制
[root@VM_147_130_centos ~]# curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
Loaded plugins: fastestmirror, langpacks
rabbitmq_erlang/x86_64/signature                                                                                                                         |  833 B  00:00:00     
rabbitmq_erlang/x86_64/signature                                                                                                                         | 1.0 kB  00:00:00 !!! 
rabbitmq_erlang-source/signature                                                                                                                         |  819 B  00:00:00     
rabbitmq_erlang-source/signature                                                                                                                         |  951 B  00:00:00 !!! 
rabbitmq_rabbitmq-server-source/signature                                                                                                                |  836 B  00:00:00     
Retrieving key from https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
Importing GPG key 0x4D206F89:
 Userid     : "https://packagecloud.io/rabbitmq/rabbitmq-server (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
 Fingerprint: 8c69 5b02 19af deb0 4a05 8ed8 f4e7 8920 4d20 6f89
 From       : https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
rabbitmq_rabbitmq-server-source/signature                                                                                                                | 1.0 kB  00:00:00 !!! 
rabbitmq_rabbitmq-server-source/primary                                                                                                                  |  175 B  00:00:02     
Loading mirror speeds from cached hostfile
Package pygpgme-0.3-9.el7.x86_64 already installed and latest version
Nothing to do
Installing yum-utils...
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package yum-utils-1.1.31-50.el7.noarch already installed and latest version
Nothing to do
Generating yum cache for rabbitmq_rabbitmq-server...
Importing GPG key 0x4D206F89:
 Userid     : "https://packagecloud.io/rabbitmq/rabbitmq-server (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
 Fingerprint: 8c69 5b02 19af deb0 4a05 8ed8 f4e7 8920 4d20 6f89
 From       : https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
Generating yum cache for rabbitmq_rabbitmq-server-source...

The repository is setup! You can now install packages.

2.2.安装rabbitmq-server

代码语言:shell复制
[root@VM_147_130_centos ~]# yum install rabbitmq-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package rabbitmq-server.noarch 0:3.7.15-1.el7 will be installed
--> Processing Dependency: socat for package: rabbitmq-server-3.7.15-1.el7.noarch
--> Running transaction check
---> Package socat.x86_64 0:1.7.3.2-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================
 Package                                   Arch                             Version                                    Repository                                          Size
================================================================================================================================================================================
Installing:
 rabbitmq-server                           noarch                           3.7.15-1.el7                               rabbitmq_rabbitmq-server                           9.8 M
Installing for dependencies:
 socat                                     x86_64                           1.7.3.2-2.el7                              os                                                 290 k

Transaction Summary
================================================================================================================================================================================
Install  1 Package ( 1 Dependent package)

Total download size: 10 M
Installed size: 12 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): socat-1.7.3.2-2.el7.x86_64.rpm                                                                                                                    | 290 kB  00:00:00     
(2/2): rabbitmq-server-3.7.15-1.el7.noarch.rpm                                                                                                           | 9.8 MB  00:00:09     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                           1.1 MB/s |  10 MB  00:00:09     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : socat-1.7.3.2-2.el7.x86_64                                                                                                                                   1/2 
  Installing : rabbitmq-server-3.7.15-1.el7.noarch                                                                                                                          2/2 
  Verifying  : socat-1.7.3.2-2.el7.x86_64                                                                                                                                   1/2 
  Verifying  : rabbitmq-server-3.7.15-1.el7.noarch                                                                                                                          2/2 

Installed:
  rabbitmq-server.noarch 0:3.7.15-1.el7                                                                                                                                         

Dependency Installed:
  socat.x86_64 0:1.7.3.2-2.el7                                                                                                                                                  

Complete!

3.设置开机启动

代码语言:shell复制
[root@VM_147_130_centos ~]# chkconfig rabbitmq-server on
Note: Forwarding request to 'systemctl enable rabbitmq-server.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.

4.启动rabbitmq节点

代码语言:shell复制
[root@VM_147_130_centos]# service rabbitmq-server start
Redirecting to /bin/systemctl start rabbitmq-server.service
rabbitmq进程rabbitmq进程

5.启用管理后台

代码语言:shell复制
[root@VM_147_130_centos ~]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@VM_147_130_centos:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@VM_147_130_centos...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch

started 3 plugins.

6.添加用户

代码语言:shell复制
[root@VM_147_130_centos ~]# rabbitmqctl add_user test 123456
Adding user "test" ...

7.配置用户权限

代码语言:shell复制
[root@VM_147_130_centos ~]# rabbitmqctl set_user_tags test administrator
Setting tags for user "test" to [administrator] ...
[root@VM_147_130_centos ~]# rabbitmqctl set_permissions -p "/" test ".*" ".*" ".*"
Setting permissions for user "test" in vhost "/"

8.配置防火墙

RabbitMQ访问端口RabbitMQ访问端口
代码语言:shell复制
[root@VM_147_130_centos ~]# firewall-cmd --zone=public --add-port=15672/tcp --permanent
success
[root@VM_147_130_centos ~]# firewall-cmd --zone=public --add-port=5671-5672/tcp --permanent
success
[root@VM_147_130_centos ~]# firewall-cmd --zone=public --add-port=4369/tcp --permanent
success
[root@VM_147_130_centos ~]# firewall-cmd --zone=public --add-port=25672/tcp --permanent
success
[root@VM_147_130_centos ~]# firewall-cmd --zone=public --add-port=35672-35682/tcp --permanent
success
[root@VM_147_130_centos ~]# firewall-cmd --reload
success

9.访问管理后台访问(端口:15672)

RabbitMQ管理后台RabbitMQ管理后台
rabbitmq管理后台主页rabbitmq管理后台主页

10.关闭rabbitmq节点

代码语言:shell复制
[root@VM_147_130_centos ~]# service rabbitmq-server stop
Redirecting to /bin/systemctl stop rabbitmq-server.service

11.参考资料

1.下载和安装RabbitMQ 2.rabbitmq’s repos 3.Centos7 安装最新RabbitMQ及配置 4.RabbitMQ端口


二、集群部署

1.在2台机器上分别安装RabbitMQ

RabbitMQ1 主节点RabbitMQ1 主节点
RabbitMQ2 从节点RabbitMQ2 从节点

2.查看.erlang.cook

2.1 RabbitMQ1(主节点)

代码语言:shell复制
[root@VM_88_143_centos rabbitmq]# cat /var/lib/rabbitmq/.erlang.cookie
GKCVRDIVRNQIBWHJEDXU

2.2 RabbitMQ2(从节点)

代码语言:shell复制
[root@VM_26_188_centos rabbitmq]# cat /var/lib/rabbitmq/.erlang.cookie
MVXVXZDFHYZGXTPGNMJM

3.设置RabbitMQ从节点.erlang.cookie值为主节点.erlang.cookie值

3.1 设置.erlang.cookie值

代码语言:shell复制
[root@VM_26_188_centos rabbitmq]# chmod  w .erlang.cookie
[root@VM_26_188_centos rabbitmq]# echo -e "GKCVRDIVRNQIBWHJEDXUc" > .erlang.cookie
[root@VM_26_188_centos rabbitmq]# chmod -w .erlang.cookie

3.2 重启从节点

代码语言:javascript复制
[root@VM_26_188_centos rabbitmq]# service rabbitmq-server stop
Redirecting to /bin/systemctl stop rabbitmq-server.service
[root@VM_26_188_centos rabbitmq]# service rabbitmq-server start
Redirecting to /bin/systemctl start rabbitmq-server.service

4.设置RabbitMQ各节点可以通过主机名ping通

代码语言:shell复制
[root@VM_88_143_centos rabbitmq]# vi /etc/hosts
127.0.0.1 VM_88_143_centos VM_88_143_centos
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

::1 VM_88_143_centos VM_88_143_centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

119.00.000.121 rabbit1
139.000.000.137 rabbit2
代码语言:shell复制
[root@VM_26_188_centos rabbitmq]# vi /etc/hosts
127.0.0.1 VM_26_188_centos VM_26_188_centos
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

::1 VM_26_188_centos VM_26_188_centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

119.00.000.121 rabbit1
139.000.000.137 rabbit2

5.RabbitMQ从节点加入RabbitMQ主节点

5.1 停止从节点RabbitMQ应用

代码语言:shell复制
[root@VM_26_188_centos rabbitmq]# rabbitmqctl stop_app
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Stopping rabbit application on node rabbit@VM_26_188_centos ...

5.2 RabbitMQ从节点加入主节点

代码语言:shell复制
[root@VM_26_188_centos rabbitmq]# rabbitmqctl join_cluster rabbit@VM_88_143_centos
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Clustering node rabbit@VM_26_188_centos with rabbit@VM_88_143_centos

5.3 启动从RabbitMQ应用

代码语言:shell复制
[root@VM_26_188_centos ~]# rabbitmqctl start_app
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Starting node rabbit@VM_26_188_centos ...
 completed with 4 plugins.
RabbitMQ集群RabbitMQ集群

6.镜像集群(高可用)

6.1 set policy

代码语言:shell复制
[root@VM_88_143_centos rabbitmq]# rabbitmqctl set_policy ha-all "^" '{"ha-mode":"all","ha-sync-mode":"automatic","ha-promote-on-shutdown":"always","ha-promote-on-failure":"always"}'
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Setting policy "ha-all" for pattern "^" to "{"ha-mode":"all","ha-sync-mode":"automatic","ha-promote-on-shutdown":"always","ha-promote-on-failure":"always"}" with priority "0" for vhost "/" ...
RabbitMQ镜像集群PoliciesRabbitMQ镜像集群Policies

6.2 set cluster_partition_handling

代码语言:shell复制
[root@VM_88_143_centos rabbitmq]# cp /usr/share/doc/rabbitmq-server-3.7.15/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config 
[root@VM_88_143_centos rabbitmq]# vi /etc/rabbitmq/rabbitmq.config
{cluster_partition_handling, autoheal}

7.Spring AMQP(RabbitMQ) 配置

application.yml

代码语言:text复制
spring:
   rabbitmq:
      addresses: 192.168.1.200:5672,192.168.1.201:5672
      username: test
      password: 123456
      template:
         retry:
            enabled: true
            initial-interval: 1s
            max-attempts: 999

9.常见问题

9.1从节点加入主节点错误

停用|启用RabbitMQ服务需要使用rabbitmqctl stop|start命令,不能使用服务方式启动service rabbitmq-server stop|start,否则从节点无法加入主节点

代码语言:javascript复制
[root@VM_26_188_centos rabbitmq]# service rabbitmq-server stop
Redirecting to /bin/systemctl stop  rabbitmq-server.service
[root@VM_26_188_centos rabbitmq]# rabbitmqctl join_cluster rabbit@VM_88_143_centos
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Error: unable to perform an operation on node 'rabbit@VM_26_188_centos'. Please see diagnostics information and suggestions below.

Most common reasons for this are:

 * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
 * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server) * Target node is not running

In addition to the diagnostics info below:

 * See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more
 * Consult server logs on node rabbit@VM_26_188_centos
 * If target node is configured to use long node names, don't forget to use --longnames with CLI tools

DIAGNOSTICS
===========

attempted to contact: [rabbit@VM_26_188_centos]

rabbit@VM_26_188_centos:
  * connected to epmd (port 4369) on VM_26_188_centos
  * epmd reports: node 'rabbit' not running at all
                  no other nodes on VM_26_188_centos
  * suggestion: start the node

Current node details:
 * node name: 'rabbitmqcli-1587-rabbit@VM_26_188_centos'
 * effective user's home directory: /var/lib/rabbitmq
 * Erlang cookie hash: s8dGy2phnuOLnKyqMij3gQ==

9.2 从节点加入主节点错误,amqp插件没启用

代码语言:javascript复制
[root@VM_26_188_centos rabbitmq]# vi /var/log/rabbitmq/rabbit@VM_26_188_centos.log
2019-06-18 13:42:51.182 [info] <0.903.0> accepting AMQP connection <0.903.0> (198.108.66.161:48862 -> 10.135.101.30:5672)
2019-06-18 13:42:51.183 [error] <0.903.0> closing AMQP connection <0.903.0> (198.108.66.161:48862 -> 10.135.101.30:5672):
amqp1_0_plugin_not_enabled

9.2.1查看RabbitMQ插件列表

代码语言:javascript复制
[root@VM_26_188_centos etc]# rabbitmq-plugins list
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Listing plugins with pattern ".*" ...
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status: * = running on rabbit@VM_26_188_centos
 |/
[  ] rabbitmq_amqp1_0                  3.7.15
[  ] rabbitmq_auth_backend_cache       3.7.15
[  ] rabbitmq_auth_backend_http        3.7.15
[  ] rabbitmq_auth_backend_ldap        3.7.15
[  ] rabbitmq_auth_mechanism_ssl       3.7.15
[  ] rabbitmq_consistent_hash_exchange 3.7.15
[  ] rabbitmq_event_exchange           3.7.15
[  ] rabbitmq_federation               3.7.15
[  ] rabbitmq_federation_management    3.7.15
[  ] rabbitmq_jms_topic_exchange       3.7.15
[E*] rabbitmq_management               3.7.15
[e*] rabbitmq_management_agent         3.7.15
[  ] rabbitmq_mqtt                     3.7.15
[  ] rabbitmq_peer_discovery_aws       3.7.15
[  ] rabbitmq_peer_discovery_common    3.7.15
[  ] rabbitmq_peer_discovery_consul    3.7.15
[  ] rabbitmq_peer_discovery_etcd      3.7.15
[  ] rabbitmq_peer_discovery_k8s       3.7.15
[  ] rabbitmq_random_exchange          3.7.15
[  ] rabbitmq_recent_history_exchange  3.7.15
[  ] rabbitmq_sharding                 3.7.15
[  ] rabbitmq_shovel                   3.7.15
[  ] rabbitmq_shovel_management        3.7.15
[  ] rabbitmq_stomp                    3.7.15
[  ] rabbitmq_top                      3.7.15
[  ] rabbitmq_tracing                  3.7.15
[  ] rabbitmq_trust_store              3.7.15
[e*] rabbitmq_web_dispatch             3.7.15
[  ] rabbitmq_web_mqtt                 3.7.15
[  ] rabbitmq_web_mqtt_examples        3.7.15
[  ] rabbitmq_web_stomp                3.7.15
[  ] rabbitmq_web_stomp_examples       3.7.15

9.2.2启用RabbitMQ AMQP插件

代码语言:javascript复制
[root@VM_88_143_centos rabbitmq]# rabbitmq-plugins enable rabbitmq_amqp1_0
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Enabling plugins on node rabbit@VM_88_143_centos:
rabbitmq_amqp1_0
The following plugins have been configured:
  rabbitmq_amqp1_0
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@VM_88_143_centos...
The following plugins have been enabled:
  rabbitmq_amqp1_0

started 1 plugins.
代码语言:javascript复制
[root@VM_26_188_centos rabbitmq]# rabbitmq-plugins enable rabbitmq_amqp1_0
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Enabling plugins on node rabbit@VM_26_188_centos:
rabbitmq_amqp1_0
The following plugins have been configured:
  rabbitmq_amqp1_0
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@VM_26_188_centos...
The following plugins have been enabled:
  rabbitmq_amqp1_0

started 1 plugins.

10.参考资料

1.RabbitMQ之集群搭建 2.Highly Available (Mirrored) Queues 3.RabbitMQ集群 4.rabbitmq - 不修改主机名的情况下搭建集群 5.RabbitMQ 入门系列(4)—— RabbitMQ 启动、停止节点和应用程序、用户管理、权限配置 6.CentOS7修改主机名的三种方法 7.Srping AMQP RabbitMQ support 8.Clustering and Network Partitions

0 人点赞