最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Centos7環(huán)境下搭建Rabbitmq集群教程

 更新時間:2026年05月04日 10:42:09   作者:84歲帶頭沖鋒  
本文主要介紹了在CentOS 7.6上安裝和配置RabbitMQ集群的過程,包括安裝依賴、配置Erlang cookie、搭建集群、添加信任關(guān)系、安裝管理插件等步驟,最后介紹了如何創(chuàng)建鏡像隊列以提高集群的可用性

一、服務(wù)器環(huán)境

操作系統(tǒng):centos7.6

[root@localhost opt]# uname -srm
Linux 3.10.0-957.el7.x86_64 x86_64

服務(wù)器IP

192.168.161.16 node16
192.168.161.17 node17
192.168.161.18 node18

安裝包

二、服務(wù)搭建

2.1 配置服務(wù)器名稱

在正式部署環(huán)境前,需要將本節(jié)點(diǎn)必須的集群其他機(jī)器的IP、主機(jī)名加入hosts文件,執(zhí)行指令如下:

[root@localhost opt]# vim /etc/hosts
#node
192.168.161.16 node16
192.168.161.17 node17
192.168.161.18 node18

注:根據(jù)實(shí)際配置,將所有集IP都添加進(jìn)去。

2.2 關(guān)閉防火墻與增強(qiáng)

不關(guān)閉防火墻開放端口

開通端口:

[root@localhost opt]# 
firewall-cmd --permanent --add-port={4369/tcp,25672/tcp,5671/tcp,5672/tcp,15672/tcp}
或者
關(guān)閉防火墻
[root@localhost opt]# systemctl stop firewalld
[root@localhost opt]# systemctl disable firewalld

通常,在部署環(huán)境時候需要關(guān)閉selinux。編輯/etc/selinux/config文件將SELINUX設(shè)置為disabled。如下
[root@localhost opt]# vim /etc/selinux/config
[root@localhost opt]# setenforce 0   ##臨時關(guān)閉,不需要重啟即可生效

2.3 添加信任關(guān)系

生成密鑰對(所有服務(wù)器均處理)

[root@localhost opt]# ssh-keygen -t rsa

將公鑰復(fù)制到需要無密碼登陸的服務(wù)器上

在192.168.161.16服務(wù)器上執(zhí)行:
[root@localhost opt]# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@192.168.161.17
[root@localhost opt]# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@192.168.161.18

在192.168.161.17服務(wù)器上執(zhí)行:
[root@localhost opt]# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@192.168.161.16
[root@localhost opt]# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@192.168.161.18

在192.168.161.18服務(wù)器上執(zhí)行:
[root@localhost opt]# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@192.168.161.16
[root@localhost opt]# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@192.168.161.17

2.4 安裝erlang

[root@localhost opt]# rpm -ivh erlang-19.0.4-1.el7.centos.x86_64.rpm

2.5 安裝RabbitMQ

[root@localhost opt]# rpm -ivh erlang-19.0.4-1.el7.centos.x86_64.rpm 
[root@localhost opt]# rpm --import rabbitmq-release-signing-key.asc 
[root@localhost opt]# rpm -ivh tcp_wrappers-7.6-77.el7.x86_64.rpm 
[root@localhost opt]# rpm -ivh socat-1.7.2.4-1.el7.rf.x86_64.rpm
[root@localhost opt]# rpm -ivh rabbitmq-server-3.6.12-1.el7.noarch.rpm

2.6 查看啟動狀態(tài)與日志

日志文件位置:/var/log/rabbitmq/

[root@localhost ~]# systemctl start rabbitmq-server.service 
[root@localhost ~]# systemctl status rabbitmq-server.service 

出現(xiàn)running則啟動成功

2.7 安裝管理插件

2.7.1安裝web管理插件

查看插件列表

[root@localhost ~]# rabbitmq-plugins list

安裝插件

[root@localhost ~]# rabbitmq-plugins enable rabbitmq_management

2.7.2 安裝日志管理插件

#rabbitmq啟用trace插件
[root@localhost ~]# rabbitmq-plugins enable rabbitmq_tracing
#打開trace的開關(guān):rabbitmqctl trace_on
#打開trace的開關(guān)(test為需要日志追蹤的vhost):rabbitmqctl trace_on -p test
#關(guān)閉trace的開關(guān):rabbitmqctl trace_off

