当前位置:网站首页>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
边栏推荐
- Pagehelper.startpage is not effective
- MySQL global lock
- 报表工具的二次革命
- The second revolution of reporting tools
- ServletConfig 类和ServletContext 类
- Endnote cannot edit range resolution
- R语言偏相关性计算(Partial Correlation)、使用ggm包的pcor函数计算偏相关性(Partial Correlations)
- [Shakespeare: keep the fun of being a man]
- [zeloengine] summary of pit filling of reflection system
- MySQL tutorial 66 data table query statement
猜你喜欢

I interviewed 8 companies and got 5 offers in a week. Share my experience

推荐收藏,这或许是最全的类别型特征的编码方法总结

0x80131500打不开微软商店的解决办法

TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format

Ml image depth learning and convolution neural network

Ice 100g network card fragment message hash problem
![[fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code](/img/9e/138e4b160fa9bd6486fac44a788d09.png)
[fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code
![Leetcode:154. find the minimum value II in the rotation sort array [about the middle and rear positioning dichotomy of the rotation sort array]](/img/03/54a2d82a17cd07374dc0aedacd7b11.png)
Leetcode:154. find the minimum value II in the rotation sort array [about the middle and rear positioning dichotomy of the rotation sort array]

Win11动态磁贴没了?Win11中恢复动态磁贴的方法

面试8家公司,1周拿了5个offer,分享一下自己的心得
随机推荐
权限管理-角色分配菜单
面试8家公司,1周拿了5个offer,分享一下自己的心得
Win11桌面切换快捷键是什么?Win11快速切换桌面的方法
02. Limit the parameter props to a list of types
Waterfall flow layout
MySQL 元数据锁(MDL)
论文笔记:Highly accurate protein structure prediction with AlphaFold (AlphaFold 2 & appendix)
MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
如何构建面向海量数据、高实时要求的企业级OLAP数据引擎?
01. A simpler way to deliver a large number of props
MySQL implicit lock
[JS advanced] JS regular correlation functions and regular objects_ 02
今天睡眠质量记录84分
乐观锁悲观锁适用场景
Implementation of recommendation system collaborative filtering in spark
MySQL pessimistic lock
使用Huggingface在矩池云快速加载预训练模型和数据集
哪个led显示屏厂家更好
mysql意向锁
Leetcode:528. select randomly according to the weight [ordinary random failure + prefix and dichotomy]