CentOS7にRabbitMQをインストールします

RabbitMQの紹介##

RabbitMQは、高度な [メッセージキューイング](https://cloud.tencent.com/product/cmq?from=10680)プロトコル(AMQP)を実装するオープンソースのメッセージブローカーソフトウェア(メッセージ指向ミドルウェアとも呼ばれます)です。 RabbitMQサーバーは [** Erlang ](https://baike.baidu.com/item/Erlang)言語で記述されており、クラスターとフェイルオーバーは [ Open Telecom Platform **](https://baike.baidu.com/item/%E5%BC%80%E6%94%BE%E7%94%B5%E4%BF%A1%E5%B9%B3%E5%8F%B0)**フレームワーク上に構築されています。すべての主要なプログラミング言語には、エージェントインターフェイスと通信するクライアントライブラリがあります。 ****

1.単一マシンの展開#

1. erlangをインストールします##

1.1.* erlang.repoライブラリを作成します*

[ 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) <[email protected]>"
 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) <[email protected]>"
 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 ###をインストールします

[ 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ライブラリを作成します*

[ 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) <[email protected]>"
 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) <[email protected]>"
 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 ###をインストールします

[ 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. 起動を設定します##

[ 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ノードを開始します##

[ root@VM_147_130_centos]# service rabbitmq-server start
Redirecting to /bin/systemctl start rabbitmq-server.service

rabbitmqプロセス

5. 管理バックエンドを有効にする##

[ 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. ユーザーを追加する ##

[ root@VM_147_130_centos ~]# rabbitmqctl add_user test 123456
Adding user "test"...

7. ユーザー権限を構成する

[ 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. ファイアウォールを構成する

![]( /img/e9c5d3459dce1b9910a7cfafeae98edd/6e20c7neby.png)RabbitMQアクセスポート

[ 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)##

![]( /img/e9c5d3459dce1b9910a7cfafeae98edd/cmndkbeg0h.png)RabbitMQ管理の背景

![]( /img/e9c5d3459dce1b9910a7cfafeae98edd/67bufi83ss.png)rabbitmq管理の背景ホームページ

**10. ** rabbitmqノードを閉じる##

[ root@VM_147_130_centos ~]# service rabbitmq-server stop
Redirecting to /bin/systemctl stop rabbitmq-server.service

**11.**参考文献##

1.[ RabbitMQをダウンロードしてインストールします](https://www.rabbitmq.com/download.html)
2. rabbitmq’s repos
3.[ Centos7は最新のRabbitMQと構成をインストールします](https://blog.csdn.net/y_k_y/article/details/81350274)
4.[ RabbitMQポート](https://www.rabbitmq.com/networking.html#ports)


2、クラスター展開#

1. RabbitMQを2台のマシンに別々にインストールします##

RabbitMQ1マスターノード

RabbitMQ2スレーブノード

2. .erlang.cookを表示##

2.1 RabbitMQ1(マスターノード)###

[ root@VM_88_143_centos rabbitmq]# cat /var/lib/rabbitmq/.erlang.cookie
GKCVRDIVRNQIBWHJEDXU

2.2 RabbitMQ2(スレーブノード)###

[ root@VM_26_188_centos rabbitmq]# cat /var/lib/rabbitmq/.erlang.cookie
MVXVXZDFHYZGXTPGNMJM

3. RabbitMQスレーブnode.erlang.cookie値をマスターnode.erlang.cookie値に設定します##

3.1 .erlang.cookie値を設定します###

[ root@VM_26_188_centos rabbitmq]# chmod +w .erlang.cookie[root@VM_26_188_centos rabbitmq]# echo -e "GKCVRDIVRNQIBWHJEDXU\c" > .erlang.cookie[root@VM_26_188_centos rabbitmq]# chmod -w .erlang.cookie

3.2 スレーブノードを再起動します###

[ 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. ホスト名を介してpingできるようにRabbitMQノードを設定します##

[ 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
[ 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アプリケーションを停止します###

[ 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スレーブノードがマスターノードに参加します###

[ 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アプリケーションから開始###

[ 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.

![]( /img/e9c5d3459dce1b9910a7cfafeae98edd/piw7qfge7a.png)RabbitMQクラスター

6. ミラークラスター(高可用性)##

6.1 set policy

[ 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 "/"...

![]( /img/e9c5d3459dce1b9910a7cfafeae98edd/lvfc3t3op5.png)RabbitMQミラーリングクラスターポリシー

6.2 set cluster_partition_handling

[ 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

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サービスはrabbitmqctlstop | startコマンドを使用する必要があります。サービスrabbitmq-serverstop | startはサービスモードで開始できません。そうしないと、スレーブノードがマスターノードに参加できません。

[ 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 forthis 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プラグインが有効になっていません

[ root@VM_26_188_centos rabbitmq]# vi /var/log/rabbitmq/rabbit@VM_26_188_centos.log
2019- 06- 1813: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-1813: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プラグインのリストを表示する

[ 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 RabbitMQAMQPプラグインを有効にする

[ 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.
[ 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クラスターの構築](https://blog.csdn.net/jinyidong/article/details/80003362)
2. Highly Available (Mirrored) Queues
3.[ RabbitMQクラスター](https://blog.51cto.com/13641879/2152912)4。[rabbitmq-ホスト名を変更せずにクラスターを構築する](https://blog.csdn.net/vbaspdelphi/article/details/62037457)
5.[ RabbitMQ入門シリーズ(4)-RabbitMQの開始、停止ノードとアプリケーション、ユーザー管理、アクセス許可の構成](https://blog.csdn.net/wohu1104/article/details/91469537)
6.[ CentOS7がホスト名を変更するための3つの方法](https://blog.csdn.net/xuheng8600/article/details/79983927)
7. Srping AMQP RabbitMQ support
8. Clustering and Network Partitions

Recommended Posts

CentOS7にRabbitMQをインストールします
セントスにRabbitMQをインストールする
CentOS7にRabbitMQをインストールします
CentOS7にRabbitMQをインストールします
centOsはrabbitMQをインストールします
Centos7にDockerをインストールする
Centos7.4はLNMPをインストールします
Centos7にJavaをインストールする
CentOS8にFFmpegをインストールします
CentosにNode.jsをインストールします
Mavenはcentos7にインストールします
CentOS7にMongoDBをインストールします
CentOS8にSurelogをインストールする
Jenkinsをcentos7にインストールします
centos6.5にDockerをインストールします
セントスにオラクルをインストールする
Centos7にElasticsearch6をインストールします
mysqlをcentosにオンラインでインストールする
LinuxCentosにMySQL8.0.16をインストールします
Centos7にdockertransferをインストールします
Centosシステムにdockerをインストールします
セントスにEPELリポジトリをインストールする
1.5Centos7をインストールする
CentOS7に基づくZabbix3.4をインストールします
centosサーバーにvirtualboxをインストールする
CentOS7にNginxサーバーをインストールします
centOS7にjdk1.8をインストールする方法
CentOS8にMySQLをインストールする方法
CentOS7にrpmでJDK8をインストールします
CentOS8にMemcachedをインストールする方法
CentOS7にMATEまたはXFCEをインストールします
CentOS8にRをインストールする方法
CentOS8にVirtualboxをインストールする方法
CentOS8にTensorFlowをインストールする方法
CentOS8にTeamViewerをインストールする方法
CentOSにPerl5をインストールする方法
CentOS8にGitをインストールする方法
CentOS8にGradleをインストールする方法
CentOS8にElasticsearchをインストールする方法
CentOS8にJavaをインストールする方法
CentOS8にGoをインストールする方法
CentOS8にGCCをインストールする方法
CentOS8にYarnをインストールする方法
CentOS8にNginxをインストールする方法
CentOS7にAsteriskをインストールする方法
CentOS8にJenkinsをインストールする方法
Linux CentOS7(Windows)にMySQLをインストールする
CentOS8にVagrantをインストールする方法
CentOS8にPython3.8をインストールする方法
CentOS8にTomcat9をインストールする方法
CentOS8にWebminをインストールする方法
CentOS8にRubyをインストールする方法
CentOS8にSkypeをインストールする方法
CentOS8にhtopをインストールする方法
CentOSLinuxにOracleデータベースをインストールします
CentOS8にElasticsearchをインストールする方法
CentOS8にPostgresqlをインストールする方法
CentosにWordpressをインストールする方法
CentOS8にTeamViewerをインストールする方法
CentOS7にMongoDBをインストールする方法
CentOS8にOdoo13をインストールする方法