EMQ集群配置

本实例采用“静态节点列表自动集群”
官方文档: http://www.emqtt.com/docs/v2/cluster.html

两台云端服务器:
A服务器:39.10.20.14
B服务器:10.14.64.45

修改A服务器配置文件

## Cluster discovery strategy: manual | static | mcast | dns | etcd | k8s
cluster.discovery = static

## Cluster Autoheal: on | off
cluster.autoheal = on

## Clean down node of the cluster
cluster.autoclean = 5m

##--------------------------------------------------------------------
## Cluster with static node list

## cluster.static.seeds = emq1@127.0.0.1,emq2@127.0.0.1
cluster.static.seeds = emq@39.10.20.14,emq@10.14.64.45

将node.name需要修改成本机的IP地址,默认的是127.0.0.1

## node.name = emq@127.0.0.1
node.name = emq@39.10.20.14

修改B服务器配置文件

## node.name = emq@127.0.0.1
node.name = emq@10.14.64.45

开启4369端口
4369由epmd端口映射服务使用,TCP端口段用于节点间建立连接与通信

在/etc/sysconfig/iptables配置文件中添加

-A INPUT -p tcp -m tcp --dport 4369 -j ACCEPT

防火墙设置后,EMQ需要配置相同的端口段,emqttd/etc/emq.conf 文件:

## Distributed node port range
node.dist_listen_min = 6369
node.dist_listen_max = 7369

重启两台服务器的EMQTT服务,在任意节点上查询集群状态:

[root@home ~]# ./sbin/emqttd_ctl cluster status
Cluster status: [{running_nodes,['emq@39.10.20.14','emq@10.14.64.45']}]

总结
注意4369端口号对外开启,node.name的名称需要修改与实际的IP地址,默认为127.0.0.1

这里写图片描述

手动加入方法

#添加集群主机
[root@home ~]# ./sbin/emqttd_ctl cluster join emq@39.10.20.14

#删除集群主机
[root@home ~]# ./sbin/emqttd_ctl cluster force-leave emq@39.10.20.14
Remove the node from cluster successfully.
Cluster status: [{running_nodes,['emq@10.14.64.45']}]

#说明
[root@home ~]# ./sbin/emqttd_ctl cluster remove emq@39.108.208.149
cluster join <Node>                             # Join the cluster
cluster leave                                   # Leave the cluster
cluster force-leave <Node>                      # Force the node leave from cluster
cluster status                                  # Cluster status
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值