各組件經過消息發送與接收是實現組件之間的通訊:node
# yum install rabbitmq-server –ylinux
# systemctl start rabbitmq-server.serviceweb
# rabbitmqctl add_user openstack 123456服務器
# rabbitmqctl set_permissions openstack ".*" ".*" ".*"cookie
# rabbitmqctl set_user_tags user_admin administratorapp
# rabbitmq-plugins enable rabbitmq_management插件
# rabbitmq-plugins list #查看插件3d
默認用戶名密碼都是guest,能夠更改,web訪問端口爲15672:server
Rabbitmq的集羣是依賴於erlang的集羣來工做的,因此必須先構建起erlang的集羣環境。而Erlang的集羣中各節點是經過一個magic cookie來實現的,這個cookie存放在 /var/lib/rabbitmq/.erlang.cookie 中,文件是400的權限。因此必須保證各節點cookie保持一致,不然節點之間就沒法通訊。blog
# scp /var/lib/rabbitmq/.erlang.cookie 192.168.10.202:/var/lib/rabbitmq/.erlang.cookie
各服務器中止全部節點RabbitMq服務,而後使用detached參數以節點方式獨立運行
# systemctl stop rabbitmq-server
# rabbitmq-server –detached
# rabbitmqctl cluster_status
Cluster status of node 'rabbit@linux-host1'
在要加入集羣的節點操做
# rabbitmqctl stop_app #中止應程序
# rabbitmqctl reset #清空元數據
# rabbitmqctl join_cluster rabbit@linux-host2 --ram #將rabbitmq-server1添加到集羣當中,併成爲內存節點,不加--ram默認是磁盤節點
# rabbitmqctl start_app #不要忘記啓動應用程序
# rabbitmqctl cluster_status
Cluster status of node 'rabbit@rabbitmq-server1' ...
[{nodes,[{disc,['rabbit@linux-host1']}, #默認是磁盤節點
{ram,['rabbit@linux-host2']}]}] #內存節點
...done.
# rabbitmqctl cluster_status #添加以後的集羣狀態
Cluster status of node 'rabbit@linux-host2' ...
[{nodes,[{disc,['rabbit@linux-host1']}, #默認的是磁盤節點
{ram,['rabbit@linux-host2']}]}] #本身被添加爲內存節點
...done.
六、更改成鏡像模式:
# rabbitmqctl set_policy ha-all "#" '{"ha-mode":"all"}' #"#"爲任意0個或多個即爲全部,也能夠使用"^test"匹配開頭,還能夠使用其餘正則匹配
Setting policy "ha-all" for pattern "#" to "{\"ha-mode\":\"all\"}" with priority "0" ...
...done.
訪問web界面:默認用戶名爲guest密碼爲guest