搭建 MQTT 服务器 emqx

安装

# 下载页:https://www.emqx.io/cn/downloads#broker
# 选择 EMQ X Broker,以及对应的版本
cd /usr/local/src
# Debian
wget https://packages.emqx.io/emqx-ce/v3.2.6/emqx-debian8-v3.2.6.zip
# CentOS
wget https://packages.emqx.io/emqx-ce/v3.2.7/emqx-centos7-v3.2.6.zip

# 解压
unzip emqx-debian8-v3.2.6.zip

# 移动目录
mv emqx /usr/local/emqx

# 启动
/usr/local/emqx/bin/emqx start

# 查看状态
/usr/local/emqx/bin/emqx_ctl status
# 返回
Node '[email protected]' is started
emqx 3.2.6 is running

# 可以使用 web 控制台访问,用户名为 admin,密码为 public
http://localhost:18083/

开启用户名权限验证

# 首先关闭 emqx 匿名认证
vim /usr/local/emqx/etc/emqx.conf
# 设置如下
allow_anonymous = false

# 加载用户名认证插件
/usr/local/emqx/bin/emqx_ctl plugins load emqx_auth_username
 
# 添加用户
/usr/local/emqx/bin/emqx_ctl users add <Username> <Password>

配置 MySQL 身份认证

vim /usr/local/emqx/etc/plugins/emqx_auth_mysql.conf
# 配置以下内容
auth.mysql.server = 127.0.0.1:3306
auth.mysql.username = root
auth.mysql.password = asdf
auth.mysql.database = xxx
auth.mysql.password_hash = plain

# 重启 加载插件
/usr/local/emqx/bin/emqx_ctl plugins load emqx_auth_mysql

你可能感兴趣的:(Linux)