1、安装RabbitMQ-server
[[email protected] ~]# yum install -y erlang rabbitmq-server
[[email protected] ~]# systemctl start rabbitmq-server.service
[[email protected] ~]# systemctl enable rabbitmq-server.service
[[email protected] ~]# systemctl status rabbitmq-server.service
[[email protected] ~]# systemctl list-unit-files | grep rabbitmq
rabbitmq-server.service enabled
以上三个节点同时进行
2
[[email protected] ~]# rabbitmqctl add_user openstack zoomtech
Creating user "openstack" ...
[[email protected] ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...
[[email protected] ~]# /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent
The following plugins have been enabled:
webmachine
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management
mochiweb
amqp_client
Applying plugin configuration to [email protected] failed.
* Could not contact node [email protected]
Changes will take effect at broker restart.
* Options: --online - fail if broker cannot be contacted.
--offline - do not try to contact broker.
[[email protected] ~]# systemctl restart rabbitmq-server.service
[[email protected] ~]# systemctl status rabbitmq-server.service
登录:http://192.168.17.132:15672/#/
Username: guest Password:guest
新增一个用户,在三个节点中操作
[[email protected] ~]# rabbitmqctl add_user mqadmin mqadmin
Creating user "mqadmin" ...
[[email protected] ~]# rabbitmqctl set_permissions -p / mqadmin ".*" ".*" ".*"
Setting permissions for user "mqadmin" in vhost "/" ...
[[email protected] ~]# rabbitmqctl status
复制.erlang.coolie到controller2和controller3
[[email protected] ~]# scp /var/lib/rabbitmq/.erlang.cookie controller2:/var/lib/rabbitmq/.erlang.cookie
[[email protected] ~]#
[[email protected] ~]# scp /var/lib/rabbitmq/.erlang.cookie controller3:/var/lib/rabbitmq/.erlang.cookie
将controller2加入到controller1集群中
[[email protected] ~]# systemctl restart rabbitmq-server.service
[[email protected] ~]# rabbitmqctl stop_app
Stopping node [email protected] ...
[[email protected] ~]# rabbitmqctl join_cluster --ram [email protected]
Clustering node [email protected] with [email protected] ...
[[email protected] ~]# rabbitmqctl start_app
Starting node [email protected] ...
将controller3加入到controller1集群中
[[email protected] ~]# systemctl restart rabbitmq-server.service
[[email protected] ~]# rabbitmqctl stop_app
Stopping node [email protected] ...
[[email protected] ~]# rabbitmqctl join_cluster --ram [email protected]
Clustering node [email protected] with [email protected] ...
在Controller1上查看集群状态
[[email protected] ~]# rabbitmqctl cluster_status
Cluster status of node [email protected] ...
[{nodes,[{disc,[[email protected]]},
{ram,[[email protected],[email protected]]}]},
{running_nodes,[[email protected],[email protected],[email protected]]},
{cluster_name,<<"[email protected]">>},
{partitions,[]},
{alarms,[{[email protected],[]},
{[email protected],[]},
{[email protected],[]}]}]
[[email protected] ~]# rabbitmqctl cluster_status
Cluster status of node [email protected] ...
[{nodes,[{disc,[[email protected]]},
{ram,[[email protected],[email protected]]}]},
{running_nodes,[[email protected],[email protected],[email protected]]},
{cluster_name,<<"[email protected]">>},
{partitions,[]},
{alarms,[{[email protected],[]},
{[email protected],[]},
{[email protected],[]}]}]