2.7.3安裝rabbitmq_delayed_message_exchange(延時隊列)

將rabbitmq_delayed_message_exchange-0.0.1.ez傳至/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.12/plugins目錄下

[root@localhost opt]# mv rabbitmq_delayed_message_exchange-0.0.1.ez  /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.12/plugins/
[root@localhost opt]# cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.12/plugins/
[root@localhost plugins]# rabbitmq-plugins enable rabbitmq_delayed_message_exchange

出現(xiàn)以下信息則說明啟動成功

至此3臺上面的rabbitmq都已安裝完成,并且啟動正常,現(xiàn)在開始配置集群服務(wù)。

2.8 普通集群配置

2.8.1 設(shè)置每個節(jié)點(diǎn)的cookie

說明:Rabbitmq的集群是依附于erlang的集群來工作的,所以必須先構(gòu)建起erlang的集群鏡像。Erlang的集群中各節(jié)點(diǎn)是經(jīng)由過程一個magic cookie來實(shí)現(xiàn)的,這個cookie存放在 $home/.erlang.cookie 中,我的是用rpm安裝的,所以.erlang.cookie就放在/var/lib/rabbitmq中。

erlang.cookie是erlang實(shí)現(xiàn)分布式的必要文件,erlang分布式的每個節(jié)點(diǎn)上要保持相同的.erlang.cookie文件,同時保證文件的權(quán)限是400,不然節(jié)點(diǎn)之間就無法通信。

打開文件然后需要先把其中的一臺服務(wù)器的.erlang.cookie中的內(nèi)容復(fù)制到別的機(jī)器上,最好是復(fù)制內(nèi)容,因?yàn)槲募?quán)限不對的話會出現(xiàn)問題,在最后退出保存的時候使用wq!用來進(jìn)行強(qiáng)制保存即可.

比如以192.168.161.16 node16為準(zhǔn)

[root@localhost plugins]# cd /var/lib/rabbitmq/
[root@localhost rabbitmq]# cat .erlang.cookie
RGDIJSPIUOPKSUACDCVU

再編輯另兩臺.erlang.cookie,將原來的內(nèi)容刪掉替換為RGDIJSPIUOPKSUACDCVU;使用wq!強(qiáng)制保存。

erlang.cookie復(fù)制完成后,逐個重啟節(jié)點(diǎn)服

[root@localhost rabbitmq]# systemctl stop rabbitmq-server.service
[root@localhost rabbitmq]# systemctl start rabbitmq-server.service 
[root@localhost rabbitmq]# systemctl status rabbitmq-server.service 

2.8.2 添加到集群

以節(jié)點(diǎn)192.168.161.16為集群主節(jié)點(diǎn),在節(jié)點(diǎn)192.168.161.17和節(jié)點(diǎn)192.168.161.18上添加配置,以加入到集群中

[root@localhost rabbitmq]# rabbitmqctl stop_app
Stopping rabbit application on node rabbit@localhost
[root@localhost rabbitmq]# rabbitmqctl reset
Resetting node rabbit@localhost
[root@localhost rabbitmq]# rabbitmqctl join_cluster rabbit@192.168.161.16
[root@localhost rabbitmq]# rabbitmqctl start_app
Starting node rabbit@localhost

每臺都查看集群狀態(tài)

[root@localhost rabbitmq]# rabbitmqctl cluster_status

2.8.3 賬號管理

==添加賬號:(僅在主節(jié)點(diǎn)上執(zhí)行即可)==
[root@localhost rabbitmq]# rabbitmqctl add_user admin admin
Creating user "admin"
==添加權(quán)tag:==
[root@localhost rabbitmq]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator]
[root@localhost rabbitmq]# rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'
Setting permissions for user "admin" in vhost "/"
==查看當(dāng)前用戶列表:==
[root@localhost rabbitmq]# rabbitmqctl list_users
Listing users
admin	[administrator]
guest	[administrator]
==查看用戶權(quán)限:==
[root@localhost rabbitmq]# rabbitmqctl list_user_permissions admin
Listing permissions for user "admin"
/	.*	.*	.*
[root@localhost rabbitmq]# 

