1.条件:准备3台Linux系统虚拟机,保持系统版本一致,确保配置好yum源,及网络源
2.3台虚拟机做静态解析
[root@yun1 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.127.135 yun1 192.168.127.136 yun2 192.168.127.137 yun3 192.168.127.138 yun4
3.设置无密钥登陆
4.配置防火墙规则
iptables -I INPUT -s 192.168.127.0/24 -p tcp --dport 5672 -j ACCEPT iptables -I INPUT -s 192.168.127.0/24 -p tcp --dport 15672 -j ACCEPT iptables -A INPUT -p tcp --dport 5672 -j REJECT iptables -A INPUT -p tcp --dport 15672 -j REJECT
yum install -y erlang rabbitmq-server.noarch systemctl enable rabbitmq-server.service systemctl start rabbitmq-server.service systemctl status rabbitmq-server.service
[root@yun1 ~]# netstat -lantp | grep 5672
vim /etc/rabbitmq/rabbitmq.config
[root@yun1 ~]# rabbitmqctl change_password guest admin Changing password for user "guest" ...
[root@yun1 ~]# rabbitmqctl add_user openstack admin Creating user "openstack" ... [root@yun1 ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*" Setting permissions for user "openstack" in vhost "/" ... [root@yun1 ~]# rabbitmqctl set_user_tags openstack administrator Setting tags for user "openstack" to [administrator] ...
RABBITMQ_NODE_PORT=5672 ulimit -S -n 4096 RABBITMQ_SERVER_ERL_ARGS="+K true +A30 +P 1048576 -kernel inet_default_connect_options [{nodelay,true},{raw,6,18,<<5000:64/native>>}] -kernel inet_default_listen_options [{raw,6,18,<<5000:64/native>>}]" RABBITMQ_NODE_IP_ADDRESS=192.168.127.135
"/etc/rabbitmq/rabbitmq-env.conf" 4L, 286C 已写入 [root@yun1 ~]# scp /etc/rabbitmq/rabbitmq-env.conf yun2:/etc/rabbitmq/ rabbitmq-env.conf 100% 286 0.3KB/s 00:00 [root@yun1 ~]# scp /etc/rabbitmq/rabbitmq-env.conf yun3:/etc/rabbitmq/ rabbitmq-env.conf
[root@yun1 ~]# /usr/lib/rabbitmq/bin/rabbitmq-plugins list
rabbitmq-plugins enable rabbitmq_management systemctl restart rabbitmq-server.service systemctl status rabbitmq-server.service
[root@yun2 ~]# rabbitmqctl cluster_status #查看rabbitmq的状态 Cluster status of node rabbit@yun2 ... [{nodes,[{disc,[rabbit@yun2]}]}, {running_nodes,[rabbit@yun2]}, {cluster_name,<<"rabbit@yun2">>}, {partitions,[]}, {alarms,[{rabbit@yun2,[]}]}]
[root@yun1 ~]# cat /var/lib/rabbitmq/.erlang.cookie IRWFJQZPVRHYOTK
[root@yun1 ~]# scp /var/lib/rabbitmq/.erlang.cookie yun2:/var/lib/rabbitmq/.erlang.cookie .erlang.cookie 100% 20 0.0KB/s 00:00 [root@yun1 ~]# scp /var/lib/rabbitmq/.erlang.cookie yun3:/var/lib/rabbitmq/.erlang.cookie .erlang.cookie
[root@yun3 ~]# systemctl restart rabbitmq-server.service [root@yun3 ~]# rabbitmqctl stop_app Stopping node rabbit@yun3 .. [root@yun3 ~]# rabbitmqctl join_cluster --ram rabbit@yun1 Clustering node rabbit@yun3 with rabbit@yun1 ... Error: unable to connect to nodes [rabbit@yun1]: nodedown DIAGNOSTICS =========== attempted to contact: [rabbit@yun1] rabbit@yun1: * unable to connect to epmd (port 4369) on yun1: address (cannot connect to host/port) current node details: - node name: ‘rabbitmq-cli-25@yun3‘ - home dir: /var/lib/rabbitmq - cookie hash: wCM6VjtONuseC1mVH1gL4A== [root@yun2 ~]# rabbitmqctl start_app Starting node rabbit@yun2 ...
[root@yun1 ~]# rabbitmqctl cluster_status Cluster status of node rabbit@yun1 ... [{nodes,[{disc,[rabbit@yun1]},{ram,[rabbit@yun3,rabbit@yun2]}]}, {running_nodes,[rabbit@yun3,rabbit@yun2,rabbit@yun1]}, {cluster_name,<<"rabbit@yun1">>}, {partitions,[]}, {alarms,[{rabbit@yun3,[]},{rabbit@yun2,[]},{rabbit@yun1,[]}]}]
http://192.168.127.135:15672/
注意:
原文:https://www.cnblogs.com/CruxAustralis/p/11254075.html