Author: Sun Hangda, a Middleware Development Engineer from the Intelligent Cloud Department of Li Auto, currently responsible for the development and operation of Apache RocketMQ, ShardingSphere Proxy, and full data migration middleware
Li Auto is a new energy vehicle manufacturer. What makes us special in the general Internet business is the addition of the Internet of Things. As the company grows, business capacity is getting larger. In this process, service has higher requirements on the infrastructure. The main problems we face include limited expansion of single cloud resources, disaster recovery in the single cloud and single region, strong dependence on single cloud providers, and single-point access to the Internet of Things.
The multi-cloud and multi-active architecture (as a reliable and highly available deployment architecture) has become the primary choice of major Internet companies to keep the core service continuity, enhance anti-risk capabilities, and achieve a resilient architecture.
The service is unitized and deployed on different cloud VDC systems. Users can use SDE to pull up VDC with one click, quickly deploy infrastructure, middleware, and business applications, and create various resources. Apache RocketMQ is an important basic middleware. Its deployment capability affects the pull-up speed of VDC.
The usual procedure for deploying an ApacheRocketMQ cluster is listed below:
If a large-scale ApacheRocketMQ cluster is deployed manually, the deployment time will be hours or days. Li Auto uses Terraform (an orchestration tool for infrastructure automation) to orchestrate the entire deployment process. The Apache RocketMQ cluster is deployed as the atomic capability and is implemented using Ansible Playbook.
You only need to fill in a few parameters on the control platform (such as the cluster name, namesrv and broker deployment scale, and machine configuration) to deploy a complete set of ApacheRocketMQ and achieve rapid cluster deployment.
During deployment, Terraform calls the cluster information from the control platform and accesses it on the interface to complete the entire deployment process.
Finally, the Apache RocketMQ Exporter has been successfully registered on the consul cluster of Prometheus.
Apache RocketMQ Playbook can deploy a complete Apache RocketMQ cluster (including Apache RocketMQ Exporter). Apache RocketMQ Playbook is idempotent and does not restart the running process during repeated execution. Scaling out the Apache RocketMQ cluster online is supported. Since the scale-in of an Apache RocketMQ cluster involves data contraction, it is generally not supported in Apache RocketMQ Playbook. Apache RocketMQ Playbook integrates tasks (such as deployment environment initialization, runnable package download, OS parameter tuning, optimal broker configuration, Apache RocketMQ cluster deployment, Apache RocketMQ Exporter deployment, and adding an automatic startup mechanism) to automate large-scale cluster deployment.
Ansible is GitHub's most popular automated O&M tool in recent years. It can perform configuration management and application deployment. It realizes the functions of batch system configuration, batch program deployment, batch running commands, etc. Installation Documentation: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html
The Apache RocketMQ Playbook entry file is rocketmq.yml. rocketmq.yml contains three files: namesrv.yml, broker.yml, and exporter.yml. These three files are used to deploy Apache RocketMQ Namesrv, Apache RocketMQBroker, and Apache RocketMQ Exporter, respectively. rocketmq.yml can be executed separately to deploy a complete Apache RocketMQ cluster, or each file can be executed separately. The hosts file includes the deployed machine list and the Apache RocketMQ configuration information. Download URL: https://github.com/apache/rocketmq-externals/tree/master/rocketmq-ansible
# Deployed machine list of ApacheRocketmq Namesrv
[rocketmq_namesrv]
127.0.0.1
127.0.0.2
# Deployed machine list and the role configuration of each machine of ApacheRocketmq Broker
[rocketmq_broker]
127.0.0.3brokerName=broker-a brokerId=0 brokerRole=ASYNC_MASTER
127.0.0.4brokerName=broker-a brokerId=1 brokerRole=SLAVE
# Public configurations of ApacheRocketmq Broker [rocketmq_broker:vars]
brokerClusterName=DefaultCluster
namesrvAddr=127.0.0.1:9876;127.0.0.2:9876
storePathRootDir=/data/rocketmq/store
# Deployed machine list of ApacheRocketmq Exporter
[rocketmq_exporter]
127.0.0.5
# Public configurations of ApacheRocketmq Exporter
[rocketmq_exporter:vars]
namesrvAddr=127.0.0.1:9876;127.0.0.2:9876
webTelemetryPath=/metrics
rocketmqVersion=V4_7_1
vars/main.yml configures the deployment path and data path of Apache RocketMQ. You need to adjust according to your company's deployment specifications.
# Theglobal variable
rocketmq_deploy_path:/app
rocketmq_log_path:/data
namesrv/vars/main.yml is configured with the download URL of the Apache RocketMQ executable file, the namerv deployment path (which can be a subpath of a global variable), and the namesrv log path.
#namesrv variable
rocketmq_download_url:https://dlcdn.apache.org/rocketmq/4.9.3/rocketmq-all-4.9.3-bin-release.zip
rocketmq_deploy_path:/app
rocketmq_log_path:${user.home}
broker/vars/main.yml is configured with the download URL of the Apache RocketMQ executable file, the broker deployment path (which can be a subpath of a global variable), and the broker log path.
# brokervariable
rocketmq_download_url:https://dlcdn.apache.org/rocketmq/4.9.3/rocketmq-all-4.9.3-bin-release.zip
rocketmq_deploy_path:/app
rocketmq_log_path:${user.home}
exporter /vars/main.yml is configured with the download URL of the Apache RocketMQ Exporter executable file and the ApacheRocketMQ Exporter deployment directory.
Note: ApacheRocketMQ Exporter needs to be edited and packaged by yourself and uploaded to the company intranet.
#exportervariable
#exporterneed build by yourself
rocketmq_exporter_download_url:http://rocketmq.exporter/rocketmq-exporter-0.0.2-SNAPSHOT.jar
rocketmq_exporter_deploy_directory:/app/exporter
ansible-playbook/path/rocketmq.yml -i /path/hosts
Note: /path needs to be modified based on the actual path. The redundant configuration of the deployment path is to allow the three sub-playbooks to be executed separately.
# Start and stop ApacheRocketMQ Broker
systemctlstart mqbroker
systemctlstop mqbroker
# Start and stop ApacheRocketMQ Namesrv
systemctlstart mqnamesrv
systemctlstop mqnamesrv
# Start and stop ApacheRocketMQ Exporter
systemctlstart mqexporter
systemctlstop mqexporter
Based on the deployment capability of Apache RocketMQ Playbook, you can encapsulate the deployment interface with minimal parameters into the control platform. Finally, you can use a visualized interface to deploy large-scale Apache RocketMQ clusters in minutes.
Join the Apache RocketMQ community: https://github.com/apache/rocketmq
The Road to Large-Scale Commercialization of Apache RocketMQ on Alibaba Cloud
507 posts | 48 followers
FollowAlibaba Cloud Native Community - January 6, 2023
Alibaba Cloud Native Community - January 5, 2023
Alibaba Cloud Native Community - March 20, 2023
Alibaba Cloud Native Community - March 20, 2023
Alibaba Cloud Native - June 12, 2024
Aliware - July 3, 2020
507 posts | 48 followers
FollowApsaraMQ for RocketMQ is a distributed message queue service that supports reliable message-based asynchronous communication among microservices, distributed systems, and serverless applications.
Learn MoreSuper Computing Service provides ultimate computing performance and parallel computing cluster services for high-performance computing through high-speed RDMA network and heterogeneous accelerators such as GPU.
Learn MoreFollow our step-by-step best practices guides to build your own business case.
Learn MoreApsaraDB Dedicated Cluster provided by Alibaba Cloud is a dedicated service for managing databases on the cloud.
Learn MoreMore Posts by Alibaba Cloud Native Community