Install MQTT Broker (Mosquitto) on centos 8

November 25, 2022 ・0 comments

 In this article we will see how to Install MQTT Broker (Mosquitto) on centos 8.

We will be using the Eclipse-Mosquitto for MQTT configuration. 

Overview of Steps:

Install the Mosquitto

Configure The Mosquitto

Test the Server

Detailed Steps:

Step 1. Install the Mosquitto

[root@localhost ~]# sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y

[root@localhost ~]# sudo yum -y install mosquitto

[root@localhost ~]# sudo systemctl start mosquitto

[root@localhost ~]# sudo systemctl enable mosquitto

Step 2. Configure The Mosquitto with Auth, let's choose username/password auth.:

[root@localhost ~]# sudo mosquitto_passwd -c /etc/mosquitto/passwd username

then Choose the password

Step 3. Adding Port: Run the following command to allow port in firewall:

[root@localhost ~]# sudo firewall-cmd --permanent --zone=public --add-port=1883/tcp

[root@localhost ~]# sudo firewall-cmd --reload

Step 4. Test The Server

[root@localhost ~]# mosquitto_sub -t demo/one -h 127.0.0.1 -u username -P password -p 1883

[root@localhost ~]# mosquitto_pub -t demo/one -h 127.0.0.1 -u username -P password -p 1883 -m '{"message": 1}'



Post a Comment

If you can't commemt, try using Chrome instead.