Centos7 mqtt cluster installation

Prepare the database

create database mqtt;
use mqtt;

SET FOREIGN_KEY_CHECKS=0;-------------------------------- Table structure for mqtt_acl
------------------------------
DROP TABLE IF EXISTS `mqtt_acl`;
CREATE TABLE `mqtt_acl`(`id`int(11) unsigned NOT NULL AUTO_INCREMENT,`allow`int(1) DEFAULT NULL COMMENT '0: deny, 1: allow',`ipaddr`varchar(60) DEFAULT NULL COMMENT 'IpAddress',`username`varchar(100) DEFAULT NULL COMMENT 'Username',`clientid`varchar(100) DEFAULT NULL COMMENT 'ClientId',`access`int(2) NOT NULL COMMENT '1: subscribe, 2: publish, 3: pubsub',`topic`varchar(100) NOT NULL DEFAULT '' COMMENT 'Topic Filter',
 PRIMARY KEY(`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;-------------------------------- Table structure for mqtt_user
------------------------------
DROP TABLE IF EXISTS `mqtt_user`;
CREATE TABLE `mqtt_user`(`id`int(11) unsigned NOT NULL AUTO_INCREMENT,`username`varchar(100) DEFAULT NULL,`password` blob,`salt` blob,`is_superuser`tinyint(1) DEFAULT '0',`created` datetime DEFAULT NULL,
 PRIMARY KEY(`id`),
 UNIQUE KEY `mqtt_username`(`username`)) ENGINE=InnoDB AUTO_INCREMENT=643 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;All 3 nodes perform the following steps to install

Installation dependencies:
yum install lksctp-tools -y

Download emqtt:
https://www.emqx.io/downloads/broker/v2.2.0/emqttd-centos7-v2.2.0.el7.centos.x86_64.rpm

# installation
rpm -ivh --force emqttd-centos7-v2.2.0.el7.centos.x86_64.rpm

# Replace 127.0.0.1 is the real ip of the current node
sed -i 's$node.name = [email protected]$node.name = [email protected]$g'/etc/emqttd/emq.conf

### Modify the mysql plug-in configuration (pay attention to replace the database connection information)
sed -i 's$auth.mysql.server = 127.0.0.1:3306$auth.mysql.server = 192.168.6.125:23306$'/etc/emqttd/plugins/emq_auth_mysql.conf
sed -i 's$auth.mysql.pool = 8$auth.mysql.pool = 50$g'/etc/emqttd/plugins/emq_auth_mysql.conf
sed -i 's$## auth.mysql.username =$auth.mysql.username=root$g'/etc/emqttd/plugins/emq_auth_mysql.conf
sed -i 's$## auth.mysql.password =$auth.mysql.password=xiaoWEI0923!$g'/etc/emqttd/plugins/emq_auth_mysql.conf
sed -i 's$select password from mqtt_user$select password,salt from mqtt_user$g'/etc/emqttd/plugins/emq_auth_mysql.conf
sed -i 's$auth.mysql.password_hash = sha256$auth.mysql.password_hash = md5 salt$g'/etc/emqttd/plugins/emq_auth_mysql.conf

### Start and confirm
# Set emqtt to self-start
systemctl enable emqttd.service
# Start emqtt
systemctl start emqttd

# an examination
systemctl status emqttd or netstat-tlnp |grep 1883, if you print the following content, it proves that the service is started and 1883 has been monitored
tcp        00127.0.0.1:118830.0.0.0:*               LISTEN      21579/beam.smp      
tcp        000.0.0.0:18830.0.0.0:*               LISTEN      21579/beam.smp 

# Load mysql authentication
emqttd_ctl plugins load emq_auth_mysql

# Restart emqtt
systemctl restart emqttd

Browser open http://Current deployment node ip:18083/#/plugins
Account: admin
Password: public
Confirm emq_auth_The mysql plugin is in the running state
Create a cluster

Assuming that the servers with mqtt installed above are node1, node2, and node3 respectively, then:
Execute on node2: emqttd_ctl cluster join emqttd@ip of node1
Execute on node3: emqttd_ctl cluster join emqttd@node2 ip

# Confirm that the cluster is created successfully
emqttd_ctl cluster status
running_All node ips are included in nodes, as follows:
Cluster status:[{running_nodes,['[email protected]','[email protected]','[email protected]']}]

Recovery

If the cluster fails due to endpoints or other reasons, stop the nodes that are not in the cluster, delete related files and join the cluster again

systemctl stop emqttd
rm -Rf /var/lib/emqttd/mnesia/*
systemctl start emqttd
emqttd_ctl cluster join emqttd@Node ip

Recommended Posts

Centos7 mqtt cluster installation
Glusterfs cluster installation on Centos7
Redis cluster installation under CentOS
CentOS 7 Galera Cluster installation guide
Redis cluster installation under CentOS
2019-07-09 CentOS7 installation
centos7_1708 installation
Centos7 hadoop cluster installation and configuration
Centos5 installation guide
Python - centos6 installation
Docker installation (CentOS7 installation)
CentOS7 docker installation
(1) Centos7 installation to build a cluster environment
CentOS online installation RabbitMQ3.7
CentOS7.3.1611 deploys k8s1.5.2 cluster
Centos6.9 build rabbitmq 3.6.8 cluster
CentOS6 install couchdb2 cluster
lamp (centos7) installation lamp environment
CentOS 6.8 deploy zookeeper cluster
Centos7 build Kubernetes cluster
Graphical installation of CentOS8
Mysql8.0.15 installation configuration (centos7)
Linux notes (1): CentOS-7 installation
Redis3 installation under Centos7
CentOS cluster related issues
Centos7 deploys Kubernetes cluster
CentOS online installation RabbitMQ3.7
CentOS7 deploys k8s cluster
Docker CentOS installation method
Linux CentOS 7 installation tutorial
Centos7 docker installation details
Discourse CentOS 8 new installation manual
Centos 7 mini installation process record
Centos mysql installation and configuration
Centos7.4 deployment configuration Elasticsearch5.6 cluster
CentOS7 install rabbitmq cluster (binary)
Centos7.2/7.3 cluster install Kubernetes 1.8.4 + Dashboard
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
Hyper-V + CentOS7 installation video tutorial
centos7 kvm installation and use
Centos7 silent installation of Oracle11g
CentOS 6.8 virtual machine installation details
CentOS7 postgresql installation and use
CentOS environment installation of Docker
CentOs7.3 build SolrCloud cluster service
Centos7 install k8s cluster 1.15.0 version
Centos7 installation tomcat process introduction
Centos7.4 environment installation lamp-php7.0 tutorial
Docker EE installation on centos7
Discourse CentOS 8 new installation manual
CentOS8 Linux 8.0.1905 installation process (illustration)
Centos7 elk7.1.1 installation and use
Analysis of Hyper-V installation CentOS 8 problem
Centos iso image file installation tutorial
CentOS 8 (2)
Centos7 installation is actually very simple
Centos7 installation of Dameng database tutorial
CentOS 8 installation of MariaDB detailed tutorial