队列元数据、交换器元数据、绑定元数据、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