ToB企服应用市场:ToB评测及商务社交产业平台

标题: RabbitMQ平常集群搭建指南 [打印本页]

作者: 乌市泽哥    时间: 2024-7-27 15:30
标题: RabbitMQ平常集群搭建指南
RabbitMQ平常集群搭建指南

   本文已经完全迁移至,www.geekery.cn 后续不在此更新
  目标架构

本次搭建的目标是构建一个由三个节点构成的RabbitMQ集群,节点信息如下:

准备工作

在开始之前,确保全部节点上都已安装RabbitMQ Server。假如尚未安装,可以通过以下下令进行安装:
  1. yum install -y epel-release
  2. yum install -y rabbitmq-server
复制代码
同时,设置主机名和修改/etc/hosts文件以正确剖析各节点的名称。
同步.erlang.cookie

为了答应节点间通信,需要确保全部节点上的.erlang.cookie文件内容相同。使用以下下令从rabbit02节点复制cookie到其他节点
  1. [root@rabbit02 ~]# scp /var/lib/rabbitmq/.erlang.cookie rabbit03:/var/lib/rabbitmq/
  2. The authenticity of host 'rabbit03 (192.168.10.133)' can't be established.
  3. ECDSA key fingerprint is SHA256:ImtbIE2DzY9M7yqwTDfMn3EzHOjk0CGowUigMe00exk.
  4. ECDSA key fingerprint is MD5:23:d8:46:37:71:8b:e3:56:d1:48:d4:f5:a9:64:80:f0.
  5. Are you sure you want to continue connecting (yes/no)? yes
  6. Warning: Permanently added 'rabbit03,192.168.10.133' (ECDSA) to the list of known hosts.
  7. root@rabbit03's password:
  8. .erlang.cookie                                                                                                                                             100%   20    24.5KB/s   00:00   
  9. [root@rabbit02 ~]# scp /var/lib/rabbitmq/.erlang.cookie rabbit04:/var/lib/rabbitmq/
  10. The authenticity of host 'rabbit04 (192.168.10.134)' can't be established.
  11. ECDSA key fingerprint is SHA256:ImtbIE2DzY9M7yqwTDfMn3EzHOjk0CGowUigMe00exk.
  12. ECDSA key fingerprint is MD5:23:d8:46:37:71:8b:e3:56:d1:48:d4:f5:a9:64:80:f0.
  13. Are you sure you want to continue connecting (yes/no)? yes
  14. Warning: Permanently added 'rabbit04,192.168.10.134' (ECDSA) to the list of known hosts.
  15. root@rabbit04's password:
  16. .erlang.cookie                                                                                                                                             100%   20    21.1KB/s   00:00   
  17. [root@rabbit02 ~]#
复制代码
集群设置

在rabbit03和rabbit04上执行以下步调:
  1. [root@rabbit03 ~]# rabbitmqctl stop_app
  2. Stopping node rabbit@rabbit03 ...
  3. ...done.
  4. [root@rabbit03 ~]# rabbitmqctl reset
  5. Resetting node rabbit@rabbit03 ...
  6. ...done.
  7. [root@rabbit03 ~]# systemctl stop firewalld
  8. [root@rabbit03 ~]# rabbitmqctl join_cluster --ram rabbit@rabbit02
  9. Clustering node rabbit@rabbit03 with rabbit@rabbit02 ...
  10. ...done.
复制代码
  1. [root@rabbit04 ~]# rabbitmqctl stop_app
  2. Stopping node rabbit@rabbit04 ...
  3. ...done.
  4. [root@rabbit04 ~]# systemctl stop firewalld
  5. [root@rabbit04 ~]# rabbitmqctl stop_app
  6. Stopping node rabbit@rabbit04 ...
  7. ...done.
  8. [root@rabbit04 ~]# rabbitmqctl reset
  9. Resetting node rabbit@rabbit04 ...
  10. ...done.
  11. [root@rabbit04 ~]# rabbitmqctl join_cluster --ram rabbit@rabbit02
  12. Clustering node rabbit@rabbit04 with rabbit@rabbit02 ...
  13. ...done.
复制代码
最终确认

