The mosquitto service is used in the project. Due to the small amount of concurrency, it is not clustered, and only a backup service is made.
By the way, I also studied a simple cluster deployment.
Prepare 2 servers to install the mosquitto service, and select one to be the main server. All configuration of the cluster only needs to be configured on the master server.
192.168.1.100 (main)
192.168.1.101 (slave)
Enter the installation directory, modify the config.mk file WITH_BRIDGE:=yes and remove the # in front of it
Modify the mosquitto.conf file and add the following configuration under the Bridges block
connection server1 //link name
address 192.168.1.101:1883 //Slave server address
topic print/# both 2 ser/ my/ //topic topic;both server quality;ser/local prefix;my/remote prefix;
bridge_protocol_version mqttv311 //protocol
notifications true //Whether to publish bridge status information
cleansession true //whether to clear the message in the remote server when the bridge is disconnected
try_private true
start_type automatic //Bridge mode (automatic, lazy, once)
After the above configuration is complete, the two clusters are configured. If you want multiple clusters, you only need to add the following configuration.
connection server1 //link name
address 192.168.1.102:1883 //Slave server address
topic print/# both 2 ser/ my/ //topic topic;both server quality;ser/local prefix;my/remote prefix;
Post topic my/print/XXX
Subscribe to topic ser/print/#