Disk partition information recovery method and device, storage medium and computer program product
By building backup nodes in distributed clusters, high availability of disk partition information is achieved, the problems of complex back-and-change disk operations and poor user experience are solved, and fault handling efficiency is improved.
Patent Information
- Application Number
- CN202411046225.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-08
AI Technical Summary
In large-scale distributed cluster deployment, the back-and-change disk operation is complicated when the disk fails, and the user experience is poor. The existing technology has failed to effectively solve the problem of recovery of disk partition information, resulting in inefficient single-point fault handling.
By building a distributed cluster, the backup node is used to store and restore the disk partition information of other storage nodes, and the data is synchronized using the master-support mode to ensure that data can be pulled from the backup node in the event of a failure, achieving high availability of the hard disk partition information database.
It effectively simplifies the return and exchange operation, improves the user experience, ensures the availability of hard disk partition information database, and solves the problem of inefficient single-point fault handling.
Smart Images

Figure CN118916216A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the computer field, and specifically, to a method and device for recovering disk partition information, a storage medium, and a computer program product. Background Art
[0002] In the process of large-scale distributed cluster deployment projects, when deploying storage services, the partition information on each disk on each node and the various services deployed will be synchronously recorded in the database, including MON (Maintenance Operations Network, Maintenance Operation Network, referred to as MON) service, OSD (Online Storage Data Service, Online Storage Data Service, referred to as OSD) service, Elasticsearch service, etc. The reason for recording these service information is mainly to deal with how to restore the services on the original disk by replacing the new disk in the case of disk failure, so that the cluster can continue to provide services normally. However, in the actual production environment, cluster nodes may have failures and are difficult to continue to use. The failed node can be restored by refilling the system, but the database that currently records the node disk service will be cleared during the node filling process, affecting the subsequent disk return function. In addition, when there is a need to return the disk, it is necessary to use the temporary disk replacement maintenance tool to perform the operation of restoring the disk partition information and services on the failed node before the subsequent disk return operation can be performed, which makes the disk return operation complicated and reduces the user experience.
[0003] In the related art, there are problems such as complicated disk return and replacement operations and poor user experience, and no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a method and device for recovering disk partition information, so as to at least solve the problems of complicated disk return and replacement operations and poor user experience in the existing methods.
[0005] According to an embodiment of the present application, a method for recovering disk partition information is provided, comprising: upon receiving a backup instruction sent by a target object, building a distributed cluster for maintaining disk partition information, and configuring a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster comprises: N distributed storage nodes, N being an integer; using the backup node to store the disk partition information of other distributed storage nodes of the distributed cluster except the backup node; and in the event that an abnormality occurs in any node among the other distributed storage nodes, recovering the disk partition information of the arbitrary node through the backup node.
[0006] In an exemplary embodiment, upon receiving a backup instruction sent by a target object, a distributed cluster for maintaining disk partition information is built, including: upon determining that the backup instruction indicates to start a preset backup service, recording basic attributes of the disk partition information contained in the N distributed storage nodes according to a data structure corresponding to the preset backup service, wherein the data structure includes at least one of the following: node name, node address, cabinet to which the node belongs, backup node name list, backup threshold, backup failure time threshold, and disk data; determining the target backup information corresponding to each distributed storage node based on the recording results; and building a distributed cluster for maintaining disk partition information according to the target backup information.
[0007] In an exemplary embodiment, configuring a backup node for the distributed cluster according to the screening rule includes: when the distributed storage nodes in the distributed cluster are on different cabinets, determining the target cabinet where the master node that currently needs to be backed up is located, setting the backup node in other cabinets except the target cabinet, and calculating the first weight value of the other cabinet as a backup node of the master node, wherein the master node is a node determined from the distributed storage nodes according to the identification information of the backup instruction; when the distributed storage nodes in the distributed cluster are on the same cabinet, setting the backup node and the master node in the same network segment, and calculating the second weight value corresponding to the number of routing hops for data intercommunication access between the backup node and the master node; when there are N backup nodes, In the case that each of the distributed storage nodes has been configured as a backup node, the target number of times that each of the distributed storage nodes is configured as a backup node is determined, the distributed storage node with the lowest target number is selected as the latest backup node, and the third weight value corresponding to the backup load of the latest backup node is calculated; the backup node weight value of each of the distributed storage nodes shown as the main node is comprehensively calculated based on the first weight value, the second weight value, the third weight value and the preset weight formula to obtain N target weight values; the N target weight values are sorted from large to small, and according to the backup threshold pre-set in the preset backup service; according to the allowed backup number corresponding to the backup threshold shown, the distributed storage nodes with the allowed backup number are screened out from the N target weight values as backup nodes.
[0008] In an exemplary embodiment, when an abnormality occurs in any node among the other distributed storage nodes, before the disk partition information of the arbitrary node is restored through the backup node, the above method also includes: performing heartbeat monitoring on the backup node; recording the target duration of the backup node losing heartbeat monitoring; when the target duration is greater than the failure duration corresponding to the backup failure time threshold preset in the preset backup service, determining that the backup node has a failure and is down, and waiting to reselect a new backup node from the other distributed storage nodes; when the target duration is less than or equal to the failure duration corresponding to the backup failure time threshold preset in the preset backup service, determining that the backup node is in a failure recovery state.
[0009] In an exemplary embodiment, upon receiving a backup instruction sent by a target object, a distributed cluster for maintaining disk partition information is built, and after configuring backup nodes for the distributed cluster according to the screening rules, the method further includes: selecting at least three nodes from the distributed cluster, and using the at least three nodes to build a high-availability master control service; aggregating and monitoring the backup status of each node in the distributed cluster in real time through the high-availability master control service; and starting a cleanup operation on the at least one distributed storage node when the high-availability master control service determines that the target number of backup nodes corresponding to at least one distributed storage node in the distributed cluster is greater than the basic number corresponding to the backup threshold pre-set in the preset backup service.
[0010] In an exemplary embodiment, after starting the cleanup operation on the at least one distributed storage node, the above method also includes: monitoring the cleanup result of the at least one distributed storage node; when the cleanup result indicates that the target number of backup nodes corresponding to the at least one distributed storage node is less than the basic number corresponding to the backup threshold pre-set in the preset backup service, determining that the cleanup operation is successfully executed, and updating the corresponding backup information of the at least one distributed storage node.
[0011] In an exemplary embodiment, after using the backup node to store the disk partition information of other distributed storage nodes in the distributed cluster except the backup node, the above method also includes: when there are at least two backup nodes at the same time, setting the current distributed storage node as the main library of the database corresponding to the disk partition information, and setting the backup node as the backup library of the database corresponding to the disk partition information; when the storage pool of the main library is expanded or reduced or a new physical disk is added to the current distributed storage node, updating the data of the main library and synchronously updating the data of the backup library.
[0012] According to another embodiment of the present application, a disk partition information recovery device is also provided, including: a building module, which is used to build a distributed cluster for maintaining disk partition information when a backup instruction sent by a target object is received, and configure a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, N is an integer; a storage module, which is used to use the backup node to store the disk partition information of other distributed storage nodes of the distributed cluster except the backup node; a recovery module, which is used to recover the disk partition information of any node through the backup node when an abnormality occurs in any node among the other distributed storage nodes.
[0013] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0014] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0015] According to another embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0016] Through this application, when a backup instruction sent by a target object is received, a distributed cluster for maintaining disk partition information is built, and a backup node is configured for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, N is an integer; the backup node is used to store the disk partition information of other distributed storage nodes of the distributed cluster except the backup node; when an abnormality occurs in any node of the other distributed storage nodes, the disk partition information of the arbitrary node is restored through the backup node. The above technical solution is adopted, and the hard disk partition information database data on the node is synchronized to the backup node through the master-slave mode, so that when the hard disk partition information database on the node is lost and cannot provide data, data can be pulled from the corresponding backup node, which solves the problems of complex disk return and replacement operations and poor user experience in the existing method, and effectively guarantees the availability of the hard disk partition information database, and effectively solves the current low efficiency of single point failure processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 The hardware structure frame of a computer terminal of a method for recovering disk partition information according to an embodiment of the present application is Figure 2
[0019] Figure 2 is a flow chart of a method for recovering disk partition information according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of a hard disk partition information database backup model according to an embodiment of the present application;
[0021] Figure 4 is a flow chart of cluster hard disk partition information recording according to an embodiment of the present application;
[0022] Figure 5 It is a structural block diagram of a disk partition information recovery device according to an embodiment of the present application;
[0023] Figure 6 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0026] The disk partition information recovery method provided in the embodiments of the present application can be executed in a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 1 is a hardware structure block diagram of a computer terminal of a method for recovering disk partition information according to an embodiment of the present application. Figure 1 As shown, the computer terminal may include one or N ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned computer terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0027] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the task configuration method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or N magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0028] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0029] In this embodiment, a method for recovering disk partition information is provided, including but not limited to being applied in a computer terminal. Figure 2 is a flow chart of a method for recovering disk partition information according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps S202-S206:
[0030] Step S202: upon receiving the backup instruction sent by the target object, building a distributed cluster for maintaining disk partition information, and configuring a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, where N is an integer;
[0031] Optionally, the number of disks on each node in the above distributed cluster is less than one hundred, and the service information recorded on the disk occupies very little storage space in the disk swap database, which is convenient for synchronization and maintenance. In the cluster construction process, a database synchronization service is deployed for each node, and each node serves as the master node of its own disk swap database. At the same time, other nodes in the cluster are selected as backup nodes according to the screening rules to back up the disk swap database. If the cluster nodes are arranged according to the cabinet layout, the backup node selects a cabinet different from the master node to avoid the loss of disk swap data due to cabinet failure. After initializing MON, OSD, Elasticsearch and other services on the node's disk, the basic information of the disk (such as drive letter, slot, etc.) and the initialized service information are recorded in the disk swap database, and the database data is synchronized to the node that provides backup services for the node. Considering that the disk swap function is only used in the disk failure scenario, the disk swap data on the node and the backup node are not synchronized in real time to avoid consuming system resources. When the storage pool is expanded or reduced to change the location of the OSD, a new disk is inserted on the node to initialize the OSD service, and when the disk swap database on the node is updated, the database on the backup node is actively synchronized and updated. When a node needs to update the disk replacement database or replace a disk, if an abnormality is detected in the disk replacement database on the node, the node will actively pull the disk replacement data from the backup node before performing subsequent operations.
[0032] Step S204: using the backup node to store disk partition information of other distributed storage nodes in the distributed cluster except the backup node;
[0033] Step S206: When an abnormality occurs in any node among the other distributed storage nodes, the disk partition information of the arbitrary node is restored through the backup node.
[0034] Through the above steps, when the backup instruction sent by the target object is received, a distributed cluster for maintaining disk partition information is built, and a backup node is configured for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, N is an integer; the backup node is used to store the disk partition information of other distributed storage nodes of the distributed cluster except the backup node; when any node in the other distributed storage nodes is abnormal, the disk partition information of the arbitrary node is restored through the backup node. The above technical solution is adopted, and the hard disk partition information database data on the node is synchronized to the backup node through the master-slave mode, so that when the hard disk partition information database on the node is lost and cannot provide data, data can be pulled from the corresponding backup node, which solves the problems of complex disk return and replacement operations and poor user experience in the existing method, and effectively guarantees the availability of the hard disk partition information database, and effectively solves the current low efficiency of single point failure processing.
[0035] In an exemplary embodiment, upon receiving a backup instruction sent by a target object, a distributed cluster for maintaining disk partition information is built, including: upon determining that the backup instruction indicates to start a preset backup service, recording basic attributes of the disk partition information contained in the N distributed storage nodes according to a data structure corresponding to the preset backup service, wherein the data structure includes at least one of the following: node name, node address, cabinet to which the node belongs, backup node name list, backup threshold, backup failure time threshold, and disk data; determining the target backup information corresponding to each distributed storage node based on the recording results; and building a distributed cluster for maintaining disk partition information according to the target backup information.
[0036] In summary, through the above implementation, by recording basic attributes, each disk partition can be accurately recorded, so that after building a distributed cluster, the disk partition information can be quickly synchronized between the nodes in the cluster, and then the record backup information can be saved at the node granularity to facilitate subsequent node adjustments.
[0037] In an exemplary embodiment, configuring a backup node for the distributed cluster according to the screening rule includes: when the distributed storage nodes in the distributed cluster are on different cabinets, determining the target cabinet where the master node that currently needs to be backed up is located, setting the backup node in other cabinets except the target cabinet, and calculating the first weight value of the other cabinet as a backup node of the master node, wherein the master node is a node determined from the distributed storage nodes according to the identification information of the backup instruction; when the distributed storage nodes in the distributed cluster are on the same cabinet, setting the backup node and the master node in the same network segment, and calculating the second weight value corresponding to the number of routing hops for data intercommunication access between the backup node and the master node; when there are N backup nodes, In the case that each of the distributed storage nodes has been configured as a backup node, the target number of times that each of the distributed storage nodes is configured as a backup node is determined, the distributed storage node with the lowest target number is selected as the latest backup node, and the third weight value corresponding to the backup load of the latest backup node is calculated; the backup node weight value of each of the distributed storage nodes shown as the main node is comprehensively calculated based on the first weight value, the second weight value, the third weight value and the preset weight formula to obtain N target weight values; the N target weight values are sorted from large to small, and according to the backup threshold pre-set in the preset backup service; according to the allowed backup number corresponding to the backup threshold shown, the distributed storage nodes with the allowed backup number are screened out from the N target weight values as backup nodes.
[0038] Optionally, in actual application, the screening rules for the backup nodes of the hard disk partition information database may be as follows:
[0039] (1) When the nodes of the cluster are distributed on different cabinets, the backup nodes are selected from other cabinets first to avoid the problem of backup data loss when the cabinet fails when the master node and the backup node are in the same cabinet. The initial weight of this rule is weight 1. If the node and the master node are in the same cabinet, the weight value is reduced by percent 1.
[0040] (2) Backup nodes are preferred to be in the same network segment as the primary node, minimizing the number of routing hops for data communication between the primary and backup nodes. This rule accounts for weight 2 of the overall weight. For every additional hop between the node and the primary node, the weight value decreases by percent 2.
[0041] (3) Backup nodes are selected from nodes with fewer backup databases to avoid excessive imbalance in node backup load. This rule accounts for weight3 of the overall weight. For each additional backup database on a node, the weight value decreases by percentage3.
[0042] The initial weight values and corresponding reduction percentages involved in the above rules can be pre-set before cluster deployment. According to the above rules, the weight value of the node as the backup node of the master node is calculated, and the nodes are sorted from large to small according to the weight value. According to the backup threshold threshold in P2, the former thresho1d nodes are selected as backup nodes.
[0043] The weight calculation formula of a node as a backup node is as follows, where n represents the number of routing hops and m represents the number of backup databases on the node: weight = weight1*(1or(1-percent1))+weight2*(1or(1-percent2)n)+weight3*(1or(1-percent3)m);
[0044] In summary, through the above weight calculation, one or more distributed storage nodes that are most suitable as backup nodes can be accurately determined from multiple nodes, so that the backup service can be optimized and the overall stability of the distributed cluster is improved.
[0045] In an exemplary embodiment, when an abnormality occurs in any node among the other distributed storage nodes, before the disk partition information of the arbitrary node is restored through the backup node, the above method also includes: performing heartbeat monitoring on the backup node; recording the target duration of the backup node losing heartbeat monitoring; when the target duration is greater than the failure duration corresponding to the backup failure time threshold preset in the preset backup service, determining that the backup node has a failure and is down, and waiting to reselect a new backup node from the other distributed storage nodes; when the target duration is less than or equal to the failure duration corresponding to the backup failure time threshold preset in the preset backup service, determining that the backup node is in a failure recovery state.
[0046] Optionally, the database backup service on the node and the backup node uses a heartbeat mechanism for health detection. When the node cannot obtain a heartbeat return from the backup node, such as the backup node fails and goes down, if the backup node cannot be restored within the backup failure time threshold of 1 minute, the backup node is selected from the current cluster based on the screening rule that the backup node is prioritized from the nodes with fewer backup databases to avoid excessive imbalance in the node backup load, and a new node is automatically selected as the backup node for the node's hard disk partition information database.
[0047] In summary, through the above implementation, the faulty backup node can be monitored, so that the failure status and recovery status of the backup node can be effectively known, so that the backup node can be adjusted quickly, saving the processing time of the abnormal node.
[0048] In an exemplary embodiment, upon receiving a backup instruction sent by a target object, a distributed cluster for maintaining disk partition information is built, and after configuring backup nodes for the distributed cluster according to the screening rules, the method further includes: selecting at least three nodes from the distributed cluster, and using the at least three nodes to build a high-availability master control service; aggregating and monitoring the backup status of each node in the distributed cluster in real time through the high-availability master control service; and starting a cleanup operation on the at least one distributed storage node when the high-availability master control service determines that the target number of backup nodes corresponding to at least one distributed storage node in the distributed cluster is greater than the basic number corresponding to the backup threshold pre-set in the preset backup service.
[0049] In summary, by setting up a high-availability master service as described above, we can avoid unlimited growth of node backup data, thereby controlling the use of cluster node resources and avoiding meaningless resource consumption.
[0050] In an exemplary embodiment, after starting the cleanup operation on the at least one distributed storage node, the above method also includes: monitoring the cleanup result of the at least one distributed storage node; when the cleanup result indicates that the target number of backup nodes corresponding to the at least one distributed storage node is less than the basic number corresponding to the backup threshold pre-set in the preset backup service, determining that the cleanup operation is successfully executed, and updating the corresponding backup information of the at least one distributed storage node.
[0051] Optionally, the primary database synchronization service and backup service on each node use the heartbeat mechanism to monitor the health status of the backup service in real time. When some nodes in the cluster fail, or are removed from the cluster for high-risk operations, the backup service cannot maintain a heartbeat with the primary database service, and the primary database service randomly selects a new database backup node from the nodes that provide normal services in the cluster.
[0052] In an exemplary embodiment, after using the backup node to store the disk partition information of other distributed storage nodes in the distributed cluster except the backup node, the above method also includes: when there are at least two backup nodes at the same time, setting the current distributed storage node as the main library of the database corresponding to the disk partition information, and setting the backup node as the backup library of the database corresponding to the disk partition information; when the storage pool of the main library is expanded or reduced or a new physical disk is added to the current distributed storage node, updating the data of the main library and synchronously updating the data of the backup library.
[0053] In summary, through the above method, the node and the backup service node form a one-master-multiple-backup mode, and the hard disk partition information database on the node is the main database. When the storage pool is expanded or reduced to change the location of the OSD, and a new disk is inserted on the node to initialize the OSD service, when the hard disk partition information database on the node is updated, the database on the backup node is actively and synchronously updated. If the hard disk partition information database needs to be changed, when it is recognized that the database on the node is abnormal and cannot provide data, the hard disk partition information data is actively pulled from the backup node to the current node to prevent the hard disk partition information database from being lost and causing the operation to fail.
[0054] Obviously, the above-described embodiments are only embodiments of a part of the present invention, rather than all embodiments. In order to better understand the above method, the above process is described below in conjunction with embodiments, but it is not intended to limit the technical solutions of the embodiments of the present invention, specifically:
[0055] In an exemplary embodiment, a high availability method based on distributed cluster hard disk partition information recording is proposed. Through a reliable backup mechanism, the disk swap database data on the node is synchronously backed up to other nodes to avoid the disk swap database on the node being lost and unable to recover by itself, resulting in blocking the disk swap function on the node. In this way, the high availability of cluster hard disk partition and service information is achieved, and further, the occurrence of abnormal loss scenarios of the disk return and replacement database on the node is reduced, so that the disk swap database can be recovered by itself without blocking the disk return and replacement operation.
[0056] Optionally, the above method is mainly used in large-scale distributed cluster deployment application environments.
[0057] As an optional implementation, the high availability method for recording the distributed cluster hard disk partition information includes the following contents:
[0058] Optionally, a database backup service is provided for recording hard disk partition information. The data structure of the backup service is shown in Table 1, including the node name node_name of the node where the database is located, the node address node_ip, the cabinet rack to which the node belongs, the backup node name list backup_nodes, the backup threshold threshold, the backup fault time threshold fault_time_threshold, the hard disk data disk_db_data and other basic attributes; in order to avoid the problem of backup information loss due to node failure, the data information of the backup service is synchronized to other nodes in the cluster, and the backup information is saved and recorded at the node granularity.
[0059] Table 1
[0060]
[0061] Step 2. During the cluster construction process, after initializing MON, OSD, Elasticsearch and other services on the disk of each node, record the basic information of the disk (such as drive letter, slot, etc.) and the initialized service information into the hard disk partition information database; at the same time, initialize the hard disk partition information database backup service for each node, and configure the basic data of the backup service, where the default value of the backup threshold threshold is 2, and the default value of the backup fault time threshold fault_time_threshold is 60s. According to the backup threshold number and the backup node screening rules, select the database backup node from the cluster; then, synchronize the node hard disk partition information database data to the node that provides backup services for the node.
[0062] Optional, Figure 3 It is a schematic diagram of a hard disk partition information database backup model according to an embodiment of the present application.
[0063] Step 3. The screening rules for the backup nodes of the hard disk partition information database are as follows:
[0064] 1) When the nodes of the cluster are distributed on different cabinets, the backup nodes are selected from other cabinets first to avoid the problem of backup data loss when the cabinet fails when the master node and the backup node are in the same cabinet. The initial weight of this rule is weight1. If the node and the master node are in the same cabinet, the weight value is reduced by percent1.
[0065] 2) Backup nodes are preferred to be in the same network segment as the primary node, minimizing the number of routing hops for data communication between the primary and backup nodes. This rule accounts for weight2 of the overall weight, and the weight value decreases by percent2 for every additional hop between the node and the primary node.
[0066] 3) Backup nodes are selected from nodes with fewer backup databases to avoid excessive imbalance in node backup load. This rule accounts for weight3 of the overall weight. For each additional backup database a node has, the weight value decreases by percent3.
[0067] The initialization weight values and corresponding reduction percentages involved in the above rules can be pre-set before cluster deployment. According to the above rules, the weight value of the node as the backup node of the master node is calculated, and the nodes are sorted from large to small according to the weight value. According to the backup threshold threshold in P2, the former threshold node is selected as the backup node.
[0068] Step 4. The database backup service on the node and the backup node uses the heartbeat mechanism for health detection. When the node cannot obtain the heartbeat return from the backup node, such as the backup node fails and goes down, if the backup node cannot be restored within the backup failure time threshold of 1 minute, a new node is automatically selected from the current cluster as the backup node of the node's hard disk partition information database according to the screening rules described in step 3.
[0069] Step 5. The node and the backup service node form a one-master-multiple-backup mode, with the hard disk partition information database on the node as the master database. When the storage pool is expanded or reduced to change the location of the OSD, or when a new disk is inserted on the node to initialize the OSD service, the hard disk partition information database on the node is updated, and the database on the backup node is actively and synchronously updated. If the hard disk partition information database needs to be changed, and it is identified that the database on the node is abnormal and cannot provide data, the hard disk partition information data is actively pulled from the backup node to the local node to prevent the hard disk partition information database from being lost and causing the operation to fail.
[0070] Step 6. When the database backup node is removed from the cluster and the number of database backup nodes of the node is lower than the backup threshold, a new node is automatically selected from the current cluster as the backup node of the node's hard disk partition information database according to the screening rules described in step 3.
[0071] Step 7. When a new node joins the cluster, the hard disk database backup mechanism of the node is consistent with the current cluster. From the current cluster, according to the screening rules described in step 3, a backup node is selected to back up the hard disk partition information database; correspondingly, when a node is removed from the cluster, the database backup service of the node in the cluster is removed synchronously.
[0072] Step 8. In the cluster, select at least three nodes to build a high-availability master service, which is responsible for real-time aggregation and monitoring of the backup information of each node. When it is detected that the number of backup nodes of a node nodex exceeds the backup threshold threshold, the backup database of node nodex will be cleaned up on the node with more backups, and the backup information of node node× will be updated synchronously to avoid unlimited increase of node backup data, so as to control the use of cluster node resources and avoid meaningless resource consumption.
[0073] As an optional implementation, Figure 4 The present invention is a flow chart of cluster hard disk partition information recording according to an embodiment of the present application; the flow chart includes the following steps:
[0074] Step S402: Determine to perform cluster deployment;
[0075] Step S404, determining the hard disk partition information record table;
[0076] Step S406: Filter the backup nodes according to the filtering rules;
[0077] Step S408, the hard disk information is synchronized to the backup node;
[0078] Step S410, backup service records backup information;
[0079] Step S412: If it is determined that the storage pool is to be expanded, the hard disk partition information is updated and stored in the database, and the data on the backup node is updated synchronously; if it is determined that the storage pool is not to be expanded, the process ends.
[0080] Step S414: If the heartbeat detection is normal, the detection is terminated; if the heartbeat detection is abnormal, a new backup node is automatically selected;
[0081] Step S416: When it is determined that the node is to be shrunk, the database backup service of the node in the cluster is synchronously removed; when it is determined that the node is not to be shrunk, the process ends.
[0082] Step S418: If the backup node is downsized and the number of backup nodes is lower than the backup threshold, determine to select a new node as the backup node of the node's hard disk partition information database; if the above situation does not occur, end the process.
[0083] It should be noted that, through the establishment of the hard disk partition information database backup service, it is responsible for maintaining the hard disk partition information database of the cluster node, adopting a one-master-multiple-standby mode, and selecting the backup node according to the backup node screening rules of this solution. When the master node cannot provide data services, it is pulled from the backup node to avoid single node failure. The heartbeat mechanism is used between the database backup service on the node and the backup node for health check. When the backup node fails, a new backup node is selected from the current cluster in time. When the database backup node is scaled out from the cluster and the number of database backup nodes of the node is lower than the backup threshold, a new node is automatically selected from the current cluster as the backup node of the hard disk partition information database of the node according to the screening rules of this solution. When the hard disk partition information of the master node changes, the database on the backup node is actively and synchronously updated. If the master node is scaled out from the cluster, the backup database on all backup nodes of the node is cleaned up synchronously. A high-availability master control service is established to be responsible for real-time aggregation and monitoring of the backup information of each node, and timely clean up redundant backup databases to avoid meaningless consumption of resources.
[0084] Through the above implementation method, in a large-scale distributed cluster application environment, a high-availability solution is used to deploy the hard disk partition information database backup function, and the hard disk partition information database data on the node is synchronized to the standby node. When the hard disk partition information database on the node changes and is actively synchronized to the standby node, if the hard disk partition information database on the node cannot provide relevant data due to an abnormality, data can be pulled from the corresponding backup node to ensure the normal operation of related services. The database backup service on the node and the standby node uses a heartbeat mechanism for health checks. When the standby node fails, a new backup node is selected from the current cluster in a timely manner. The implementation of this high-availability solution can effectively ensure the availability of the hard disk partition information database and effectively solve the current single point failure problem.
[0085] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0086] In the present embodiment, a recovery device for disk partition information is also provided, which is used to implement the above-mentioned embodiment and preferred implementation mode, and the descriptions which have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the modules described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0087] Figure 5 is a structural block diagram of a disk partition information recovery device according to an embodiment of the present application, such as Figure 5 As shown, the device comprises:
[0088] A building module 52 is used to build a distributed cluster for maintaining disk partition information when receiving a backup instruction sent by a target object, and configure a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, where N is an integer;
[0089] The storage module 54 is used to use the backup node to store the disk partition information of other distributed storage nodes in the distributed cluster except the backup node;
[0090] The recovery module 56 is used to restore the disk partition information of any node through the backup node when an abnormality occurs to any node among the other distributed storage nodes.
[0091] The above device, upon receiving the backup instruction sent by the target object, builds a distributed cluster for maintaining disk partition information, and configures a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, N is an integer; the backup node is used to store the disk partition information of other distributed storage nodes in the distributed cluster except the backup node; in the event of an abnormality in any of the other distributed storage nodes, the disk partition information of the arbitrary node is restored through the backup node. The above technical solution is adopted to synchronize the hard disk partition information database data on the node to the backup node through the master-slave mode, so that when the hard disk partition information database on the node is lost and cannot provide data, data can be pulled from the corresponding backup node, which solves the problems of complex disk return and replacement operations and poor user experience in the existing method, effectively guarantees the availability of the hard disk partition information database, and effectively solves the current low efficiency of single point failure processing.
[0092] In an exemplary embodiment, the above-mentioned construction module is also used to record the basic attributes of the disk partition information contained in the N distributed storage nodes according to the data structure corresponding to the preset backup service when it is determined that the backup instruction indicates to start the preset backup service, wherein the data structure includes at least one of the following: node name, node address, the cabinet to which the node belongs, backup node name list, backup threshold, backup failure time threshold, disk data; determine the target backup information corresponding to each distributed storage node based on the recording results; and build a distributed cluster for maintaining disk partition information according to the target backup information.
[0093] In an exemplary embodiment, the above-mentioned building module is also used to determine the target cabinet where the main node that currently needs to be backed up is located when each distributed storage node in the distributed cluster is on a different cabinet, set the backup node in other cabinets except the target cabinet, and calculate the first weight value of the other cabinet as the backup node of the main node, wherein the main node is a node determined from the distributed storage nodes according to the identification information of the backup instruction; when each distributed storage node in the distributed cluster is on the same cabinet, set the backup node and the main node in the same network segment, and calculate the second weight value corresponding to the number of routing hops for data intercommunication access between the backup node and the main node; when there are N backup nodes and each distributed storage When all storage nodes have been configured as backup nodes, determine the target number of times that each distributed storage node is configured as a backup node, select the distributed storage node with the lowest target number as the latest backup node, and calculate the third weight value corresponding to the backup load of the latest backup node; comprehensively calculate the backup node weight value of each distributed storage node as the main node in the shown distributed storage nodes based on the first weight value, the second weight value, the third weight value and the preset weight formula to obtain N target weight values; sort the N target weight values from large to small, and according to the backup threshold pre-set in the preset backup service; according to the allowed backup number corresponding to the shown backup threshold, filter out the distributed storage nodes with the allowed backup number from the N target weight values as backup nodes.
[0094] In an exemplary embodiment, the above-mentioned device also includes: a monitoring module, which is used to perform heartbeat monitoring on the backup node before restoring the disk partition information of the backup node through the backup node when an abnormality occurs in any node among the other distributed storage nodes; record the target duration of the backup node losing heartbeat monitoring; when the target duration is greater than the failure duration corresponding to the backup failure time threshold pre-set in the preset backup service, determine that the backup node has a failure and is down, and wait to re-select a new backup node from the other distributed storage nodes; when the target duration is less than or equal to the failure duration corresponding to the backup failure time threshold pre-set in the preset backup service, determine that the backup node is in a failure recovery state.
[0095] In an exemplary embodiment, the above-mentioned device also includes: a cleaning module, which is used to build a distributed cluster for maintaining disk partition information when receiving a backup instruction sent by the target object, and after configuring a backup node for the distributed cluster according to the screening rule, select at least three nodes from the distributed cluster, and use the at least three nodes to build a high-availability master service; summarize and monitor the backup status of each node in the distributed cluster in real time through the high-availability master service; when the high-availability master service determines that the target number of backup nodes corresponding to at least one distributed storage node in the distributed cluster is greater than the basic number corresponding to the backup threshold pre-set in the preset backup service, start a cleaning operation on the at least one distributed storage node.
[0096] In an exemplary embodiment, the above-mentioned cleaning module also includes an updating unit, which is used to monitor the cleaning result of the at least one distributed storage node after starting the cleaning operation on the at least one distributed storage node; when the cleaning result indicates that the target number of backup nodes corresponding to the at least one distributed storage node is less than the basic number corresponding to the backup threshold pre-set in the preset backup service, it is determined that the cleaning operation is successfully executed and the corresponding backup information of the at least one distributed storage node is updated.
[0097] In an exemplary embodiment, the above-mentioned device also includes: an update module, which is used to use the backup node to store the disk partition information of other distributed storage nodes in the distributed cluster except the backup node. When there are at least two backup nodes at the same time, the current distributed storage node is set as the main library of the database corresponding to the disk partition information, and the backup node is set as the backup library of the database corresponding to the disk partition information; when the storage pool of the main library is expanded or reduced or a new physical disk is added to the current distributed storage node, the data of the main library is updated, and the data of the backup library is synchronously updated.
[0098] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0099] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0100] Optionally, in this embodiment, the computer program may be configured to perform the following steps by means of the computer program:
[0101] S1, upon receiving a backup instruction sent by a target object, building a distributed cluster for maintaining disk partition information, and configuring a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, where N is an integer;
[0102] S2, using the backup node to store the disk partition information of other distributed storage nodes in the distributed cluster except the backup node;
[0103] S3, when any node among the other distributed storage nodes is abnormal, the disk partition information of the any node is restored through the backup node.
[0104] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile disk, a magnetic disk or an optical disk.
[0105] The embodiment of the present application also provides an electronic device, such as Figure 6 As shown, the electronic device includes a memory 502 and a processor 504. The memory 502 stores a computer program, and the processor 504 is configured to execute the steps in any of the above method embodiments through the computer program.
[0106] Optionally, in this embodiment, the processor 504 may be configured to perform the following steps through a computer program:
[0107] S1, upon receiving a backup instruction sent by a target object, building a distributed cluster for maintaining disk partition information, and configuring a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, where N is an integer;
[0108] S2, using the backup node to store the disk partition information of other distributed storage nodes in the distributed cluster except the backup node;
[0109] S3, when any node among the other distributed storage nodes is abnormal, the disk partition information of the any node is restored through the backup node.
[0110] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0111] Alternatively, a person skilled in the art may understand that: Figure 6 The structure shown is for illustration only. Figure 6 The structure of the electronic device is not limited. For example, the electronic device may also include Figure 6 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 6 Different configurations are shown.
[0112] Among them, the memory 502 can be used to store software programs and modules, such as the program instructions / modules corresponding to the disk partition information recovery method and device in the embodiment of the present application. The processor 504 executes various functional applications and data processing by running the software programs and modules stored in the memory 502, that is, realizing the above-mentioned disk partition information recovery method. The memory 502 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or N magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 502 may further include a memory remotely arranged relative to the processor 504, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 502 can be specifically, but not limited to, used to store information such as system configuration files. As an example, such as Figure 6 As shown, the memory 502 may include but is not limited to all modules in the above-mentioned disk partition information recovery device. In addition, it may also include but is not limited to other module units in the above-mentioned disk partition information recovery device, which will not be repeated in this example.
[0113] Optionally, the transmission device 506 is used to receive or send data via a network. Specific examples of the network may include wired networks and wireless networks. In one example, the transmission device 506 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 506 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0114] In addition, the electronic device mentioned above further includes: a display 508; and a connection bus 510, which is used to connect various module components in the electronic device mentioned above.
[0115] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0116] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0117] The embodiments of the present application also provide a computer program, which includes computer instructions stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any one of the above method embodiments.
[0118] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of N computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that here, or they can be made into individual integrated circuit modules, or N of the modules or steps can be made into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.
[0119] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for recovering disk partition information, characterized in that: include: In the case of receiving the backup instruction sent by the target object, building a distributed cluster for maintaining disk partition information, and configuring a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, where N is an integer; Using the backup node to store disk partition information of other distributed storage nodes in the distributed cluster except the backup node; When an abnormality occurs to any node in the other distributed storage nodes, the disk partition information of the arbitrary node is restored through the backup node.
2. The method according to claim 1, characterized in that When receiving the backup instruction sent by the target object, a distributed cluster for maintaining disk partition information is built, including: In the case where it is determined that the backup instruction indicates to start the preset backup service, basic attributes of the disk partition information contained in the N distributed storage nodes are recorded according to the data structure corresponding to the preset backup service, wherein the data structure includes at least one of the following: node name, node address, cabinet to which the node belongs, backup node name list, backup threshold, backup failure time threshold, and disk data; Determine the target backup information corresponding to each distributed storage node based on the recorded results; A distributed cluster for maintaining disk partition information is constructed according to the target backup information.
3. The method according to claim 1, characterized in that Configuring a backup node for the distributed cluster according to the screening rule includes: In the case where the distributed storage nodes in the distributed cluster are located in different cabinets, determining the target cabinet where the master node currently to be backed up is located, setting the backup node in other cabinets except the target cabinet, and calculating the first weight value of the other cabinet as the backup node of the master node, wherein the master node is a node determined from the distributed storage nodes according to the identification information of the backup instruction; When the distributed storage nodes in the distributed cluster are on the same cabinet, the backup node and the master node are set in the same network segment, and a second weight value corresponding to the number of routing hops for data intercommunication access between the backup node and the master node is calculated; In the case where there are N backup nodes and each of the distributed storage nodes has been configured as a backup node, determine a target number of times that each of the distributed storage nodes is configured as a backup node, select the distributed storage node with the lowest target number as the latest backup node, and calculate a third weight value corresponding to the backup load of the latest backup node; Comprehensively calculate the weight value of each distributed storage node as a backup node of the master node in each distributed storage node shown based on the first weight value, the second weight value, the third weight value and a preset weight formula to obtain N target weight values; Sort the N target weight values from large to small, and use the backup thresholds pre-set in the preset backup service; According to the allowed backup quantity corresponding to the backup threshold, the distributed storage nodes with the allowed backup quantity are selected from the N target weight values as backup nodes.
4. The method according to claim 1, characterized in that: In the case that any node among the other distributed storage nodes is abnormal, before the backup node restores the disk partition information of the any node, the method further includes: Performing heartbeat monitoring on the backup node; Record the target duration of the backup node losing heartbeat monitoring; When the target duration is greater than the fault duration corresponding to the backup fault time threshold preset in the preset backup service, it is determined that the backup node has a fault and is down, and a new backup node is to be selected from the other distributed storage nodes; When the target duration is less than or equal to the failure duration corresponding to the backup failure time threshold preset in the preset backup service, it is determined that the backup node is in a failure recovery state.
5. The method according to claim 1, characterized in that In the case of receiving the backup instruction sent by the target object, after building a distributed cluster for maintaining disk partition information and configuring a backup node for the distributed cluster according to the screening rule, the method further includes: Select at least three nodes from the distributed cluster, and use the at least three nodes to build a high-availability master control service; The backup status of each node in the distributed cluster is summarized and monitored in real time by the high-availability master control service; When the high-availability master service determines that the target number of backup nodes corresponding to at least one distributed storage node in the distributed cluster is greater than the basic number corresponding to the backup threshold pre-set in the preset backup service, a cleanup operation on the at least one distributed storage node is started.
6. The method according to claim 5, characterized in that After starting the cleanup operation on the at least one distributed storage node, the method further includes: Monitoring the cleaning result of the at least one distributed storage node; When the cleaning result indicates that the target number of backup nodes corresponding to the at least one distributed storage node is less than the basic number corresponding to the backup threshold pre-set in the preset backup service, it is determined that the cleaning operation is successfully executed and the corresponding backup information of the at least one distributed storage node is updated.
7. The method according to claim 1, characterized in that After using the backup node to store the disk partition information of other distributed storage nodes in the distributed cluster except the backup node, the method further includes: When there are at least two backup nodes at the same time, the current distributed storage node is set as the main library of the database corresponding to the disk partition information, and the backup node is set as the standby library of the database corresponding to the disk partition information; When the storage pool of the primary library is expanded or reduced or a new physical disk is added to the current distributed storage node, the data of the primary library is updated, and the data of the standby library is updated synchronously.
8. A disk partition information recovery device, characterized in that: include: A building module, used for building a distributed cluster for maintaining disk partition information when receiving a backup instruction sent by a target object, and configuring a backup node for the distributed cluster according to the screening rule, wherein the distributed cluster includes: N distributed storage nodes, where N is an integer; A storage module, used to use the backup node to store disk partition information of other distributed storage nodes in the distributed cluster except the backup node; The recovery module is used to restore the disk partition information of any node through the backup node when an abnormality occurs to any node among the other distributed storage nodes.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.
