dashboard {
listeners.http {
bind = 18083
}
}
#### 189
Cluster discovery via static seed nodes
node {
name = “emqx@192.168.50.189”
cookie = “3882cbd0254f9f398a1ca785703b46668f61ad0928b70fc0ee850f8a431fb86b”
data_dir = “data”
}
cluster {
## Human-friendly name of the EMQX cluster.
name = emqxcl
## Service discovery method for the cluster nodes
discovery_strategy = static
## If true, the node will try to heal network partitions automatically
autoheal = true
## List EMQX node names in the static cluster
static.seeds = ["emqx@192.168.50.187", "emqx@192.168.50.189"]
}
dashboard {
listeners.http {
bind = 18083
}
}
### cookie生成
openssl rand -hex 32
* **其中node中的name值的IP和hostname保持一直**
* **node中的cookie值每台机器必须保持一直**
### 修改hostname方法
hostnamectl set-hostname 192.168.50.189
### 创建docker的emqx
chown -R 1000:1000 /usr/docker/emqx
chmod -R 755 /usr/docker/emqx
docker run -dit --name emqx
–network host
-p 18083:18083
-p 1883:1883
-p 8083:8083
-p 8084:8084
-v /usr/docker/emqx/data:/opt/emqx/data
-v /usr/docker/emqx/etc:/opt/emqx/etc
-v /usr/docker/emqx/log:/opt/emqx/log
emqx/emqx:latest
### 重点
**要使两个节点通信 必须开放5370 4370 端口**
开放端口
firewall-cmd --zone=public --add-port=5370/tcp --permanent
#重启防火墙
systemctl restart firewalld
以下端口也必须全都开放
![](https://img-blog.csdnimg.cn/direct/015f74e6b3ce470d91b26119efc0de90.png)
到这里基本就结束了
![](https://img-blog.csdnimg.cn/direct/e725e681a76541fb9d9637166c045185.png)
### 集群恢复
直接用docker start emqx
如果通过 dokcer logs -f emqx 发现启动失败
删除 emqx/data/mnesia/\* 下的文件 再次启动
### 常用命令
#### 集群状态查看
docker exec -it emqx emqx_ctl cluster status
#### 节点运行状态查看
docker exec -it emqx emqx_ctl status
## nginx代理配置
**新增和http同级配置**
stream {
upstream emqx_servers {
zone tcp_servers 64k;
hash $remote_addr;
server 192.168.50.187:1883 weight=1 max_fails=3 fail_timeout=30s;
server 192.168.50.189:1883 weight=1 max_fails=3 fail_timeout=30s;
}
server {
listen 1883 so_keepalive=on;
proxy_pass emqx_servers;
proxy_buffer_size 8k;
proxy_connect_timeout 60s;
proxy_timeout 300s;
tcp_nodelay on;
}
}
### 注意
如果报 **nginx: [emerg] unknown directive "stream" in xxxxxxxx**
需要重新编译 nginx并安装
进入 Nginx 源代码目录。
## 最后
**自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**
**深知大多数Java工程师,想要提升技能,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助。**
**因此收集整理了一份《2024年嵌入式&物联网开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**
![img](https://img-blog.csdnimg.cn/img_convert/c86477c57ec12011f00203e706624ad7.png)
![img](https://img-blog.csdnimg.cn/img_convert/06107aed7073c898f198aeee292de285.jpeg)
![img](https://img-blog.csdnimg.cn/img_convert/79cd0ce75eb65cd5e9883561d96f13db.png)
![img](https://img-blog.csdnimg.cn/img_convert/1cf27caac696db34da4fc88517f34ef8.png)
![img](https://img-blog.csdnimg.cn/img_convert/6ba07b52c7ccb8ebe4adbb15c8b0333f.png)
![img](https://img-blog.csdnimg.cn/img_convert/a7db9120afdc3408e3c5c3a3b975350e.png)
![](https://img-blog.csdnimg.cn/img_convert/05e58e99bb3b31aaec05fc924130de2e.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上嵌入式&物联网开发知识点,真正体系化!**
[**如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!**](https://bbs.csdn.net/topics/618654289)
**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**!!
入学习提升的进阶课程,基本涵盖了95%以上嵌入式&物联网开发知识点,真正体系化!**
[**如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!**](https://bbs.csdn.net/topics/618654289)
**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**!!