在centos7上构建rabbitmq单节点集群 2019-05-13

rabbitMQ,MQ全称为Message Queue,消息列队是一种应用程序对应#用程序的通信方法。应用程序通过读写出入的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们。

在centos7上构建rabbitmq单节点集群
centos7+网络环境

安装rabbitmq-server:

添加任意一个openstack的镜像源(yum -y install centos-release-openstack-pike.x86_64)
[root@centos7 ~]# yum -y install rabbitmq-server

启动:

[root@centos7 ~]# systemctl start rabbitmq-server
[root@centos7 ~]# 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

配置管理员用户:

[root@centos7 ~]# rabbitmqctl add_user admin admin
Creating user "admin" ...
[root@centos7 ~]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...
[root@centos7 ~]# rabbitmqctl set_permissions admin ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "/" ...

添加rabbit-2节点:

[root@centos7 ~]# RABBITMQ_NODE_PORT=5673 RABBITMQ_NODENAME=rabbit-2 rabbitmq-server -detached(rabbitm默认端口号为5672)
Warning: PID file not written; -detached was passed.(警告好像没什么用)
[root@centos7 ~]# rabbitmqctl -n rabbit-2 stop_app
Stopping node 'rabbit-2@centos7' ...
[root@centos7 ~]# rabbitmqctl -n rabbit-2 join_cluster rabbit@`hostname -s`
Clustering node 'rabbit-2@centos7' with rabbit@centos7 ...
[root@centos7 ~]# rabbitmqctl -n rabbit-2 start_app
Starting node 'rabbit-2@centos7' ...

查询集群状态:

[root@centos7 ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@centos7 ...
[{nodes,[{disc,['rabbit-2@centos7',rabbit@centos7]}]},
 {running_nodes,['rabbit-2@centos7',rabbit@centos7]},
 {cluster_name,<<"rabbit@centos7">>},
 {partitions,[]},
 {alarms,[{'rabbit-2@centos7',[]},{rabbit@centos7,[]}]}]

附:
启动rabbitmqWeb界面:

[root@centos7 ~]# 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 rabbit@centos7... started 6 plugins.
默认端口号为15672

点这里 查看rabbitmq集群官方构建方法

rabbit官方单节点.JPG

你可能感兴趣的:(在centos7上构建rabbitmq单节点集群 2019-05-13)