Professional Documents
Culture Documents
Overview
Building an elastic high Related Links
HiveMQ Product Info
availability MQTT broker cluster Get HiveMQ
on AWS S3 Cluster Discovery Extension
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 1/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
UPDATE
This post has been updated for HiveMQ 4 and the use of
AWS Network Load Balancer has been added.
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 2/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
As Amazon Webservice is amongst the best known and most used cloud
platforms, we want to illustrate the setup of a HiveMQ cluster on AWS in
this post. Note that similar concepts as displayed in this step by step
guide for Running an elastic HiveMQ cluster on AWS apply to other cloud
platforms such as Microsoft Azure or Google Cloud Platform.
The first step is creating a security group that allows inbound traffic to
the listeners we are going to configure for MQTT communication. It is
also vital to have SSH access on the instances. After you created the
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 3/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
security group you need to edit the group and add an additional rule for
internal communication between the cluster nodes (meaning the source
is the security group itself) on all TCP ports.
To create and edit security groups go to the EC2 console - NETWORK &
SECURITY - Security Groups
Inbound traffic
Outbound traffic
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 4/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
HiveMQ on AWS
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 5/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
4. Create 2 instances.
5. Assign the newly created S3 Full Access role to the instances.
6. Go to “Configure Security Group”.
7. Select the Security Group that we just created.
8. Launch the instances.
This action will automatically spawn two separate EC2 instances that run
HiveMQ as a service.
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 6/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
Make sure to remember the bucket name. You can use the default
configuration.
1
ssh -i <your-deployment-key> ec2-user@<instance-ip-address>
1
sudo su
1
wget https://www.hivemq.com/releases/extensions/hivemq-s3-c
1
unzip hivemq-s3-cluster-discovery-extension-4.0.1.zip
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 7/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
1
vi hivemq-s3-cluster-discovery-extension/hivemq-s3-cluster-
1
##########################################################
2
# S3 Bucket
3
##########################################################
4
5
#
6
# Region for the S3 bucket used by hivemq
7
# see http://docs.aws.amazon.com/general/latest/gr/rande.h
8
# example: us-west-2
9
#
10
s3-bucket-region:<your-region>
11
12
#
13
# Name of the bucket used by HiveMQ
14
#
15
s3-bucket-name:<your-bucket-name>
1
chown -R hivmq:hivemq hivemq-s3-cluster-discovery-extension
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 8/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
1
mv hivemq-s3-cluster-discovery-extension/ /opt/hivemq/exten
1
<?xml version="1.0"?>
2
<hivemq>
4
<listeners>
5
<tcp-listener>
6
<port>1883</port>
7
<bind-address>0.0.0.0</bind-address>
8
</tcp-listener>
9
</listeners>
10
11
<cluster>
12
<enabled>true</enabled>
13
<transport>
14
<tcp>
15
<bind-address>IP_ADDRESS</bind-address>
16
<bind-port>7800</bind-port>
17
</tcp>
18
</transport>
19
20
<discovery>
21
<extension/>
22
</discovery>
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndica… 9/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
23
</cluster>
24
25
<anonymous-usage-statistics>
26
<enabled>true</enabled>
27
</anonymous-usage-statistics>
28
29
<control-center>
30
<listeners>
31
<http>
32
<port>8080</port>
33
<bind-address>0.0.0.0</bind-address>
34
</http>
35
</listeners>
36
</control-center>
37
</hivemq>
1
/etc/init.d/hivemq restart
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 10/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
We are now able to take advantage of rapid elasticity. Scaling the HiveMQ
cluster up or down by adding or removing EC2 instances without the
need of administrative intervention is now possible. One last step on our
way to a true high availability including a load balancer to our setup. This
way our HiveMQ broker cluster can act as a single logical broker nodes to
MQTT clients. An MQTT clients simply needs to know the load balancers
URL to connect, publish, and subscribe. The actual number of HiveMQ
broker nodes active in the cluster are irrelevant to the MQTT client.
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 11/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
8. Click “Create”
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 12/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
12. Save
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 13/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
17. Configure your VPC and availability zones according to your needs.
HINT: It is best practise to choose all availability zones.
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 14/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 15/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
20. Select our newly created target group and go to “Register Targets”
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 16/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
That’s it! Once the Load Balancer finished provisioning, we can connect to
our HiveMQ Broker Node cluster using the Load Balancer’s DNS name.
Who we are
Contact Florian
Submit
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 18/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
By clicking the subscribe button, you give your consent to the use of your data according to our Privacy Policy.You can
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 19/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
HiveMQ Sign up Resources Overview Automotive MQTT Client Tools About us Download HiveMQ
Editions Integration Documentation MQTT 5 Essentials Manufacturing Get started with News AWS
Marketplace HiveMQ Cloud MQTT Sparkplug Azure Solution Publish and Partners
Extension Broker
Kubernetes FAQ
Operator
Open Source
Webinars
Newsletter
HiveMQ GmbH
Ergoldingerstr. 2a
Follow us on
84030 Landshut
Bavaria, Germany
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 20/21
08/06/2022, 12:16 Building an elastic high availability MQTT broker cluster on AWS
https://www.hivemq.com/blog/running-hivemq-cluster-aws-auto-discovery/?utm_source=website&utm_medium=AWS_MQTTCluster_blog_microsite&utm_campaign=infoq+content+syndic… 21/21