vernemq Mqtt 安装
创建时间:2024-08-17 05:58:55
支持分布式mqtt
yum groupinstall "Development Tools"
yum install epel-release
yum install -y glibc-devel glibc-headers gcc-c++ ncurses-devel openssl-devel autoconf mesa-libGL-devel mesa-libGLU-devel gtk3-devel mesa-libGL-devel mesa-libGLU-devel libX11-devel libXpm-devel libXft-devel freetype-devel fontconfig-devel expat-devel unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel
install:
https://github.com/vernemq/vernemq/releases
下载rpm包,rpm -i 安装
vernemq-2.0.1.rocky8.x86_64.rpm 用于centos8
修改配置
vi /etc/vernemq/vernemq.conf
##同意协议
accept_eula = yes
##数据库做权限认证
plugins.vmq_diversity = on
vmq_diversity.auth_mysql.enabled = on
vmq_diversity.mysql.host = 127.0.0.1
vmq_diversity.mysql.port = 3306
vmq_diversity.mysql.user = vernemq
vmq_diversity.mysql.password = vernemq
vmq_diversity.mysql.database = vernemq_db
vmq_diversity.mysql.password_hash_method = password
plugins.vmq_passwd = off
plugins.vmq_acl = off
allow_anonymous = off
##打开webhook
plugins.vmq_webhooks = on
启动
systemctl start vernemq
数据库:
https://docs.vernemq.com/configuring-vernemq/db-auth#creating-the-mysql-tables
```sql
CREATE TABLE vmq_auth_acl
(
mountpoint VARCHAR(10) NOT NULL,
client_id VARCHAR(128) NOT NULL,
username VARCHAR(128) NOT NULL,
PASSWORD VARCHAR(128),
publish_acl TEXT,
subscribe_acl TEXT,
CONSTRAINT vmq_auth_acl_primary_key PRIMARY KEY (mountpoint, client_id, username)
);
INSERT INTO vmq_auth_acl
(mountpoint, client_id, username,
password, publish_acl, subscribe_acl)
VALUES
('', 'test-client', 'test-user', PASSWORD('123'),
'[{"pattern":"a/b/c"},{"pattern":"c/b/#"}]',
'[{"pattern":"a/b/c"},{"pattern":"c/b/#"}]');
```
vmq-admin plugin enable --name=vmq_acl