Cluster configuration management method and system based on rocketmq
By using the interface between the management side and the NameSrv node and the distributed KV Store module in the Apache RocketMQ cluster to synchronize configuration information, the problem of metadata inconsistency between nodes is solved, unified management and high availability of cluster configuration are achieved, and stability is improved. and operation and maintenance efficiency.
Patent Information
- Application Number
- PCT/CN2023/143253
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-11
- Filing Date
- 2023-12-29
- Publication Date
- 2024-09-19
AI Technical Summary
In the Apache RocketMQ cluster, because the configuration of each node is saved and updated independently, metadata is inconsistent and abnormal problems occur, affecting the normal operation of the cluster.
Establish a connection with the NameSrv node through the management side, store the configuration information, start the broker node through PUT KV request to obtain the configuration information, and use the distributed KV Store module to synchronize the configuration to ensure the consistency of the cluster configuration.
It provides a unified perspective to reduce the difficulty and cost of operation and maintenance, improves the stability of RocketMQ cluster, and avoids abnormal problems caused by metadata inconsistency.
Smart Images

Figure CN2023143253_19092024_PF_FP_ABST
Abstract
Description
A cluster configuration management method and system based on RocketMQ Technical Field
[0001] The present invention belongs to the technical field of middleware, and in particular relates to a cluster configuration management method and system based on RocketMQ. Background Art
[0002] Apache RocketMQ is a distributed messaging platform with low latency, high concurrency, high availability, and high reliability. It is widely adopted by many enterprise developers and cloud vendors due to its simple architecture, rich business functions, and strong scalability.
[0003] Apache RocketMQ has a simple deployment architecture, with each process deployed independently and independent of each other. The RocketMQ Broker is responsible for message storage and computation. The RocketMQ NameSrv is a simple topic routing registry that supports dynamic registration and discovery of topics and brokers. NameSrv is typically deployed with multiple instances, which do not communicate with each other.
[0004] Each RocketMQ node's configuration is stored independently in a local configuration file, with independent modification interfaces. Therefore, metadata consistency across all nodes in the cluster cannot be guaranteed, leading to more anomalies and impacting the cluster's normal operation and usability. Each node in the cluster is independently stored and updated, and updates on some nodes can fail, resulting in inconsistent cluster metadata and unpredictable cluster anomalies.
[0005] Summary of the Invention
[0006] The purpose of the present invention is to provide a cluster configuration management method and system based on RocketMQ, so as to improve the stability of the RocketMQ cluster and avoid abnormal problems caused by inconsistent metadata, so as to solve the problems raised in the above background technology.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: a cluster configuration management method based on RocketMQ, comprising: establishing a connection between the management side and the NameSrv node through an interface, and storing configuration information on the NameSrv node; sending a PUT KV request to the NameSrv node through the management side; starting the broker node according to the PUT KV request to obtain the configuration information from the NameSrv node, and managing the configuration of all broker nodes in the cluster.
[0008] Preferably, the management side uses the existing interface of NameSrv to store the configuration information under the namespace attribute, and the NameSrv node is synchronized to the entire NameSrv cluster through the distributed KV Store module.
[0009] Preferably, the interfaces of the KV Store module include KEYS, DELETE and LOCK; the KEYS and DELETE are used only to clean up data when cleaning up the managed cluster; and the LOCK includes GET and PUT.
[0010] Preferably, the startup broker node actively queries the version information on the broker node when obtaining the configuration information from the NameSrv node.
[0011] Preferably, querying the version information on the broker node includes:
[0012] If no version information is found, lock the current node and synchronize the full configuration information to this node through the existing open source interface. After the operation is completed, update the node version information.
[0013] If version information is found and is lower than the latest version information, the incremental operation steps for the topic and subscription group are replayed once on the target node. For other configurations, a full update is performed once. After the operation is completed, the node version information is updated;
[0014] If the node version information is found to be greater than or equal to the latest version information, the operation ends.
[0015] Preferably, the externally exposed interface of the KV Store module receives PUT requests and GET requests.
[0016] Preferably, the KV Store module is connected to an ETCD type KV system or object storage system.
[0017] Preferably, the KV value of the KV Store module is set according to the configuration information of the broker node.
[0018] Preferably, the message header of the PUT request is provided with a security verification field.
[0019] On the other hand, the present invention proposes a cluster configuration management method based on RocketMQ, comprising:
[0020] A storage module, configured to establish a connection between the management side and the NameSrv node through an interface, and store configuration information on the NameSrv node;
[0021] A request sending module, configured to send a PUT KV request to the NameSrv node through the management side;
[0022] The configuration management module is used to start the broker node to obtain the configuration information from the NameSrv node according to the PUT KV request, and manage the configuration of all broker nodes in the cluster.
[0023] Technical effects and advantages of the present invention: Compared with the existing technology, the cluster configuration management method and system based on RocketMQ proposed in the present invention have the following advantages:
[0024] The present invention establishes a connection between the management side and the NameSrv node through an interface and stores configuration information on the NameSrv node; the management side sends a PUT KV request to the NameSrv node; based on the PUT KV request, the broker node is started to obtain configuration information from the NameSrv node, and the configuration of all broker nodes in the cluster is managed. This provides a unified perspective for cluster configuration management, reduces the difficulty and cost of operation and maintenance, improves the stability of the RocketMQ cluster, and avoids abnormal problems caused by inconsistent metadata. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] FIG1 is a schematic diagram of a cluster configuration management method based on RocketMQ according to the present invention;
[0026] FIG2 is a schematic diagram of the interface structure exposed to the outside of the KV Store module of the present invention;
[0027] FIG3 is a schematic diagram showing various implementations of the KV Store module according to the present invention based on scenarios;
[0028] FIG4 is a schematic diagram of the RAFT-based KV Store implementation of the present invention;
[0029] FIG5 is a diagram showing the setting of the KV value of the present invention;
[0030] FIG6 is a flow chart of the management configuration of the present invention;
[0031] FIG7 is a flow chart of a cluster configuration management method based on RocketMQ according to the present invention;
[0032] FIG8 is a schematic structural diagram of a cluster configuration management system based on RocketMQ according to the present invention. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. The specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0034] The present invention provides a cluster configuration management method based on RocketMQ as shown in FIG7 , including:
[0035] Step 1: Establish a connection between the management side and the NameSrv node through the interface, and store configuration information on the NameSrv node;
[0036] Specifically, the management side uses the existing interface of NameSrv to store the configuration information under the namespace attribute, and the NameSrv node synchronizes the configuration information to the entire NameSrv cluster through the distributed KV Store module.
[0037] Furthermore, the interfaces of the KV Store module include KEYS, DELETE, and LOCK; KEYS and DELETE are used only to clean up data when cleaning up the managed cluster; and LOCK includes GET and PUT.
[0038] Step 2: Send a PUT KV request to the NameSrv node through the management side;
[0039] Step 3: Start the broker node according to the PUT KV request to obtain the configuration information from the NameSrv node and manage the configuration of all broker nodes in the cluster.
[0040] Specifically, the startup broker node actively queries the version information on the broker node when obtaining the configuration information from the NameSrv node.
[0041] The querying of the version information on the broker node includes:
[0042] If no version information is found, lock the current node and synchronize the full configuration information to this node through the existing open source interface. After the operation is completed, update the node version information.
[0043] If version information is found and is lower than the latest version information, the incremental operation steps for the topic and subscription group are replayed once on the target node. For other configurations, a full update is performed once. After the operation is completed, the node version information is updated;
[0044] If the node version information is found to be greater than or equal to the latest version information, the operation ends.
[0045] The KV Store module's externally exposed interface accepts PUT and GET requests. The PUT request header includes a security verification field. The KV Store module connects to an ETCD-style KV system or object storage system. The KV Store module's KV value is set based on the broker node's configuration information.
[0046] The management side establishes a connection with the NameSrv node through the interface and stores the configuration information on the NameSrv node. The management side sends a PUT KV request to the NameSrv node. Based on the PUT KV request, the broker node is started to obtain the configuration information from the NameSrv node and manage the configuration of all broker nodes in the cluster. This provides a unified perspective for cluster configuration management, reduces the difficulty and cost of operation and maintenance, improves the stability of the RocketMQ cluster, and avoids abnormal problems caused by inconsistent metadata.
[0047] On the other hand, the present invention proposes a cluster configuration management method based on RocketMQ, as shown in FIG8 , including: a storage module, a request sending module and a configuration management module.
[0048] Specifically, the storage module is used to establish a connection between the management side and the NameSrv node through an interface, and store configuration information on the NameSrv node;
[0049] Specifically, the request sending module is used to send a PUT KV request to the NameSrv node through the management side;
[0050] Specifically, the configuration management module is used to start the broker node to obtain the configuration information from the NameSrv node according to the PUT KV request, and manage the configuration of all broker nodes in the cluster.
[0051] In addition, when the storage module, request sending module, and configuration management module are executed, other functions of the aforementioned RocketMQ-based cluster configuration management method can also be implemented, as follows.
[0052] By utilizing distributed KV storage at the NameSrv node layer, without changing the cluster deployment architecture and maintaining full compatibility with the open source ecosystem, the function of a cluster configuration center is realized, supporting automatic synchronization of configuration information, dynamic addition of nodes, and other capabilities.
[0053] The management side uses existing NameSrv interfaces to store configuration information in a specific namespace attribute. NameSrv nodes are synchronized to the entire NameSrv cluster via distributed KV storage, ensuring configuration consistency and high availability. Using the open source broker registration mechanism, configuration information is maintained across all broker nodes in the cluster, ensuring consistency.
[0054] By placing configuration information uniformly on the NameSrv node and registering with the NameSrv node when the broker node starts, the configuration of all broker nodes in the cluster is managed to ensure that the cluster metadata information remains consistent.
[0055] Cluster configuration management provides a unified perspective, reducing the difficulty and cost of operations and maintenance. It improves the stability of the RocketMQ cluster and eliminates issues caused by inconsistent metadata. Cloud-native, it supports automatic scaling and expansion. It is low-cost and uses a streamlined storage format, requiring very little storage space.
[0056] As shown in Figure 3, the distributed KV Store module is used to store cluster configuration information. The KV Store module itself needs to ensure high availability and consistency of the distributed cluster.
[0057] Only PUT and GET requests are exposed to the KV Store module. Because the KV Store module has clear functions and boundaries, different implementations can be adopted based on different scenarios.
[0058] You can configure one or more KV Store implementations. When using multiple implementations, all implementations are written and read in the order they are configured. Multiple implementations can be used to enhance data security and enable seamless migration between different environments.
[0059] As shown in Figure 4, in traditional bare-metal deployments, since machine resources are largely fixed, RAFT can be used to synchronize KV values and implement elections. Data is compressed and stored on local storage. In cloud-native or container-based scenarios, KV storage can be connected to KV-like systems such as ETCD or object storage systems. NameSrv nodes do not store any state, allowing for flexible expansion.
[0060] As shown in Figure 5, the KV value design of the KV Store is mainly determined by the configuration information required by the Broker.
[0061] Supports simultaneous management of multiple RocketMQ clusters, supporting both cluster-level and node-level configuration management. Priority: node > cluster. Version information prevents ABA issues. For some configuration information, only the latest value is needed. For this purpose, a complete copy of the latest value and the current version is sufficient.
[0062] The following example:
[0063] fileReservedTime=168
[0064] DeleteWhen=04
[0065] For some configuration information, there is an ABA problem. For example, for topic or subscription group configuration, you need to maintain a version-based incremental change content, as shown in the following example:
[0066] [
[0067] {"topicName":"test","state":"create","version":"1"},
[0068] {"topicName":"test","state":"delete","version":"2"},
[0069] {"topicName":"test","state":"create","version":"3"}
[0070] ].
[0071] It provides a unified management portal for the configuration management of the entire RocektMQ cluster, without having to worry about abnormal problems caused by inconsistent configuration.
[0072] The management side can directly connect to NameSrv without having to access every node to obtain complete cluster information. The management side sends a PUT KV request to NameSrv and only needs to write the entire KV store to the distributed KV store.
[0073] Broker nodes register information with NameSrv upon startup and periodically. This triggers NameSrv to perform a metadata version check on the node and ensure that the node's elements remain consistent with the cluster version. Updates are performed based on the version, making the entire update operation idempotent. Cluster metadata can also be automatically synchronized for newly added or recovered nodes.
[0074] As shown in Figure 6, a configuration management module is extended on Apache RocektMQ.
[0075] Added the definition of the KV Store interface. The only interfaces are GET, PUT, KEYS, DELETE, and LOCK. The KEYS and DELETE interfaces are used for data cleanup and are only used when cleaning managed clusters. They do not affect core functionality. The LOCK interface is a combination of the GET and PUT interfaces. It requires implementing a set of atomic GET and PUT operations, which can also be achieved by leveraging the characteristics of external storage.
[0076] Add a specific implementation of KV Store. To connect to external systems such as ETCD and object storage, just call the corresponding interface. For the implementation of local storage, implement a KV cache data format. All KEY values are cached in memory, using the TreeMap data type. The VALUE value uses a delayed loading memory object. The specific value is usually placed on the local storage and temporarily loaded into the memory when needed. If it is not used for a certain period of time, the memory is released. The KEY / VALUE value is stored in a compressed JSON file format. In order to avoid reading all the content when loading into the memory during use, the KV content is split into multiple files according to the consistent HASH of the KEY value. On the basis of this local KV storage, the RAFT synchronization protocol is added to synchronize operations on the local KV storage to all nodes. Implement a distributed KV Store based on RAFT.
[0077] This extends the existing GET / PUT KV interface of the open source nameserver. If a special meta-manager is detected, the interface will be redirected to the corresponding KV STORE interface. This interface is used to expose operations and maintenance management. For security reasons, the PUT interface requires additional security verification fields in the message header. The VALUE value of the PUT KV interface is not the configuration value itself, but actually an operation data structure, as follows: {"action":"create_tpoic","params":{"topicName":"test"}}.
[0078] To prevent concurrent execution, the target key value needs to be locked. This requires the KV STORE to provide this capability. Common implementations utilize TTL or temporary node mechanisms.
[0079] When modifying a configuration, first call the LOCK API to lock the configuration. Then, perform the logical modification to the target KEY VALUE. For broker configuration files and role-controlled configuration information, only the latest full values are required. For information such as topics and subscription groups, incremental content must be saved. After modifications are complete, the cluster version information must also be updated.
[0080] When the Nameserver receives a configuration change request or a broker node registration request, it will proactively query the broker node for version information.
[0081] If no version information is found, you need to lock the node. Synchronize the full configuration information to the node through an open-source interface. After the operation is completed, update the node's version information.
[0082] If version information is found and is lower than the latest version, replay the incremental steps for topics and subscription groups on the target node. For other configurations, perform a full update. After the operation is complete, update the node's version information.
[0083] If the node version information is found to be greater than or equal to the latest version information, the operation ends.
[0084] This solves the problem of inconvenient configuration management of a large number of RockeMQ nodes during actual operation. It also provides the ability to synchronize configuration information when dynamically scaling nodes. It also provides foundational capabilities for other extended features: metadata management for cloud-native scenarios; cluster-level distributed locking; and cross-node distributed transaction messaging.
[0085] In addition, this embodiment also provides the present invention also provides a terminal device. The RocketMQ-based cluster configuration management method involved in this embodiment is mainly applied to the terminal device, which can be a PC, portable computer, mobile terminal, etc. with display and processing functions.
[0086] Specifically, a terminal device may include a processor (e.g., a CPU), a communication bus, a user interface, a network interface, and a memory. The communication bus is used to enable communication between these components; the user interface may include a display and an input unit such as a keyboard; the network interface may optionally include a standard wired interface or a wireless interface (e.g., a Wi-Fi interface); and the memory may be high-speed RAM or non-volatile memory, such as a disk drive. The memory may also be a storage device independent of the processor.
[0087] The memory stores a readable storage medium, and the readable storage medium stores a cluster configuration management program. The processor can call the cluster configuration management program stored in the memory and execute the RocketMQ-based cluster configuration management method provided in an embodiment of the present invention.
[0088] It will be understood that a computer-readable storage medium can be a tangible device that can hold and store instructions used by an instruction execution device. Computer-readable storage media can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination thereof. As used herein, a computer-readable storage medium is not to be construed as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through an electrical wire.
[0089] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in the computer-readable storage medium in each computing / processing device.
[0090] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., utilizing an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions. The electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0091] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A cluster configuration management method based on RocketMQ, It is characterized in that include: Establishing a connection between the management side and the NameSrv node through an interface, and storing configuration information on the NameSrv node; Sending a PUT KV request to the NameSrv node through the management side; The broker node is started according to the PUT KV request to obtain the configuration information from the NameSrv node, and the configuration of all broker nodes in the cluster is managed.
2. According to the RocketMQ-based cluster configuration management method of claim 1, It is characterized in that The management side uses the existing interface of NameSrv to store the configuration information under the namespace attribute, and the NameSrv node is synchronized to the entire NameSrv cluster through the distributed KV Store module.
3. According to the RocketMQ-based cluster configuration management method of claim 2, It is characterized in that The interfaces of the KV Store module include KEYS, DELETE and LOCK; The KEYS and DELETE methods are only used to clean up data when cleaning up the managed cluster. The LOCK includes GET and PUT.
4. According to claim 1, a cluster configuration management method based on RocketMQ, It is characterized in that The startup broker node actively queries the version information on the broker node when obtaining the configuration information from the NameSrv node.
5. According to claim 4, a cluster configuration management method based on RocketMQ, It is characterized in that The querying the version information on the broker node includes: If no version information is found, lock the current node and synchronize the full configuration information to this node through the existing open source interface. After the operation is completed, update the node version information. If version information is found and is lower than the latest version information, the incremental operation steps for topics and subscription groups are replayed once on the target node, and all other configurations are updated once. After the operation is completed, the node version information is updated; If it is found that the node version information is greater than or equal to the latest version information, the operation ends.
6. According to claim 2, a cluster configuration management method based on RocketMQ, It is characterized in that The externally exposed interface of the KV Store module receives PUT requests and GET requests.
7. A cluster configuration management method based on RocketMQ according to claim 6, It is characterized in that The KV Store module is connected to an ETCD type KV system or object storage system.
8. According to the RocketMQ-based cluster configuration management method of claim 7, It is characterized in that The KV value of the KV Store module is set according to the configuration information of the broker node.
9. A cluster configuration management method based on RocketMQ according to claim 6, It is characterized in that The message header of the PUT request is provided with a security verification field.
10. A cluster configuration management method based on RocketMQ, It is characterized in that include: A storage module, used to establish a connection between the management side and the NameSrv node through an interface, and store configuration information on the NameSrv node; A request sending module, used for sending a PUT KV request to the NameSrv node through the management side; The configuration management module is used to start the broker node to obtain the configuration information from the NameSrv node according to the PUT KV request, and manage the configuration of all broker nodes in the cluster.
Citation Information
Patent Citations
Multi-cluster data synchronization method of distributed storage system and related device
CN110795503A
Server cluster configuration hot loading system and method, equipment and medium
CN112612545A
IPv4 / IPv6 dual-stack support method and device for multi-version container cluster
CN115509673A
Multi-cluster container orchestration
US20210342193A1
Cited By
All-media all-signal integrated management platform
CN120935094A