在rabbit02上执行以下步调来确认集群状态:
这表明集群已经成功建立,并且rabbit02作为磁盘节点,rabbit03和rabbit04作为RAM节点加入了集群。
  1. [root@rabbit02 ~]# rabbitmqctl cluster_status
  2. Cluster status of node rabbit@rabbit02 ...
  3. [{nodes,[{disc,[rabbit@rabbit02]},{ram,[rabbit@rabbit04,rabbit@rabbit03]}]},
  4. {running_nodes,[rabbit@rabbit02]},
  5. {cluster_name,<<"rabbit@rabbit02">>},
  6. {partitions,[]}]
  7. ...done.
  8. [root@rabbit02 ~]#
  9. [root@rabbit03 ~]# rabbitmqctl cluster_status
  10. Cluster status of node rabbit@rabbit03 ...
  11. [{nodes,[{disc,[rabbit@rabbit02]},{ram,[rabbit@rabbit03]}]}]
  12. ...done.
  13. [root@rabbit03 ~]#
  14. [root@rabbit03 ~]# rabbitmqctl cluster_status
  15. Cluster status of node rabbit@rabbit03 ...
  16. [{nodes,[{disc,[rabbit@rabbit02]},{ram,[rabbit@rabbit03]}]}]
  17. ...done.
复制代码
END

一些有用没用的历史下令!!!可以不消看了
  1. yum install -y epel* ;yum install -y rabbitmq-server
  2. vi /etc/hosts
  3. hostnamectl set-hostname rabbit02
  4. vi /etc/hosts
  5. find / -name *.cookie
  6. man rabbitmq-server
  7. rabbitmq-server -detached
  8. scp /var/lib/rabbitmq/.erlang.cookie rabbit03:/var/lib/rabbitmq/
  9. scp /var/lib/rabbitmq/.erlang.cookie rabbit04:/var/lib/rabbitmq/
  10. systemctl status rabbitmq-server
  11. systemctl restart rabbitmq-server.service
  12. systemctl status rabbitmq-server.service
  13. chmod 400 /var/lib/rabbitmq/.erlang.cookie
  14. systemctl restart rabbitmq-server.service
  15. systemctl status rabbitmq-server.service
  16. find / -name *.cookie
  17. systemctl stop firewalld
  18. rabbitmqctl cluster_status
  19. history
  20. yum install -y epel* ;yum install -y rabbitmq-server
  21. hostnamectl set-hostname rabbit03
  22. vi /etc/hosts
  23. rabbitmq-server -detached
  24. chmod 400 /var/lib/rabbitmq/.erlang.cookie
  25. systemctl restart rabbitmq-server.service
  26. systemctl status rabbitmq-server.service
  27. systemctl restart rabbitmq-server.service
  28. systemctl status rabbitmq-server.service
  29. chmod 400 /var/lib/rabbitmq/.erlang.cookie
  30. systemctl restart rabbitmq-server.service
  31. rabbitmq-server -detached
  32. systemctl start rabbitmq-server.service
  33. systemctl status rabbitmq-server.service
  34. ps -ef | grep rabbit
  35. kill -9 1969
  36. ps -ef | grep rabbit
  37. kill -9 1999
  38. ps -ef | grep rabbit
  39. systemctl start rabbitmq-server.service
  40. systemctl status rabbitmq-server.service
  41. rabbitmqctl stop_app
  42. rabbitmqctl reset
  43. rabbitmqctl join_cluster --ram rabbit@rabbit02
  44. systemctl stop firewalld
  45. rabbitmqctl join_cluster --ram rabbit@rabbit02
  46. rabbitmqctl cluster_status
  47. history
  48. yum install -y epel* ;yum install -y rabbitmq-server
  49. hostnamectl set-hostname rabbit04
  50. vi /etc/hosts
  51. rabbitmq-server -detached
  52. chmod 400 /var/lib/rabbitmq/.erlang.cookie
  53. systemctl restart rabbitmq-server
  54. systemctl status rabbitmq-server
  55. rabbitmq-server -detached
  56. systemctl status rabbitmq-server
  57. systemctl restart rabbitmq-server
  58. find / -name *.cookie
  59. ps -ef | grep rabbit
  60. kill -9  1960 1990  
  61. ps -ef | grep rabbit
  62. systemctl restart rabbitmq-server
  63. systemctl status rabbitmq-server
  64. rabbitmqctl stop_app
  65. systemctl stop firewalld
  66. rabbitmqctl stop_app
  67. rabbitmqctl reset
  68. rabbitmqctl join_cluster --ram rabbit@rabbit02
  69. rabbitmqctl cluster_status
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4