其他操作:

刪除用戶guest
[root@localhost rabbitmq]# rabbitmqctl delete_user guest 
Deleting user "guest"
查看用戶列表
[root@localhost rabbitmq]# rabbitmqctl list_users
Listing users
admin	[administrator]
更改用戶密碼
[root@localhost rabbitmq]# rabbitmqctl change_password Username Newpassword

[root@localhost rabbitmq]# rabbitmqctl change_password admin 123456
Changing password for user "admin"

2.8.4 訪問web地址

URL:
http://192.168.161.16:15672

使用admin登陸,登陸成功后界面如下:

至此rabbitmq普通集群模式創(chuàng)建完成.

2.9其他維護(hù)操作

2.9.1從集群中移除節(jié)點(diǎn)

(在需要移除的節(jié)點(diǎn)服務(wù)器上操作,比如移除node17)

[root@node17 rabbitmq]#rabbitmqctl stop_app
[root@node17 rabbitmq]#rabbitmqctl reset
[root@node17 rabbitmq]#rabbitmqctl start_app

2.9.2改變集群節(jié)點(diǎn)類型

加入集群時指定節(jié)點(diǎn)類型:

[root@node16 rabbitmq]]#rabbitmqctl stop_app
[root@node16 rabbitmq]]#rabbitmqctl join_cluster --ram rabbit@192.168.161.16
[root@node16 rabbitmq]]#rabbitmqctl start_app

備注:–ram 指定內(nèi)存節(jié)點(diǎn)類型,–disc指定磁盤節(jié)點(diǎn)類型

修改節(jié)點(diǎn)類型:

[root@node16 rabbitmq]]#rabbitmqctl stop_app
[root@node16 rabbitmq]]#rabbitmqctl change_cluster_node_type disc
[root@node16 rabbitmq]]#rabbitmqctl start_app

2.9.3日志文件

/var/log/rabbitmq/rabbit@node16.log
/var/log/rabbitmq/rabbit@node16-sasl.log

2.10集群鏡像模式配置

上面配置RabbitMQ默認(rèn)集群模式,但并不保證隊列的高可用性,盡管交換機(jī)、綁定這些可以復(fù)制到集群里的任何一個節(jié)點(diǎn),但是隊列內(nèi)容不會復(fù)制,雖然該模式解決一部分節(jié)點(diǎn)壓力,但隊列節(jié)點(diǎn)宕機(jī)直接導(dǎo)致該隊列無法使用,只能等待重啟,所以要想在隊列節(jié)點(diǎn)宕機(jī)或故障也能正常使用,就要復(fù)制隊列內(nèi)容到集群里的每個節(jié)點(diǎn),需要創(chuàng)建鏡像隊列。

鏡像隊列的創(chuàng)建可通過rabbitmq管理界面或者使用命令來創(chuàng)建。

  • Pattern:“^” 表示所有匹配所有隊列名稱。”^log” 是指同步”log”開頭的隊列名稱。
  • ha-mode:“all”代表同步到所以節(jié)點(diǎn)。

2.10.1 命令方式建立鏡像隊列

輸入以下命令:(所有服務(wù)器均操作)

rabbitmqctl set_policy ha-all “^” ‘{“ha-mode”:“all”}'

這樣三臺rabbitmq就可以數(shù)據(jù)同步了。

2.10.2 rabbitmq管理界面方式建立鏡像隊列

總結(jié)

