当前位置:网站首页>Quickly deploy mqtt clusters on AWS using terraform
Quickly deploy mqtt clusters on AWS using terraform
2022-07-25 16:14:00 【EMQX】
Terraform By HashiCorp An infrastructure launched is code (IaC) Tools , It includes low-level components such as computing instances 、 Storage and networking , And high-level components such as DNS、LBS etc. . Users can use Terraform Security 、 Build... Efficiently 、 Change and update infrastructure .
In the traditional private cloud or public cloud deployment , Users need to deploy the infrastructure first ( virtual machine 、 Network and storage, etc ), Before deployment MQTT colony . And if you use Terraform, Users can complete these two tasks at the same time . Besides , The same set of tools can be deployed on different platforms , Repeatable by template 、 Define and configure resources in a predictable way , It can greatly reduce errors caused by human factors .
This article will focus on the distributed Internet of things MQTT Message server EMQX For example , use AWS As a public cloud platform , How to use Terraform Quickly deploy a highly available MQTT colony .
Terraform brief introduction
As a tool to manage the service life cycle ,Terraform You can use status files to record and track all environmental changes . The default state is stored locally , adopt HCL perhaps JSON To define ,HCL yes HashiCorp The template language provided .

- Coding: use HCL To write infrastructure code . Blocks can be defined , Parameters and expressions .
- Plan: function Terraform Plan To check whether the implementation plan meets expectations .
- Apply: function Terraform Apply To build the infrastructure that users need
Installation and preparation
install Terraform
With Mac For example , adopt brew install .
brew tap hashicorp/tap 2brew install hashicorp/tap/terraform
Verify the installation
terraform -help
Specific reference Official documents
install AWS Cli
With Mac For example
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
Verify the installation
which aws
aws --version
Reference resources Official documents
Add users
Get into AWS Of IAM menu , Click on “ Add users ”

In adding users , Remember to check “ Access key ”

choice “ Create group ”

Add “AdministratorAccess” Strategy

Click on “ Create user ”, Finish adding users

obtain Access Key and Secret

To configure AWS Of Access Key
Get the one created above access key and secret, Set the environment variable
AWS_ACCESS_KEY_ID: ${anaccesskey}
AWS_SECRET_ACCESS_KEY: ${asecretkey}
Use Terraform stay AWS Upper Department EMQX colony
download AWS Deployment scripts
git clone "https://github.com/emqx/terraform-emqx-emqx-aws.git"
Deployment script description :
- Temporarily not supported EMQX 5.X
- AWS CLI:aws-cli/2.2.41 Python/3.8.8 Darwin/21.4.0 exe/x86_64 prompt/off
Script configuration file path :
- Stand alone deployment Profile :services/emqx/terraform.tfvars
- Cluster deployment profile :services/emqx_cluster/terraform.tfvars
The deployment script uses the following configuration by default , Readers can modify it according to the actual situation terraform.tfvars file :
- Default EMQX edition : Enterprise Edition 4.4.3
If you want to deploy the open source version , Need modification
emqx_packagevalue , For example, deploy the open source version 4.4.3:https://www.emqx.com/en/downloads/broker/v4.4.3/emqx-4.4.3-otp23.3.4.9-3-ubuntu20.04-amd64.zip
- Default AWS Region by us-east-1
- Default cluster node :3 platform
t3.small
Deploy EMQX colony
Users can modify terraform.tfvars file , To change the default configuration
cd services/emqx_cluster
terraform init
terraform plan
terraform apply -auto-approve
Wait a few minutes , The results of the deployment are as follows

verification EMQX Cluster deployment results
After the cluster deployment is successful , We can simply test whether the cluster is running normally . First get the cluster's IP Address , And access through the following information EMQX Enterprise Edition Dashboard.
http://tf-elb-nlb-5bff6976b15586dd.elb.us-east-1.amazonaws.com:18083user name :
adminpassword :
public

We can see from the above figure that we have deployed 3 Nodes , You can pass Websocket Tools for simple verification :
Select tools in the left menu bar →WebSocket

Click on “ Connect ”

Subscribe to topics

Click publish , Normally, you can see the following results

Conclusion
thus , We've done it through Terraform stay AWS On rapid deployment MQTT The whole process of the cluster . Readers can modify the deployment script according to the actual situation , Create a EMQX colony , With the help of EMQX Data connection in the Internet of things 、 Advantages in mobile and processing, build a competitive Internet of things platform and Application .
Reference resources :
Code warehouse :https://github.com/emqx/terraform-emqx-emqx-aws
EMQX Terraform Module official documentation :https://docs.emqx.com/zh/emqx-terraform/latest
Copyright notice : This paper is about EMQ original , Reprint please indicate the source .
Link to the original text :https://www.emqx.com/zh/blog/deploy-mqtt-cluster-on-aws-using-terraform
边栏推荐
- Is the win11 dynamic tile gone? Method of restoring dynamic tile in Win 11
- 百奥赛图与LiberoThera共同开发全人GPCR抗体药物取得里程碑式进展
- [server data recovery] data recovery cases of raid information loss caused by unexpected power failure of HP EVA server storage
- MySQL页锁
- 论文笔记:Highly accurate protein structure prediction with AlphaFold (AlphaFold 2 & appendix)
- [wechat applet] detailed explanation of applet host environment
- JWT diagram
- leetcode:528. 按权重随机选择【普通随机失效 + 要用前缀和二分】
- Golang review summary
- MySQL explicit lock
猜你喜欢

tkinter模块高级操作(一)—— 透明按钮、透明文本框、自定义按钮及自定义文本框

Sum arrays with recursion

哪个led显示屏厂家更好

How Google cloud disk is associated with Google colab

Introduction to redis

面试突击:为什么 TCP 需要 3 次握手?

JWT diagram

开发者如何为React Native选择合适的数据库

Save the image with gaussdb (for redis), and the recommended business can easily reduce the cost by 60%
![[server data recovery] data recovery cases of raid information loss caused by unexpected power failure of HP EVA server storage](/img/90/51d86111b918eb60761818110cdec4.jpg)
[server data recovery] data recovery cases of raid information loss caused by unexpected power failure of HP EVA server storage
随机推荐
Permission management - role assignment menu
MySQL 悲观锁
leetcode:528. 按权重随机选择【普通随机失效 + 要用前缀和二分】
使用 Terraform 在 AWS 上快速部署 MQTT 集群
MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
Which led display manufacturer is better
Sum arrays with recursion
30 lines write the concurrency tool class yourself (semaphore, cyclicbarrier, countdownlatch)
论文笔记:Highly accurate protein structure prediction with AlphaFold (AlphaFold 2 & appendix)
意向锁(Intention Lock)
Record locks
Intention lock
Understanding service governance in distributed development
EMQX Cloud 更新:日志分析增加更多参数,监控运维更省心
如何构建面向海量数据、高实时要求的企业级OLAP数据引擎?
[zeloengine] summary of pit filling of reflection system
0x80131500 solution for not opening Microsoft Store
[JS advanced] JS regular correlation functions and regular objects_ 02
解决Win10磁盘占用100%
阿唐的小帮手