当前位置:网站首页>Quickly deploy mqtt clusters on AWS using terraform
Quickly deploy mqtt clusters on AWS using terraform
2022-07-28 11:29:00 【51CTO】
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 .
Verify the installation
Specific reference Official documents
install AWS Cli
With Mac For example
Verify the installation
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
Use Terraform stay AWS Upper Department EMQX colony
download AWS Deployment scripts
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_package value , 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
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.
user name :
adminpassword :
public
http://tf-elb-nlb-5bff6976b15586dd.elb.us-east-1.amazonaws.com:18083

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
边栏推荐
- Random talk on GIS data (V) - geographic coordinate system
- Three ways for Cortex-M kernel to manage global interrupts
- What functions does MySQL have? Don't look everywhere. Just look at this.
- What is WordPress
- ThinkPad指纹验证在win7无法使用的解决方法
- 什么是WordPress
- Do you want to enroll in class for advanced soft exam
- Use the common union and pointer to test the size end
- Learn to use MySQL explain to execute the plan, and SQL performance tuning is no longer difficult
- 重新刷新你对Redis集群的理解
猜你喜欢

重新刷新你对Redis集群的理解

「学习笔记」树状数组
Microsoft security team found an Austrian company that used windows Zero Day vulnerability to sell spyware

Do you want to enroll in class for advanced soft exam

keil和IAR中lib库文件的生成和使用

GIS数据漫谈(五)— 地理坐标系统

The solution of PHP sending mobile MAS SMS garbled code

接口测试的作用

Encryption defect of icloud Keychain in Apple mobile phone

JS - 修改数组中对象的键名
随机推荐
c语言链表的使用
mysql的左连接和右连接(内连接和自然连接的区别)
ripro9.0修正升级版+WP两款美化包+稀有插件
Summary of the second semester of junior year
Two dimensional prefix and
对话庄表伟:开源第一课
win10安装sqlmap(windows 7)
用c语言编写学生成绩管理系统(c语言学生成绩管理系统删除)
目标检测领域必看的6篇论文
keil和IAR中lib库文件的生成和使用
A solution to the problem that ThinkPad fingerprint verification cannot be used in win7
I use the applet container to improve the efficiency of mobile R & D by 5 times!
Display line number under VIM command [easy to understand]
Learning notes tree array
融云 IM & RTC 能力上新盘点
JWT login authentication + token automatic renewal scheme, well written!
Technology sharing | quick intercom integrated dispatching system
Machine learning strong foundation plan 0-5: why is the essence of learning generalization ability?
1天涨粉81W,打造爆款短视频的秘诀是什么?
const与指针的组合使用