以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • apache下運(yùn)行cgi模式的配置方法

    apache下運(yùn)行cgi模式的配置方法

    這篇文章主要介紹了apache下運(yùn)行cgi模式的配置方法,需要的朋友可以參考下
    2014-04-04
  • Linux常用查看硬件設(shè)備信息命令大全(值得收藏)

    Linux常用查看硬件設(shè)備信息命令大全(值得收藏)

    本文是小編收藏整理的關(guān)于linux查看硬件設(shè)備信息的命名,非常不錯,值得收藏,需要的朋友參考下吧
    2016-12-12
  • 詳解Centos7源碼編譯安裝 php7.2之生產(chǎn)篇

    詳解Centos7源碼編譯安裝 php7.2之生產(chǎn)篇

    這篇文章主要介紹了詳解Centos7源碼編譯安裝 php7.2之生產(chǎn)篇,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-06-06
  • Linux(CentOS)安裝Nginx圖文教程

    Linux(CentOS)安裝Nginx圖文教程

    本文文介紹了兩種安裝Nginx的方式:通過yum安裝和通過編譯源碼包安裝,yum安裝簡單,全程無憂,但需root權(quán)限;編譯安裝需具備配置相關(guān)操作,但安裝后可能定制化更強(qiáng),最后附上了設(shè)置Nginx服務(wù)開機(jī)啟動的方法
    2026-04-04
  • 淺談Linux內(nèi)核創(chuàng)建新進(jìn)程的全過程

    淺談Linux內(nèi)核創(chuàng)建新進(jìn)程的全過程

    這篇文章主要為大家深入淺出的介紹了Linux內(nèi)核創(chuàng)建新進(jìn)程的全過程,感興趣的小伙伴們可以參考一下
    2016-01-01
  • rsync如何實(shí)現(xiàn)斷點(diǎn)續(xù)傳

    rsync如何實(shí)現(xiàn)斷點(diǎn)續(xù)傳

    rsync命令是一種高效的文件傳輸工具,相較于scp命令,它具有支持?jǐn)帱c(diǎn)續(xù)傳和僅拷貝修改過的文件等優(yōu)勢,大大提高了文件傳輸?shù)男?特別適用于傳輸大文件和定期同步文件夾,通過參數(shù)配置,rsync能夠?qū)崿F(xiàn)多種高級功能
    2024-10-10
  • Linux系統(tǒng)中配置靜態(tài)IP地址的詳細(xì)步驟

    Linux系統(tǒng)中配置靜態(tài)IP地址的詳細(xì)步驟

    本文詳細(xì)介紹了在Linux系統(tǒng)中配置靜態(tài)IP地址的五個步驟,包括打開終端、編輯網(wǎng)絡(luò)配置文件、配置IP地址、保存并重啟網(wǎng)絡(luò)服務(wù),這對于系統(tǒng)管理員和新手都極具參考價值,需要的朋友可以參考下
    2025-03-03
  • centos更改時區(qū)的方法

    centos更改時區(qū)的方法

    centos默認(rèn)使用UTC時區(qū),中國用戶需要修改成自己的時區(qū),這篇文章主要介紹了centos更改時區(qū)的方法,需要的朋友可以參考下
    2014-03-03
  • 解決Linux中Systemd服務(wù)環(huán)境變量缺失的問題

    解決Linux中Systemd服務(wù)環(huán)境變量缺失的問題

    在Linux系統(tǒng)運(yùn)維中,我們可能會遇到在使用systemd管理的服務(wù)時無法獲取系統(tǒng)環(huán)境變量,尤其是PATH變量,這確實(shí)是一個常見的挑戰(zhàn),因?yàn)閟ystemd啟動的服務(wù)通常不會加載用戶的環(huán)境變量,下面,我們將一起探討解決這一問題的幾種方法,需要的朋友可以參考下
    2024-01-01
  • 詳解Linux(Centos)之安裝Nginx及注意事項

    詳解Linux(Centos)之安裝Nginx及注意事項

    Nginx是一個高性能的HTTP和反向代理服務(wù)器,這篇文章主要介紹了詳解Linux(Centos)之安裝Nginx及注意事項,有興趣的可以了解一下。
    2017-03-03

最新評論

黄陵县| 盐山县| 嘉义市| 土默特左旗| 西林县| 佛学| 天祝| 辰溪县| 惠州市| 台中县| 尚义县| 汉沽区| 社会| 西贡区| 武清区| 寿阳县| 房山区| 台南市| 高邑县| 沽源县| 云龙县| 永川市| 高淳县| 中西区| 密山市| 砚山县| 蒙阴县| 和静县| 吉水县| 司法| 洪雅县| 乐清市| 米脂县| 南召县| 浪卡子县| 楚雄市| 达拉特旗| 南岸区| 海林市| 仁化县| 麻栗坡县|