Database based on multi-log stream technology, database elastic scaling method, computer equipment and storage medium
By introducing multi-log stream technology and heartbeat function into the database, data sharding is dynamically managed, which solves the performance bottleneck problem of traditional databases under high load and expansion and contraction, achieves efficient data processing and capacity management, and simplifies engineering implementation. .
Patent Information
- Application Number
- CN202410713824.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-09-27
AI Technical Summary
When traditional database management systems process large-scale data, due to the limited processing capacity of a single log stream, response delays and data processing capabilities are limited under high load conditions, and a large number of data insertion and deletion operations are required when the database is expanded or reduced, which affects performance. low.
Using multi-log stream technology, the management node monitors the storage status of data nodes, dynamically expands or shrinks data shards, and uses the heartbeat function and metadata information management to realize automatic copying and migration of data shards, avoiding the problems in traditional solutions. Insertion and deletion operations.
It improves the parallel processing capabilities of the database, improves data throughput and request processing capabilities, simplifies the expansion and contraction process of the database, and reduces the difficulty of engineering implementation.
Smart Images

Figure CN118708564A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of database management systems and cloud computing, and specifically relates to a database based on multi-log stream technology, a database elastic scaling method, a computer device and a storage medium. Background Art
[0002] With the rapid development of information technology, databases are the core of storage and management of massive data, and their performance, stability and scalability are particularly critical. However, when processing large-scale data, traditional database management systems are often limited by the processing capacity of a single log stream of a database instance. This processing method based on a single log stream may encounter performance bottlenecks and scalability challenges when dealing with a large number of concurrent requests or scaling up or down the database.
[0003] Specifically, the processing capacity of a single log stream of a database instance is limited, and it is difficult to effectively handle a large number of concurrent transaction logs, resulting in delayed response and limited data processing capacity of the database under high load. In addition, in terms of expansion and contraction of distributed databases, the commonly used expansion solution is to read part of the data of a selected data shard from the original data shard and execute an insert request to insert it into a new node, and then execute a delete request to delete the corresponding data of the data shard; for contraction, all the data in a node is read out and an insert request is executed to insert it into other nodes, and then the node is removed from the cluster. Whether it is expansion or contraction, traditional solutions need to perform a large amount of data insertion and deletion operations, and the performance is relatively low. Summary of the invention
[0004] Purpose of the invention: In order to solve the performance bottleneck problem of a single log stream of a database instance when dealing with a large number of concurrent requests or data updates, and to solve the complex engineering implementation and performance problems faced when scaling the database, the present invention proposes a database based on multi-log stream technology, a database elastic scaling method, a computer device and a storage medium. By introducing a multi-log stream mechanism in the database, the ability to process business requests in parallel can be greatly improved.
[0005] Technical solution: A database based on multi-log stream technology, including management nodes, computing nodes and data nodes;
[0006] The management node is responsible for metadata information management and data node expansion or reduction scheduling;
[0007] The computing node is responsible for processing query requests of the application, generating an execution plan and obtaining required data from the data node;
[0008] The data node is responsible for storing and reading actual data;
[0009] Each data node implements shard storage by setting up several data shards, each data shard has an independent data shard file, and the data shard file includes a log stream.
[0010] Furthermore, data node expansion scheduling specifically includes:
[0011] Through the heartbeat function, the management node continuously monitors the storage status of data shards in each data node; only when the storage status of a data node meets the preset database expansion status, the database expansion function is actively triggered to mark the data node as a busy data node;
[0012] The management node determines an idle data node or registers a new idle data node based on the storage status of other data nodes, and directly copies some data shard files stored on the busy data node to the idle data node;
[0013] The management node updates the metadata information and deletes the copied data shard files on the busy data nodes.
[0014] Furthermore, the data node scaling down scheduling specifically includes:
[0015] Through the heartbeat function, the management node continuously monitors the storage status of data shards in each data node; only when the storage status of a data node meets the preset database shrinking status, the database shrinking function is actively triggered; and the data node is marked as a data node to be migrated;
[0016] The management node determines the target data node according to the storage status of other data nodes, and copies the data shard files stored on the data node to be migrated to the target data node;
[0017] After the migration is completed, the management node updates the metadata information and deletes the data shard files on the data nodes to be migrated.
[0018] Furthermore, the data shard file also includes a data file, an index file and a rollback file.
[0019] Furthermore, the metadata information includes the data node and data shard information where the original data is located.
[0020] The present invention discloses a database elastic scaling method based on multiple log streams, comprising:
[0021] The management node continuously monitors the storage status of each data shard in each data node through the heartbeat function;
[0022] When the storage status of the monitored data node DN0 meets the preset database expansion status, a new data node DN1 is registered. After judgment, the management node copies some data shard files in the data node DN0 to the data node DN1, modifies the metadata information stored in the management node, and then deletes some data shard files in the data node DN0 that have been copied to the data node DN1.
[0023] When it is monitored that the storage status of data node DN0 meets the preset database shrinkage status, some data shard files in data node DN1 are copied to data node DN0, and then the metadata information stored in the management node is updated, and finally some data shard files in data node DN1 are deleted.
[0024] Furthermore, it also includes the step of initializing a database;
[0025] The steps of initializing the database include:
[0026] Determine the total number of data shards and allocation rules based on server hardware performance and data storage scale; the allocation rules determine the storage method and distribution of data in the database;
[0027] Register compute nodes and data nodes with the management node;
[0028] The management node allocates corresponding data shards to each data node according to the user's initialization command. Each data shard has an independent log stream.
[0029] The application writes data to the data shard corresponding to the data node according to the sharding rules.
[0030] Furthermore, each data shard has independent data files, index files, and rollback files.
[0031] The present invention discloses a computer device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the processor implements the steps of a database elastic scaling method based on multiple log streams.
[0032] The present invention discloses a storage medium, wherein the storage medium stores a database elastic scaling program, and when the database elastic scaling program is executed by at least one processor, the steps of a database elastic scaling method based on multiple log streams are implemented.
[0033] Beneficial effect: Compared with the prior art, the method of the present invention uses a data sharding storage method based on multi-log stream technology in data nodes. Compared with a single log stream, it not only improves the data throughput of data nodes and the ability to process requests, but also provides a simple, efficient and easy implementation plan for the expansion and reduction of the database, reducing the difficulty of engineering implementation. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A schematic diagram of four stages of a database elastic scaling method based on multiple log streams of the present invention;
[0035] Figure 2 A schematic diagram of data reading and writing of a database based on a multi-log stream technology of the present invention;
[0036] Figure 3 A schematic diagram of a database expansion process based on a multi-log stream technology of the present invention;
[0037] Figure 4 The present invention is a schematic diagram of a database shrinking process based on the multi-log stream technology. DETAILED DESCRIPTION
[0038] The common distributed database architecture in the industry is now described. The overall architecture includes management nodes (part of the distributed database is called metadata nodes), computing nodes and data nodes (part of the distributed database is called storage nodes). The management node is mainly responsible for metadata management, data node fault detection and repair, data node expansion and contraction scheduling and other functions. The data node is responsible for the storage and reading of actual data. The computing node is usually stateless, responsible for receiving application requests, generating execution plans and obtaining the required data from the data node, and feeding back to the application after execution. The log stream in the present invention generally refers to the redo log file (Redo Log File) in the database and other derivative files such as rollback files generated while writing logs. Multi-log stream technology refers to the storage of data in a single database instance, each shard has its own independent log file, data file, index file and rollback file, etc. When using multiple log streams, a mechanism similar to distributed transactions is used to ensure data consistency between data shards and the ACID characteristics of transactions. However, a traditional single database instance has only one log file, and multiple data shards usually have independent data files and index files, but share one log file and rollback file.
[0039] The technical solution of the present invention is now further described in conjunction with the accompanying drawings and embodiments.
[0040] Embodiment 1:
[0041] This embodiment proposes a database elastic scaling method based on multiple log streams, which mainly includes the following stages:
[0042] (1) Database initialization phase
[0043] During the user's database initialization phase, the user needs to comprehensively consider and specify the total number of data shards (each shard corresponds to an independent log stream, and when setting the number of data shards, consider the maximum number of data nodes that may be expanded in the subsequent distributed cluster) and the initial allocation rules based on multiple factors such as server hardware performance and data storage scale. These allocation rules will determine how the data is stored and distributed in the database. After receiving the user's initialization command, the management node will execute the corresponding process to allocate the corresponding data shard to each data node. At this stage, users need to fully understand their business needs, data scale, and the maximum number of nodes in the cluster in order to reasonably set the number of data shards and allocation rules.
[0044] (2) User reads and writes data
[0045] When users perform data read and write operations, management nodes play a key role. Management nodes store metadata information, which is the basis for users to perform data read and write operations. By using the metadata information in the management node, users can determine the data nodes and data shards that should be accessed for read and write operations. The system will then send the read and write requests to the corresponding data nodes to complete the data access operations.
[0046] (3) Database expansion phase
[0047] As the amount of data continues to increase, the database may need to be expanded to meet greater storage needs. At this stage, the management node will regularly check the status of each data shard managed in each data node through the heartbeat function. Once it is found that the total disk space occupied by the data shard managed by a data node is too large, the number of recorded data is too large, or the load is too heavy, the database expansion function will be actively triggered. During the expansion process, the management node will make a comprehensive judgment based on factors such as the free space of other data nodes. If necessary, the user needs to add a new data node. At the same time, the management node will directly copy some data shard files on the data node that occupies too much space to the idle data node. After that, the management node will update the metadata information and delete the data shard files on the original data node. In this way, the database can achieve smooth expansion to meet the growing data storage needs without the need to perform insertion and deletion operations.
[0048] (4) Database reduction phase
[0049] In contrast to expansion, when the amount of data in the database decreases, it may be necessary to shrink the capacity to release unnecessary resources. At this stage, the management node will also continuously monitor the status of the data shards managed in each data node through the heartbeat function. When it is found that the data shards managed by some data nodes occupy too little disk space or record too little data, and this state has been maintained for a period of time, rules can be set to actively trigger the database shrinking function. During the shrinking process, the management node will conduct a comprehensive assessment based on factors such as the free space of other data nodes, copy the data shard files managed by the data nodes that occupy too little space to other data nodes, and delete the original data shard files after the migration is completed. In this way, the database can achieve reasonable shrinking, release unnecessary resources, and improve the operating efficiency of the system.
[0050] This embodiment uses a data sharding storage method based on multiple log stream technology in the data node. Compared with a single log stream, it not only improves the data throughput of the data node and the ability to process requests, but also provides a simple, efficient and easy implementation solution for scaling the database, reducing the difficulty of engineering implementation.
[0051] Embodiment 2:
[0052] Now Figure 2 , Figure 3 , Figure 4 Take the example to show the data reading and writing, expansion and reduction process of the database based on multi-log stream technology, which includes the following steps:
[0053] Step 1: The user initializes the database, registers a compute node CN0 (Compute Node 0) and a data node DN0 (Data Node 0) to the manager node MN0 (Manager Node 0), and then sends an initialization command to initialize 10 data shards. After receiving the command, the manager node MN0 adds 10 data shards to the data node DN0, which are recorded as: P0-P9 (Partition0-Partition9). Each data shard has an independent log stream, data file, index file, rollback file, etc., and is stored in the corresponding data shard directory P0-P9.
[0054] Step 2: The user sets the maximum amount of data for each data node to 1,000 records.
[0055] Step 3: The user application continuously initiates data write requests to the computing node CN0 in the database. The user application writes the data to the data shards P0-P9 corresponding to the data node DN0 according to the sharding rules.
[0056] Step 4: When the management node MN0 detects that the data space in the data node DN0 is insufficient through the heartbeat function, it notifies the operation and maintenance personnel that capacity expansion is required, such as Figure 3 As shown, the specific operations include: registering a new data node DN1 to the management node MN0 and triggering the capacity expansion function. After judgment, the management node MN0 copies the P5-P9 directory in the data node DN0 to the data node DN1, modifies the metadata information in the management node MN0, and then deletes the P5-P9 directory in DN0.
[0057] Step 5: When the user application reads a record, the computing node CN0 can calculate the data node and shard information where the data is located through the metadata information of the data node MN0, thereby finding the record that needs to be accessed.
[0058] Step 6: The user increases the amount of data that the data node can accommodate by 3 times, and the management node MN0 determines that it can be reduced. Figure 4 As shown, the P5-P9 directories in the data node DN1 are copied to the data node DN0, and then the metadata information stored in the management node MN0 is updated, and finally the P5-P9 directories in the data node DN1 are deleted.
[0059] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0060] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0061] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A database based on multiple log stream technology, characterized in that: Includes management nodes, computing nodes, and data nodes; The management node is responsible for metadata information management and data node expansion or reduction scheduling; The computing node is responsible for processing query requests of the application, generating an execution plan and obtaining required data from the data node; The data node is responsible for storing and reading actual data; Each data node implements shard storage of actual data by setting up several data shards. Each data shard has an independent data shard file, and the data shard file includes a log stream.
2. According to claim 1, a database based on multiple log stream technology is characterized in that: Data node expansion scheduling, including: Through the heartbeat function, the management node continuously monitors the storage status of data shards in each data node; only when the storage status of a data node meets the preset database expansion status, the database expansion function is actively triggered to mark the data node as a busy data node; The management node determines an idle data node or registers a new idle data node based on the storage status of other data nodes, and directly copies some data shard files stored on the busy data node to the idle data node; The management node updates the metadata information and deletes the copied data shard files on the busy data nodes.
3. The database based on multiple log stream technology according to claim 1, characterized in that: Data node scaling scheduling, including: Through the heartbeat function, the management node continuously monitors the storage status of data shards in each data node; only when the storage status of a data node meets the preset database shrinking status, the database shrinking function is actively triggered; and the data node is marked as a data node to be migrated; The management node determines the target data node according to the storage status of other data nodes, and copies the data shard files stored on the data node to be migrated to the target data node; After the migration is completed, the management node updates the metadata information and deletes the data shard files on the data nodes to be migrated.
4. The database based on multiple log stream technology according to claim 1, characterized in that: The data segment files also include data files, index files and rollback files.
5. The database based on multiple log stream technology according to claim 1, characterized in that: The metadata information includes the data node where the original data is located and the data shard information.
6. A database elastic scaling method based on multiple log streams, characterized in that: include: The management node continuously monitors the storage status of each data shard in each data node through the heartbeat function; When the storage status of the monitored data node DN0 meets the preset database expansion status, a new data node DN1 is registered. After judgment, the management node copies some data shard files in the data node DN0 to the data node DN1, modifies the metadata information stored in the management node, and then deletes some data shard files in the data node DN0 that have been copied to the data node DN1. When it is monitored that the storage status of data node DN0 meets the preset database shrinkage status, some data shard files in data node DN1 are copied to data node DN0, and then the metadata information stored in the management node is updated, and finally some data shard files in data node DN1 are deleted.
7. The method for elastically scaling a database based on multiple log streams according to claim 6 is characterized in that: Includes steps to initialize the database; The steps of initializing the database include: Determine the total number of data shards and allocation rules based on server hardware performance and data storage scale; the allocation rules determine the storage method and distribution of data in the database; Register compute nodes and data nodes with the management node; The management node allocates corresponding data shards to each data node according to the user's initialization command. Each data shard has an independent log stream. The application writes data to the data shard corresponding to the data node according to the sharding rules.
8. The method for elastically scaling a database based on multiple log streams according to claim 7, characterized in that: Each data shard also has independent data files, index files, and rollback files.
9. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of a database elastic scaling method based on multiple log streams as described in any one of claims 6 to 8 are implemented.
10. A storage medium, characterized in that: The storage medium stores a database elastic scaling program, and when the database elastic scaling program is executed by at least one processor, the steps of a database elastic scaling method based on multiple log streams according to any one of claims 6 to 8 are implemented.
