手动配置管理集群
假设部署两台服务器 s1.emqx.io, s2.emqx.io 上部署集群:
节点名 | 主机名(FQDN) | IP 地址 |
---|---|---|
emqx@s1.emqx.io 或 emqx@192.168.0.10 | s1.emqx.io | 192.168.0.10 |
emqx@s2.emqx.io 或 emqx@192.168.0.20 | s2.emqx.io | 192.168.0.20 |
Warning
节点名格式: Name@Host , Host 必须是 IP 地址或 FQDN(主机名.域名)
emqx@s1.emqx.io 节点设置
emqx/etc/emqx.conf:
node.name = emqx@s1.emqx.io
或
node.name = emqx@192.168.0.10
也可通过环境变量:
export EMQX_NODE_NAME=emqx@s1.emqx.io && ./bin/emqx start
Warning
节点启动加入集群后,节点名称不能变更。
emqx@s2.emqx.io 节点设置
emqx/etc/emqx.conf:
node.name = emqx@s2.emqx.io
或
node.name = emqx@192.168.0.20
节点加入集群
启动两台节点后,emqx@s2.emqx.io 上执行:
$ ./bin/emqx_ctl cluster join emqx@s1.emqx.io
Join the cluster successfully.
Cluster status: [{running_nodes,['emqx@s1.emqx.io','emqx@s2.emqx.io']}]
或,emqx@s1.emqx.io 上执行:
$ ./bin/emqx_ctl cluster join emqx@s2.emqx.io
Join the cluster successfully.
Cluster status: [{running_nodes,['emqx@s1.emqx.io','emqx@s2.emqx.io']}]
任意节点上查询集群状态:
$ ./bin/emqx_ctl cluster status
Cluster status: [{running_nodes,['emqx@s1.emqx.io','emqx@s2.emqx.io']}]
节点退出集群
节点退出集群,两种方式:
- leave: 本节点退出集群
- force-leave: 从集群删除其他节点
emqx@s2.emqx.io 主动退出集群:
$ ./bin/emqx_ctl cluster leave
或 emqx@s1.emqx.io 节点上,从集群删除 emqx@s2.emqx.io 节点:
$ ./bin/emqx_ctl cluster force-leave emqx@s2.emqx.io