隊列元數據、交換器元數據、綁定元數據、vhost元數據。
單一節點中:會將數據存儲到內存,同時將持久化元數據保存到硬盤。
集羣中: 存儲到磁盤上、內存中。
集羣中的隊列:不是每個rabbitmq節點都有全部隊列的拷貝,集羣只會在單個節點上建立完整信息。node
內存節點: 元數據定義都存儲在內存中。內存節點有出色的性能。
磁盤節點: 元數據定義都存儲在磁盤中(單節點服務器都是磁盤節點)。磁盤節點能持久化信息。
rabbitmq集羣中至少有一個磁盤節點。當節點加入或者離開集羣時,必須將變動通知到至少一個磁盤節點。
若是集羣只有一個磁盤節點,正好它崩了。此時集羣還能夠路由消息。可是不能建立元數據和管理用戶和節點。解決方案是集羣中設置兩個磁盤節點。web
rabbitmqctl stop
RABBITMQ_NODE_PORT=5672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" RABBITMQ_NODENAME=rabbit rabbitmq-server -detached RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]" RABBITMQ_NODENAME=rabbit_1 rabbitmq-server -detached RABBITMQ_NODE_PORT=5674 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}]" RABBITMQ_NODENAME=rabbit_2 rabbitmq-server -detached
rabbit服務器
[root@localhost ~]# rabbitmqctl -n rabbit@localhost add_user admin admin [root@localhost ~]# rabbitmqctl -n rabbit@localhost set_user_tags admin administrator [root@localhost ~]# rabbitmqctl -n rabbit@localhost set_permissions -p / admin ".*" ".*" ".*"
rabbit_1架構
[root@localhost ~]# rabbitmqctl -n rabbit_1 add_user admin admin [root@localhost ~]# rabbitmqctl -n rabbit_1 set_user_tags admin administrator [root@localhost ~]# rabbitmqctl -n rabbit_1 set_permissions -p / admin ".*" ".*" ".*"
rabbit_2:app
[root@localhost ~]# rabbitmqctl -n rabbit_2 add_user admin admin [root@localhost ~]# rabbitmqctl -n rabbit_2 set_user_tags admin administrator [root@localhost ~]# rabbitmqctl -n rabbit_2 set_permissions -p / admin ".*" ".*" ".*"
訪問web頁面: http://ip:15672/#/ http://ip:15673/#/ http://ip:15674/#/性能
[root@localhost ~]# rabbitmqctl -n rabbit_1 stop_app [root@localhost ~]# rabbitmqctl -n rabbit_1 reset [root@localhost ~]# rabbitmqctl -n rabbit_1 join_cluster rabbit@localhost [root@localhost ~]# rabbitmqctl -n rabbit_1 start_app
[root@localhost ~]# rabbitmqctl -n rabbit_2 stop_app [root@localhost ~]# rabbitmqctl -n rabbit_2 reset [root@localhost ~]# rabbitmqctl -n rabbit_2 join_cluster rabbit@localhost --ram [root@localhost ~]# rabbitmqctl -n rabbit_2 start_app
[root@localhost ~]# rabbitmqctl cluster_status
獲得如下結果:ui
[root@localhost ~]# rabbitmqctl cluster_status Cluster status of node rabbit@localhost [{nodes,[{disc,[rabbit@localhost,rabbit_1@localhost]}, {ram,[rabbit_2@localhost]}]}, {running_nodes,[rabbit_2@localhost,rabbit_1@localhost,rabbit@localhost]}, {cluster_name,<<"rabbit@localhost">>}, {partitions,[]}, {alarms,[{rabbit_2@localhost,[]}, {rabbit_1@localhost,[]}, {rabbit@localhost,[]}]}]
訪問web頁面能夠看見集羣信息(兩個磁盤節點,一個內存節點)code