It is also working well, when you install mosquitto from the AUR. Just install Yaourt and install mosquitto.
yaourt -S mosquitto.
For my bachelor thesis I needed a MQTT broker to realize a lightweight communication between my Raspberry Pi, my Android phone and a Java component.
Because the Raspberry Pi was always running during my testing I chose to install it there. Here are the steps.
Download, unzip, make and install the actual version. For me it was Version # 1.2.3.
wget http://mosquitto.org/files/source/mosquitto-1.2.3.tar.gz tar xzf mosquitto-1.2.3.tar.gz cd mosquitto-1.2.3 make sudo make install
Running mosquitto in it's default configuration results in this output
[cygairko@archpi ~]$ mosquitto 1393424318: mosquitto version 1.2.3 (build date 2014-02-25 17:29:26-0700) starting 1393424318: Using default config. 1393424318: Opening ipv4 listen socket on port 1883. 1393424318: Opening ipv6 listen socket on port 1883. 1393424318: Warning: Address family not supported by protocol
When you enable IPv6 the last line will disappear and your broker is also listening to IPv6 requests.
Configuration and startup script
To configure mosquitto we need to have a config file
sudo cp /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf
Adjust some parameters in
pid_file /var/run/mosquitto.pid user user_name
Now we want our mosquitto broker to start at boot. For this Arch Linux has systemd.
Create a .service file
/etc/systemd/system/mosquitto.service with this content
[Unit] Description=Mosquitto MQTT Broker daemon ConditionPathExists=/etc/mosquitto/mosquitto.conf Requires=network.target [Service] Type=simple ExecStartPre=/usr/bin/rm -f /var/run/mosquitto.pid ExecStart=/usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d ExecReload=/bin/kill -HUP $MAINPID PIDFile=/run/mosquitto.pid Restart=on-failure [Install] WantedBy=multi-user.target</code></pre> Enable and start <pre><code>sudo systemctl enable mosquitto sudo systemctl start mosquitto systemctl status mosquitto
The last command will print an green
active (running) if mosquitto started successfully.
Mosquitto is now running and usable directly after boot.