当前位置:网站首页>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
边栏推荐
- doGet与doPost
- MySQL metadata lock (MDL)
- 进程之间的通信(管道详解)
- 01. A simpler way to deliver a large number of props
- [JS advanced] JS regular correlation functions and regular objects_ 02
- High score technical document sharing of ink Sky Wheel - Database Security (48 in total)
- Product upgrade observation station in June
- Upgrade esxi6.7.0 to 7.0u3f (updated on July 12, 2022)
- Leetcode:6127. Number of high-quality number pairs [bit operation finding rules + the sum of two numbers is greater than or equal to K + dichotomy]
- C# 模拟抽奖
猜你喜欢

0x80131500 solution for not opening Microsoft Store

Ml image depth learning and convolution neural network

进程之间的通信(管道详解)

EMQX Cloud 更新:日志分析增加更多参数,监控运维更省心

Waterfall flow layout

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

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

Product dynamics - Android 13 high-efficiency adaptation new upgrade

一文理解分布式开发中的服务治理

可验证随机函数 VRF
随机推荐
Leetcode:528. select randomly according to the weight [ordinary random failure + prefix and dichotomy]
C # simulation lottery
Release of v6.5.1/2/3 series of versions of Xingyun housekeeper: the ability of database OpenAPI continues to be strengthened
没错,请求DNS服务器还可以使用UDP协议
Ml image depth learning and convolution neural network
Endnote cannot edit range resolution
MySQL table read lock
Typescript learning 1 - data types
Basic usage of MFC thread afxbeginthread, passing multiple parameters
MySQL read / write lock
Recommended collection, which is probably the most comprehensive coding method summary of category type features
如何构建面向海量数据、高实时要求的企业级OLAP数据引擎?
High score technical document sharing of ink Sky Wheel - Database Security (48 in total)
墨天轮高分技术文档分享——数据库安全篇(共48个)
Gap locks
MySQL显式锁
EMQX Cloud 更新:日志分析增加更多参数,监控运维更省心
MySQL tutorial 66 data table query statement
mysql 表读锁
Endnote add Chinese gbt7714 style how to quote documents in word