在centos7上构建rabbitmq单节点集群 2019-05-13
rabbitMQ,MQ全称为Message Queue,消息列队是一种应用程序对应#用程序的通信方法。应用程序通过读写出入的消息(针对应哟程序的数据)来通信,而无需专用连接来链接它们。
在centos7上构建rabbitmq单节点集群
centos7+网络环境
安装rabbitmq-server:
添加任意一个openstack的镜像源(yum -y install centos-release-openstack-pike.x86_64)
[[email protected] ~]# yum -y install rabbitmq-server
启动:
[[email protected] ~]# systemctl start rabbitmq-server
[[email protected] ~]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2019-05-11 08:07:50 EDT; 1s ago
Main PID: 10915 (beam)
Status: "Initialized"
CGroup: /system.slice/rabbitmq-server.service
├─10915 /usr/lib64/erlang/erts-7.3.1.2/bin/beam -W w -A 64 -P 1048576 -t 5000000 -stbt db -K true ...
├─11096 inet_gethost 4
└─11097 inet_gethost 4
配置管理员用户:
[[email protected] ~]# rabbitmqctl add_user admin admin
Creating user "admin" ...
[[email protected] ~]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...
[[email protected] ~]# rabbitmqctl set_permissions admin ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "/" ...
添加rabbit-2节点:
[[email protected] ~]# RABBITMQ_NODE_PORT=5673 RABBITMQ_NODENAME=rabbit-2 rabbitmq-server -detached(rabbitm默认端口号为5672)
Warning: PID file not written; -detached was passed.(警告好像没什么用)
[[email protected] ~]# rabbitmqctl -n rabbit-2 stop_app
Stopping node '[email protected]' ...
[[email protected] ~]# rabbitmqctl -n rabbit-2 join_cluster [email protected]`hostname -s`
Clustering node '[email protected]' with [email protected] ...
[[email protected] ~]# rabbitmqctl -n rabbit-2 start_app
Starting node '[email protected]' ...
查询集群状态:
[[email protected] ~]# rabbitmqctl cluster_status
Cluster status of node [email protected] ...
[{nodes,[{disc,['[email protected]',[email protected]]}]},
{running_nodes,['[email protected]',[email protected]]},
{cluster_name,<<"[email protected]">>},
{partitions,[]},
{alarms,[{'[email protected]',[]},{[email protected],[]}]}]
附:
启动rabbitmqWeb界面:
[[email protected] ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
mochiweb
webmachine
rabbitmq_web_dispatch
amqp_client
rabbitmq_management_agent
rabbitmq_management
Applying plugin configuration to [email protected] started 6 plugins.
默认端口号为15672
rabbitmq官方构建方法:https://www.rabbitmq.com/clustering.html#overview-hostname-requirements
rabbit官方单节点.JPG