Install Mosquitto MQTT Broker
less than a minute
Tested Versions
MyController tested on Mosquitto 1.6.9Mosquitto broker can be installed in different way. Here we are focusing to setup it on docker and Mosquitto 1.6.9 version.
To install Mosquitto broker on your host system follow this guide
Note
Assuming that you are running all the commands as aroot
user.If you are running from non-root user, you should include
sudo
in the beginning of the commands.
mosquitto.conf
Detailed information is on Mosquitto Website
# create mosquitto.conf
mkdir -p /opt/apps/mosquitto
cd /opt/apps/mosquitto
cat << EOF > mosquitto.conf
allow_anonymous true
persistence false
persistence_location /mosquitto/data/
EOF
Install
Variable $PWD
$PWD
is a Print Working Directory
.
mkdir -p /opt/apps/mosquitto
cd /opt/apps/mosquitto
docker run -d --name mc_mosquitto \
--publish 1883:1883 \
--publish 9001:9001 \
--volume $PWD/mosquitto.conf:/mosquitto/config/mosquitto.conf \
--restart unless-stopped \
eclipse-mosquitto:1.6.9
To see the logs
- Prints all available logs
docker logs mc_mosquitto
- Prints and tails the logs, to get exit do
Ctrl+C
docker logs --follow mc_mosquitto
Restart
docker restart mc_mosquitto
Uninstall
docker stop mc_mosquitto
docker rm mc_mosquitto
Last modified June 14, 2021: update installation guide (2fd41a2)