1. installation

yum -y install mosquitto

2. configuration

> /etc/mosquitto/mosquitto.conf
vi /etc/mosquitto/mosquitto.conf
#
listener 8083
protocol websockets
listener 1883
protocol mqtt
#
persistent_client_expiration 1d
autosave_interval 60
persistence true
persistence_file mosquitto.db
persistence_location /var/lib/mosquitto/
#
allow_anonymous false
password_file /etc/mosquitto/passwd
#
sys_interval 1
#log_dest file /var/log/mosquitto/mosquitto.log
log_dest syslog
#log_type error
#log_type warning
log_type notice
#log_type information
#log_type all
log_facility 5
log_timestamp true
log_timestamp_format %Y%m%d %H:%M:%S
mkdir -p /var/lib/mosquitto /var/log/mosquitto
chown mosquitto:mosquitto /var/lib/mosquitto/ /var/log/mosquitto/
> /etc/mosquitto/passwd
echo -en "xx\nxx\n" | mosquitto_passwd /etc/mosquitto/passwd "admin"

3. service

systemctl enable --now mosquitto.service

4. testing

mosquitto_sub -h localhost -u admin -P xx -t '#' -d
Client cid-xx sending CONNECT
Client cid-xx received CONNACK (0)
Client cid-xx sending SUBSCRIBE (Mid: 1, Topic: #, QoS: 0, Options: 0x00)
Client cid-xx received SUBACK
Subscribed (mid: 1): 0
Client cid-xx received PUBLISH (d0, q0, r1, m0, 'shellies/shellyplug-s-43F7D0/relay/0', ... (2 bytes))
on
Client cid-xx received PUBLISH (d0, q0, r1, m0, 'shellies/shellyplug-s-43F7D0/relay/0/power', ... (4 bytes))
0.00
Client cid-xx received PUBLISH (d0, q0, r1, m0, 'shellies/shellyplug-s-43F7D0/relay/0/energy', ... (1 bytes))
0
Client cid-xx received PUBLISH (d0, q0, r1, m0, 'shellies/shellyplug-s-43F7D0/temperature', ... (5 bytes))
33.89
Client cid-xx received PUBLISH (d0, q0, r1, m0, 'shellies/shellyplug-s-43F7D0/overtemperature', ... (1 bytes))
0
Client cid-xx sending PINGREQ
Client cid-xx received PINGRESP
Client cid-xx sending PINGREQ
Client cid-xx received PINGRESP

to get only the relay state from specific device:

mosquitto_sub -h localhost -u admin -P xx -t 'shellies/shellyplug-s-43F7D0/relay/0'
off
on