当前位置:网站首页>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
边栏推荐
- Leetcode:528. select randomly according to the weight [ordinary random failure + prefix and dichotomy]
- 泰山OFFICE技术讲座:英寸,厘米,磅,派卡,提,行,字行,像素的换算关系
- Win11桌面切换快捷键是什么?Win11快速切换桌面的方法
- R语言ggplot2可视化线图(line)、自定义配置标题文本相关内容颜色和图例(legend)颜色相匹配(和分组线图的颜色相匹配、match colors of groups)
- 【ZeloEngine】反射系统填坑小结
- 递归菜单查询(递归:自己查自己)
- Analysis and solution of data and clock mismatch delay in SPI transmission
- What is a physical firewall? What's the effect?
- leetcode:6127. 优质数对的数目【位运算找规律 + 两数之和大于等于k + 二分】
- 测试驱动开发(TDD)在线练功房 | 9月17日开课
猜你喜欢

MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具

Use huggingface to quickly load pre training models and datasets in moment pool cloud
![[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

Upgrade esxi6.7.0 to 7.0u3f (updated on July 12, 2022)

终极套娃 2.0 | 云原生交付的封装
![Leetcode:528. select randomly according to the weight [ordinary random failure + prefix and dichotomy]](/img/fb/8178388f8c9ac80d95140378d24238.png)
Leetcode:528. select randomly according to the weight [ordinary random failure + prefix and dichotomy]

Understanding service governance in distributed development

聊聊如何用 Redis 实现分布式锁?

【图像去噪】基于双立方插值和稀疏表示实现图像去噪matlab源码

How to build an enterprise level OLAP data engine for massive data and high real-time requirements?
随机推荐
【图像隐藏】基于混合 DWT-HD-SVD 的数字图像水印方法技术附matlab代码
MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
ML - Speech - traditional speech model
聊聊如何用 Redis 实现分布式锁?
R语言偏相关性计算(Partial Correlation)、使用ggm包的pcor函数计算偏相关性(Partial Correlations)
MyBaits
Food safety - do you really understand the ubiquitous frozen food?
0x80131500 solution for not opening Microsoft Store
mysql 表写锁
MySQL显式锁
百奥赛图与LiberoThera共同开发全人GPCR抗体药物取得里程碑式进展
2w字详解数据湖:概念、特征、架构与案例
PageHelper.startPage没有生效问题
Solve win10 disk occupation of 100%
[fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code
pymongo保存dataframe格式的数据(insert_one, insert_many, 多线程保存)
How does win11's own drawing software display the ruler?
意向锁(Intention Lock)
R语言使用gt包和gtExtras包漂亮地显示表格数据:gt_bar_plot函数和gt_plt_bar_pct函数可视化百分比条形图、原始数据的百分比条形、缩放后的数据的百分比条形、指定数据对齐宽度
Permission management - delete menu (recursive)