×
Community Blog Best Practices for Large-Scale Apache RocketMQ Cluster Deployment for Li Auto

Best Practices for Large-Scale Apache RocketMQ Cluster Deployment for Li Auto

This article discusses how Li Auto utilizes the deployment capability of Apache RocketMQ Playbook.

1

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

Why Do We Need to Deploy Apache RocketMQ Quickly?

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.

How Can I Deploy Apache RocketMQ Quickly?

The usual procedure for deploying an ApacheRocketMQ cluster is listed below:

  1. Apply for a Machine
  2. Apply for a domain name
  3. Deploy an Apache RocketMQ cluster
  4. Deploy the Apache RocketMQ Exporter
  5. Access Apache RocketMQ Exporter on the monitoring system
  6. Access the Apache RocketMQ cluster information on the control platform

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.

Effect

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.

2

During deployment, Terraform calls the cluster information from the control platform and accesses it on the interface to complete the entire deployment process.

3

Finally, the Apache RocketMQ Exporter has been successfully registered on the consul cluster of Prometheus.

4

An Introduction to Apache RocketMQ Playbook

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.

Use of Apache RocketMQ Playbook

1. Install Ansible

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

2. Download Apache RocketMQ Playbook

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

3. Modify the Configuration File as Needed

  • The hosts file describes the deployed machine list and the Apache RocketMQ configuration information.
# 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
  • Modify global variables

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
  • Modify the namesrv variable

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}
  • Modify the broker variable

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}
  • Modify the exporter variable

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

4. Execute the Apache RocketMQ Playbook

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.

5. Commands Available for Daily O&M

# 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

Conclusion

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

0 1 0
Share on

You may also like

Comments

Related Products

  • ApsaraMQ for RocketMQ

    ApsaraMQ for RocketMQ is a distributed message queue service that supports reliable message-based asynchronous communication among microservices, distributed systems, and serverless applications.

    Learn More
  • Super Computing Cluster

    Super 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 More
  • Best Practices

    Follow our step-by-step best practices guides to build your own business case.

    Learn More
  • Message Queue for Apache Kafka

    A fully-managed Apache Kafka service to help you quickly build data pipelines for your big data analytics.

    Learn More