Database Cluster Scaling Method, Service System, Storage Medium

By automatically obtaining the operating indicators and resource utilization rate of the database cluster, the automatic scaling of the database cluster is solved, and the problem of manual participation in the existing technology is solved, and efficiency and accuracy are improved.

CN114328440BActive Publication Date: 2025-07-01ZTE CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011049631.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-29
Publication Date
2025-07-01
Estimated Expiration
2040-09-29

AI Technical Summary

Technical Problem

The prior art realizes database cluster expansion by receiving external requests, requiring manual participation and wasting human resources.

Method used

By obtaining the detection values ​​of the operating indicators of each database in the database cluster, the resource utilization rate of the database cluster is calculated. If the preset expansion and expansion conditions are met, the expansion and expansion will be performed automatically.

Benefits of technology

It realizes automatic scaling of the dynamic database cluster, saves human resources, and has more accurate analysis results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114328440B_ABST
    Figure CN114328440B_ABST
Patent Text Reader

Abstract

Embodiments of the present invention relate to the field of information technology, and disclose a method for expanding and contracting a database cluster, a service system, and a storage medium. In the present invention, detection values of operation metrics of each database in the database cluster are obtained; according to the detection values of the operation metrics of each database, the resource utilization rate of the database cluster is obtained; if the resource utilization rate of the database cluster meets a preset expansion and contraction condition, the database cluster is expanded and contracted. By comprehensively analyzing the detection values of the operation metrics, the analysis result is more accurate, and the dynamic expansion and contraction of the database cluster can be automatically realized, saving human resources and achieving the purpose of intelligence and automation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of information technology, and particularly to a method for expanding and contracting a database cluster, a service system, and a storage medium. Background Art

[0002] A database cluster is a technology that encapsulates a series of database servers in a cluster manner and provides data services externally in a unified way. By combining technologies such as database sharding, read-write separation, data balancing, and master-slave synchronization, the read-write access bottleneck of a single database node is solved. When situations such as insufficient disk space of the servers where the databases in the database cluster are located or the concurrency of read-write requests exceeding the limit that the database cluster can bear occur, the database cluster will be expanded or contracted. In related technologies, the expansion and contraction of the database cluster are achieved by receiving external requests.

[0003] However, the inventors found that the related technologies have the following problems: Implementing the expansion and contraction of the database cluster by receiving external requests requires manual participation, wasting human resources. Summary of the Invention

[0004] The main purpose of the embodiments of the present application is to propose a method for expanding and contracting a database cluster, a service system, and a storage medium, which can automatically realize the dynamic expansion and contraction of the database cluster and analyze using operation metrics to more accurately obtain the timing of expanding and contracting the database.

[0005] To achieve the above object, the embodiments of the present application provide a method for expanding and contracting a database cluster, including: obtaining the detected values of the operation metrics of each database in the database cluster; obtaining the resource utilization rate of the database cluster according to the detected values of the operation metrics of each database; if the resource utilization rate of the database cluster meets the preset expansion and contraction conditions, expanding or contracting the database cluster.

[0006] To achieve the above object, the embodiments of the present application further provide a service system, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above method for expanding and contracting a database cluster.

[0007] To achieve the above object, the embodiments of the present application further provide a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above method for expanding and contracting a database cluster is implemented.

[0008] The method, service system, and storage medium for scaling a database cluster proposed in this application obtain the detected values of the operating metrics of each database in the database cluster; based on the detected values of the operating metrics of each database, obtain the resource utilization rate of the database cluster; if the resource utilization rate of the database cluster meets the preset scaling conditions, scale the database cluster. The embodiments of this application can automatically implement dynamic scaling of the database cluster, save human resources, and achieve the purpose of intelligent and automated scaling of the database cluster. In addition, by comprehensively analyzing the detected values of the operating metrics, the operating conditions of the database cluster are obtained, making the analysis results more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Figure 1 is a schematic diagram of a system according to the first embodiment of the present invention;

[0010] Figure 2 is a flowchart of a method for scaling a database cluster according to the first embodiment of the present invention;

[0011] Figure 3 is a flowchart of sub-steps of a method for scaling a database cluster according to the first embodiment of the present invention;

[0012] Figure 4 is a flowchart of a method for scaling a database cluster according to the second embodiment of the present invention;

[0013] Figure 5 is a flowchart of a method for scaling a database cluster according to the third embodiment of the present invention;

[0014] Figure 6 is a schematic structural diagram of a service system according to the fourth embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0015] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the following will elaborate on each embodiment of this application in conjunction with the accompanying drawings. However, those of ordinary skill in the art can understand that in each embodiment of this application, many technical details are presented to help readers better understand this application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in this application can still be implemented. The division of the following embodiments is for convenience of description and should not constitute any limitation to the specific implementation of this application. The embodiments can be combined and cross-referenced with each other on the premise of not being contradictory.

[0016] For simplicity of description, the Chinese and abbreviated counterparts of the parameters and the like used in the embodiments of the present invention are shown in Table 1 as follows.

[0017] Table 1

[0018]

[0019]

[0020] The first embodiment of the present invention relates to a method for scaling a database cluster. The method includes: obtaining detection values of operation metrics of each database in the database cluster; obtaining the resource utilization rate of the database cluster according to the detection values of the operation metrics of each database; and scaling the database cluster if the resource utilization rate of the database cluster meets a preset scaling condition. This embodiment can automatically implement dynamic scaling of the database cluster, and by analyzing the detection values of the operation metrics of the database, the operation status of each database in the database cluster can be obtained, making the analysis result more accurate.

[0021] This embodiment can be applied to a system including multiple servers, but is not limited thereto.

[0022] For example, in a system as Figure 1 shown, the system can implement database scaling. There can be different database applications, as well as a database resource monitoring module and a database resource pool in the system. In the database resource monitoring module, there are a resource cycle acquisition module, a database resource scaling-down module, a database resource scaling-up module, and a cluster analysis module. The database resource monitoring module monitors the database resource pool to determine whether scaling is required.

[0023] When the resource cycle acquisition module starts, it parses the scaling parameters configured by the user, loads the scaling parameters into memory, obtains the parameter values defined by the database metric acquisition cycle, periodically obtains the operation metrics of each database, and submits the data detected each time to the cluster statistical analysis module; the cluster statistical analysis module periodically analyzes and statistically analyzes the operation metrics of all databases in the cluster in the current cycle according to the operation metrics obtained by the configured cluster metric statistical cycle; the cluster statistical analysis module normalizes the statistical information in each cycle to obtain a rate-normalized index of cluster resource utilization, and determines whether scaling is required. If scaling up is required, it notifies the database resource scaling-up module to scale up the database resources. If scaling down is required, it notifies the database resource scaling-down module to scale down the resources, and returns the idle resources after scaling down to the resource pool.

[0024] Optionally, the scaling parameters include the database threshold value, the cluster threshold value, the index impact factor, the detection cycle parameter, the database initialization method, and the database cleaning method listed in Table 1.

[0025] The implementation details of the database cluster scaling conversion method of the first embodiment of the present invention will be specifically described below. The following content is only provided for easy understanding of the implementation details and is not necessary for implementing the solution.

[0026] The flowchart of the first embodiment of the present invention is as Figure 2 shown.

[0027] Step 201: Obtain the detected values of the operation metrics of each database in the database cluster.

[0028] In one example, according to a preset detection period, the detected values of the operation metrics of each database in the database cluster are obtained periodically.

[0029] In one example, the operation metric is one of the following metrics: CPU utilization rate DCU, memory utilization rate DMU, disk utilization rate DDU, structure table quantity overrun rate DSNU, and structure form single table record quantity overrun rate DTRU.

[0030] In one example, when the operation metric is the CPU utilization rate, or the memory utilization rate, or the disk utilization rate, the obtaining of the detected values of the operation metrics of each database in the database cluster specifically means collecting the detected values of the operation metrics of each database, DCU, or DMU, or DDU; when the operation metric is the structure table quantity overrun rate, collecting the quantity of structure tables of each database, and calculating the structure table quantity overrun rate of each database according to a preset structure table quantity threshold value; when the operation metric is the structure form single table record quantity overrun rate, collecting the quantity of structure form single table records of each database, and calculating the structure form single table record quantity overrun rate of each database according to a preset structure form single table record quantity threshold value.

[0031] Taking the example that the operation metrics are obtained N times and the database cluster manages a total of K databases.

[0032] When the operation metric is the structure table quantity overrun rate, calculate the quantity exceeding the database structure table quantity threshold according to the quantity of structure tables in a single database obtained each time. The calculation method is: if the quantity of the current table structure exceeds the database table structure quantity threshold value DSNT, then subtract the database table structure quantity threshold DSNT from the current quantity to obtain the current overrun table structure quantity, and divide the overrun quantity by the database table structure quantity threshold to obtain the current database structure table quantity overrun rate DSNU.

[0033] When the operation metric is the structure form single table record quantity overrun rate, first calculate the quantity of table structures exceeding the table record threshold according to the record quantity of each table in a single database obtained each time. The calculation method is: if the quantity of the current table has exceeded the database single table record quantity threshold, then count and accumulate to obtain the quantity of tables in the database exceeding the threshold. Secondly, divide the overrun table quantity obtained in the first step by the total quantity of all tables in the database to obtain the current database structure form single table record quantity overrun rate DTRU.

[0034] Step 202: Obtain the resource utilization rate of the database cluster according to the detected values of the operation metrics of each database.

[0035] In one example, obtain the resource utilization rate of the database cluster according to the detected values of the operation metrics of each database obtained within a number of the detection periods.

[0036] Sub-step 301: Calculate the statistical value of the operation metric of the database according to the detected values of the same operation metric of the same database obtained within a number of the detection periods.

[0037] Continuing with the above example, taking the statistical value as the mean, and assuming that the operation metric is obtained N times and the cluster manages a total of K databases.

[0038] When the operation metric is the CPU utilization rate, calculate the average CPU utilization rate SCLB of a single database within the preset detection period as SCLB = (DCU1 + DCU2 +... + DCU N ), and in this way, obtain the average CPU utilization rates SCLB1, SCLB2... SCLBK of the K databases.

[0039] When the operation metric is the memory utilization rate, calculate the average memory utilization rate SCMB of a single database within the period as SCMB = (DMU1 + DMU2 +... + DMU N ), and in this way, obtain the average memory utilization rates SCMB1, SCMB2... SCMB K .

[0040] When the operation metric is the disk utilization rate, calculate the average disk utilization rate SDLB of a single database within the period as SDLB = (DDU1 + DDU2 +... + DDU N ), and in this way, obtain the average disk utilization rates SDLB1, SDLB2…SDLBK of the K databases.

[0041] When the operation metric is the overrun rate of the structure table quantity, assuming that there are M overruns in N collections, then the average overrun rate SSNU of this database is SSNU = (DSNU1 + DSNU2 +... + DSNU M ) / N.

[0042] When the operation metric is the overrun rate of the single-table record quantity of the structure form, calculate the average overrun rate STRU of the single-table record quantity of the structure form of a single database within the period as STRU = (DTRU1 + DTRU2 +... + DTRU N ) / N.

[0043] Sub-step 302: Calculate the statistical value of the operation metric of the database cluster according to the statistical values of the operation metrics of each database.

[0044] Continuing with the above example, when the running metric is CPU utilization, the average CPU utilization of the computing cluster CCLB = (SCLB1 + SCLB2 +... + SCLB K ) / K; when the running metric is memory utilization, the average memory utilization of the cluster CMLB = (SCMB1 + SCMB2 +... + SCMB K ) / K; when the running metric is disk usage, the average disk usage of the cluster CDLB = (SDLB1 + SDLB2 +... + SDLB K ) / K; when the running metric is the over - limit rate of the number of structure tables, the average over - limit rate of the database structure tables of the cluster CSNU = (SSNU1 + SSNU2 +... + SSNU K ) / K; when the running metric is the over - limit rate of the number of records in a single structure table, the average over - limit rate of the number of records in the database tables of the cluster CTRU = (STRU1 + STRU1 +... + STRUK) / K.

[0045] Sub - step 303: Normalize the statistical values of the running metrics of each database cluster, and take the sum of the normalized statistical values of the running metrics of the database cluster as the resource utilization rate of the database cluster.

[0046] In an example, calculate the normalized index cluster resource utilization rate CRR in the current period. The calculation method is: CRR = CCLB * CCIF + CMLB * CMIF + CDLB * CDIF + CSNU * CSNIF + CTRU * CTRIF.

[0047] Step 203: If the resource utilization rate of the database cluster meets the preset scaling conditions, perform scaling on the database cluster.

[0048] In an example, if CRR is greater than the upper normalized limit CBNU for cluster scaling configured by the user, it is considered that expansion is required; if CRR is less than the lower normalized limit CBND for cluster scaling configured by the user, it is considered that contraction is required.

[0049] The first embodiment of the present invention relates to a method for scaling a database cluster. The method includes: obtaining the detection values of the running metrics of each database in the database cluster; obtaining the resource utilization rate of the database cluster according to the detection values of the running metrics of each database; if the resource utilization rate of the database cluster meets the preset scaling conditions, perform scaling on the database cluster. This embodiment can automatically implement dynamic scaling of the database cluster, and by analyzing the detection values of the running metrics of the database, the running status of each database in the database cluster can be obtained, making the analysis result more accurate.

[0050] The second embodiment of the present invention relates to a method for scaling a database cluster up or down. The flowchart of the second embodiment of the present invention is as follows Figure 2 shown

[0051] Step 401: Obtain the detected values of the running metrics of each database in the database cluster.

[0052] Step 402: Obtain the resource utilization rate of the database cluster according to the detected values of the running metrics of each database.

[0053] Steps 401 to 402 are substantially the same as steps 201 to 202 of the first embodiment. To avoid repetition in expression, they will not be elaborated here.

[0054] Step 403: If the resource utilization rate of the database cluster meets the expansion condition in the scaling-up or scaling-down condition, obtain the database configuration information according to the pre-obtained source mode of the database configuration information.

[0055] In one example, the source mode of the database configuration information includes at least one of the following: obtaining from at least one database in the database cluster, obtaining from a local storage module, and obtaining from a remote device.

[0056] Exemplarily, the source mode of the database configuration information is to obtain from at least one database in the database cluster, that is, copy the existing tenant database information, obtain the source database addressing rules configured by the user, find any source database information that meets the rules, and load the configuration information such as memory, CPU, disk configuration, master-slave strategy, backup strategy, and disaster recovery strategy into the configuration list. Secondly, obtain the database information, such as index information, database schema information, database table structure information, etc., and generate relevant scripts respectively, and put them into the script list.

[0057] Exemplarily, the source mode of the database configuration information is from the local storage module, that is, obtain the local configuration file, directly load the configuration information in the local file into the configuration list, and load the script for initializing the database into the script list.

[0058] Exemplarily, the source mode of the database configuration information is to obtain from a remote device, that is, obtain the remote configuration file, download the remote configuration file to the local, and then load the configuration information in the file downloaded to the local into the configuration list, and load the script for initializing the database into the script list.

[0059] Optionally, when downloading the file, a streaming mode can be selected to directly load the content of the remote file into the memory without downloading it to the local file, reducing the I / O of the local disk.

[0060] Step 404: Configure the new database of the database cluster according to the database configuration information.

[0061] In one example, the database configuration information includes first information representing the hardware performance of the database, second information representing the data processing strategy, and third information representing the database architecture; apply for a new database from the database resource pool according to the first information; initialize the new database using the third information; set the initialized new database using the second information, and use the successfully set new database as the new database of the database cluster.

[0062] Exemplarily, apply for a new database from the database resource pool according to the first information, that is, apply for database resources such as memory resources, CPU resources, and disk resources from the cluster resource pool according to the first information in the obtained configuration list. If the resources cannot be obtained, give up this expansion; initialize the new database using the third information, that is, initialize the newly applied database according to the obtained database initialization script. If the database initialization fails, it is considered that the expansion fails, and the applied resources are cleaned up and returned to the resource pool; set the initialized new database using the second information, and use the successfully set new database as the new database of the database cluster, that is, set database-related database policies such as the master-slave policy, backup policy, and disaster recovery policy, etc.; if the database policy setting fails, it is considered that the expansion fails, and the applied resources are cleaned up and returned to the resource pool.

[0063] The following uses an example to illustrate the expansion of the database cluster.

[0064] During initialization, the resource cycle collection module parses the configuration data of the current user, and the obtained parameter configuration is shown in Table 2.

[0065] Table 2

[0066]

[0067]

[0068] When initializing, the database expansion module obtains that the current database expansion method is to obtain from the local storage module, and thus obtains the local configuration file, and loads the information obtained by parsing the obtained local configuration file into the memory.

[0069] There are 2 databases in the current database cluster. During a preset detection period, the resource cycle collection module collects the operation metrics of the two databases as shown in Table 3.

[0070] Table 3

[0071]

[0072]

[0073] Based on the detection values of the same operation metrics of the same database obtained within 10 detection cycles, calculate the statistical value of the operation metrics of the database. The data is shown in Table 4 as follows:

[0074] Table 4

[0075]

[0076]

[0077] Based on the statistical values of the operation metrics of each database, calculate the statistical value of the operation metrics of the database cluster. In this embodiment, the statistical value is the average value, as shown in Table 5.

[0078] Table 5

[0079] Index Average value Calculation method CCLB 0.753 (0.753+0.753) / 2 CMLB 0.755 (0.748+0.762) / 2 CDLB 0.741 (0.739+0.743) / 2 CSNU 0.8477 (0.8418+0.8535) / 2 CTRU 0.7164 (0.7149+0.7179) / 2

[0080] Normalize the statistical values of the operation metrics of the database cluster, and use the sum of the normalized statistical values of the operation metrics of the database cluster as the resource utilization rate of the database cluster. The normalization of the database cluster is as follows:

[0081] CRR = 0.753 * 0.25 + 0.755 * 0.25 + 0.741 * 0.25 + 0.8477 * 0.15 + 0.7164 * 0.15 = 0.797. Since 0.797 is already greater than the cluster expansion threshold of 0.7, the cluster statistical analysis module will send a notice to the database resource expansion module to handle the expansion.

[0082] After receiving the notice sent by the cluster statistical analysis module, the database resource expansion module first applies for resources from the database resource pool according to the configuration parameters of CPU, memory, and disk. After obtaining the resources, it creates a database, that is, applies for a new database from the database resource pool according to the first information.

[0083] Then, use the database initialization script specified in the local configuration file to initialize the database, that is, initialize the new database using the third information.

[0084] Next, configure the master-slave strategy, backup strategy, and disaster recovery strategy of the new database, and use the second information to set the initialized new database.

[0085] Finally, notify the database resource information to the resource cycle collection module and the cluster statistical analysis module, and add the newly created database to the statistical list. Thus, the database expansion is completed.

[0086] In the second embodiment of the present invention, when implementing the expansion and contraction of the database cluster, dynamic factors such as CPU utilization rate and memory occupancy are considered for the analysis of database expansion, so as to judge whether the database meets the expansion conditions of the expansion and contraction conditions to achieve expansion, making the timing of expansion more accurate. In addition, it can automatically expand the database without manual participation, saving human resources.

[0087] The third embodiment of the present invention relates to a method for expanding and contracting a database cluster. The third embodiment is substantially the same as the first embodiment, and the main difference is that: if the resource utilization rate of the database cluster meets the contraction condition in the expansion and contraction conditions, normalize the statistical values of the operating metrics of the same database, and use the sum of the normalized operating metrics of the database as the resource utilization rate of the database; select candidate databases from each of the databases according to the resource utilization rate of each database and the resource utilization rate of the database cluster; and perform contraction on the database cluster based on the candidate databases.

[0088] The flowchart of the third embodiment of the present invention is as Figure 5 shown.

[0089] Step 501, obtain the detected values of the operating metrics of each database in the database cluster.

[0090] Step 502, obtain the resource utilization rate of the database cluster according to the detected values of the operating metrics of each database.

[0091] Steps 501 to 502 are substantially the same as steps 201 to 202 in the embodiment, and will not be elaborated here.

[0092] Step 503, if the resource utilization rate of the database cluster meets the contraction condition in the expansion and contraction conditions, normalize the statistical values of the operating metrics of the same database, and use the sum of the normalized operating metrics of the database as the resource utilization rate of the database.

[0093] In an example, obtain the normalized index (SRR) of the resource utilization rate of each database in the database cluster within the current cycle from the cluster statistical analysis module = SCLB*CCIF + SCMB*CMIF + SDLB*CDIF + SSNU*CSNIF + STRU*CTRIF.

[0094] Step 504: Select candidate databases from each of the databases according to the resource utilization rate of each database and the resource utilization rate of the database cluster.

[0095] In one example, a database with a resource utilization rate less than that of the database cluster among each of the databases is used as the candidate database.

[0096] Exemplarily, obtain the normalized index of the cluster resource utilization rate (CRR) in the current period from the cluster statistical analysis module of the cluster; compare the SSR of each database with the obtained cluster CRR, and add the information of the databases with SSR lower than CRR to the list L to be processed, that is, the candidate databases.

[0097] Step 505: Scale down the database cluster based on the candidate databases.

[0098] In one example, if there is one candidate database, use the candidate database as the database to be reduced, and merge the database to be reduced into the other databases except the database to be reduced among each of the databases.

[0099] If there are two or more candidate databases, use at least one of the multiple candidate databases as the database to be reduced, and merge the database to be reduced into the other candidate databases except the database to be reduced among the multiple candidate databases; clean up the database to be reduced.

[0100] In one example, sort the multiple candidate databases in ascending order of resource utilization rate to obtain a first sequence, and sort the multiple candidate databases in descending order of resource utilization rate to obtain a second sequence; use the two candidate databases with the same sorting number in the first sequence and the second sequence as a group, and filter out multiple different groups; for each filtered group, merge one of the candidate databases in the group into the other candidate database in the group; the one candidate database is used as the database to be reduced.

[0101] In one example, to clean up the database to be reduced, the database to be reduced can be cleaned up based on a preset cleaning rule. The cleaning rules can be as follows: delete the data in the database to be reduced and remove the database to be reduced from the database cluster; or, only delete the data in the database to be reduced.

[0102] Exemplarily, the list L to be processed is sorted in ascending order of SRR to obtain the first sequence Ls, and sorted in descending order to obtain the second sequence Lb; the two lists Ls and Lb are traversed simultaneously. When traversing a certain time, the database metrics of the two lists are Lsc and Lbc respectively. If the average value of Lsc and Lbc is less than or equal to CRR, it is considered that the two databases can be merged; otherwise, merging is not allowed. The two databases that can be merged are placed in the list H to obtain the list of databases that can be merged. It should be noted that the merged databases are two different candidate databases.

[0103] Then, the list H of databases that can be merged is traversed in turn. When merging, the database with a lower resource occupancy index is used as the source database, and the database with a higher resource occupancy index is used as the target database. First, it is judged whether the target database contains information such as the table structure and index of the source database. If it does not exist, it is created first. If it exists, the data is directly copied. In particular, to ensure data security, a backup operation of the database needs to be performed before executing the data copy. If an exception occurs during the copy process, the backup data is used to restore the database to the state before merging.

[0104] Finally, after successful merging, if the cleaning rule configured by the user is: clean all and return the resources to the resource pool, then all information of the database is deleted, the database resources are released and returned to the resource pool, and the cleaned database is removed from the cluster statistical analysis module; if the cleaning rule configured by the user is: only clean the data and do not return the resources to the resource pool, then the resources of the current database are retained and not returned to the resource pool.

[0105] The following uses an example to illustrate the scale-down of the database cluster.

[0106] During initialization, the resource cycle collection module parses the configuration data of the current user. The configuration data of this embodiment is the same as that of the second embodiment, as shown in Table II.

[0107] The database scale-down module parses and loads the scale-down method of the current database during initialization. Assume that the current resource pool has already used 2 databases for a certain tenant, and the operation metrics of the two databases obtained by the resource cycle collection module are shown in Table VI.

[0108] Table VI

[0109]

[0110]

[0111] According to the detection values of the same operation metric of the same database obtained within several detection cycles, calculate the statistical value of the operation metric of the database. The data is shown in Table VII:

[0112] Table VII

[0113]

[0114]

[0115] Calculate the statistical value of the operation metrics of the database cluster according to the statistical values of the operation metrics of each of the databases, as shown in Table VIII.

[0116] Table VIII

[0117] Index Index value Calculation method CCLB 0.1365 (0.158+0.115) / 2 CMLB 0.116 (0.118+0.114) / 2 CDLB 0.121 (0.122+0.12) / 2 CSNU 0 ((0)+(0)) / 2 CTRU 0.0426 ((0.0629)+(0.0224)) / 2

[0118] After multiplying the average metrics of each resource by the corresponding normalization factor, we get:

[0119] Cluster normalization metric CRR = 0.1365 * 0.25 + 0.116 * 0.25 + 0.121 * 0.25 + 0 * 0.15 + 0.0426 * 0.15 = 0.0998

[0120] Since 0.0998 is already less than the cluster scaling-down threshold of 0.3, the cluster statistical analysis module will send a notice to the database resource scaling-down module to handle the scaling-down.

[0121] After receiving the notice sent by the cluster statistical analysis module, the database scaling-down module first calculates the normalization rate of the resource metrics of each individual database.

[0122] Resource utilization rate of Database 1:

[0123] SRR1 = 0.158 * 0.25 + 0.118 * 0.25 + 0.122 * 0.25 + 0 * 0.15 + 0.0698 * 0.15 = 0.02199.

[0124] Resource utilization rate of Database 2:

[0125] SRR2 = 0.1365 * 0.25 + 0.116 * 0.25 + 0.121 * 0.25 + 0 * 0.15 + 0.0461 * 0.15 = 0.01812.

[0126] Optionally, the average of the two databases (0.02199 + 0.01812) / 2 = 0.02005 <= CRR. Therefore, the data of the two databases can be merged.

[0127] Since the resource utilization of Database 2 is smaller, Database 2 is used as the source database and Database 1 is used as the target database for merging.

[0128] Before merging, first back up the data of Database 1 and Database 2, and then determine whether Database 1 contains all the complete table structures of Database 2. If not, supplement the relevant content in Database 1.

[0129] Secondly, after the structure to be represented is completed, copy the data of database 2 to database 1.

[0130] Thirdly, after the data copy is completed, release the database resources, and notify the resource cycle collection module and the cluster statistical analysis module to release the information of database 2. Thus, the database expansion is completed.

[0131] In the third embodiment of the present invention, when implementing the expansion and contraction of the database cluster, dynamic factors such as CPU utilization rate and memory occupancy are considered for the analysis of database expansion, so as to judge whether the database meets the contraction conditions of the expansion and contraction conditions, and then achieve expansion, making the timing of expansion more accurate. In addition, it can automatically expand the database without manual participation, saving human resources, periodically obtaining the detection values of operation indicators, and achieving contraction. Compared with only considering the value at a certain moment in the related art, the embodiment of the present invention is more accurate and has a small error.

[0132] The fourth embodiment of the present invention relates to a service system, as Figure 6 shown, including at least one processor 601; and a memory 602 communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned method for expanding and contracting a database cluster.

[0133] Among them, the memory and the processor are connected by a bus. The bus can include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits together, which are well known in the art, so they will not be further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, and provides a unit for communicating with various other devices on the transmission medium. The data processed by the processor is transmitted on the wireless medium through the antenna. Further, the antenna also receives data and transmits the data to the processor.

[0134] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. The memory can be used to store the data used by the processor when performing operations.

[0135] The fifth embodiment of the present invention relates to a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the above-mentioned method embodiments are implemented.

[0136] That is, those skilled in the art can understand that all or part of the steps in the methods of the above embodiments can be completed by instructing relevant hardware through a program. The program is stored in a storage medium, including several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.

[0137] Ordinary skilled artisans in the art can understand that the above embodiments are specific examples for implementing the present invention, and in actual applications, various changes can be made in form and details without departing from the spirit and scope of the present invention.

Claims

1. A method for scaling a database cluster, characterized in that Including: Obtaining the detected values of the running metrics of each database in the database cluster; Obtaining the resource utilization rate of the database cluster according to the detected values of the running metrics of each database; If the resource utilization rate of the database cluster meets the preset condition for capacity reduction, selecting candidate databases from each of the databases; If the number of candidate databases is greater than or equal to 2, sorting the multiple candidate databases in ascending order of resource utilization rate to obtain a first sequence, and sorting the multiple candidate databases in descending order of resource utilization rate to obtain a second sequence; Taking two candidate databases with the same sorting number in the first sequence and the second sequence as a group, and screening out multiple different groups; For each screened group, merging one of the candidate databases in the group into another candidate database in the group; Taking the one candidate database as the database to be reduced, and cleaning the database to be reduced.

2. The method according to claim 1, wherein The obtaining the detected values of the running metrics of each database in the database cluster is specifically: periodically obtaining the detected values of the running metrics of each database in the database cluster according to a preset detection period; The obtaining the resource utilization rate of the database cluster according to the detected values of the running metrics of each database is specifically: obtaining the resource utilization rate of the database cluster according to the detected values of the running metrics of each database obtained within a plurality of the detection periods.

3. The method according to claim 2, characterized in that, The number of the running metrics is greater than or equal to 2; the obtaining the resource utilization rate of the database cluster according to the detected values of the running metrics of each database obtained within a plurality of the detection periods includes: Calculating the statistical value of the running metric of the database according to the detected values of the same running metric of the same database obtained within a plurality of the detection periods; Calculating the statistical value of the running metric of the database cluster according to the statistical values of the running metrics of each database; Normalizing the statistical values of the running metrics of the database cluster, and taking the sum of the normalized statistical values of the running metrics of the database cluster as the resource utilization rate of the database cluster.

4. The method according to claim 1, characterized in that The running metric is one of the following metrics: CPU utilization rate, memory utilization rate, disk utilization rate, structure table quantity overlimit rate, structure form single table record quantity overlimit rate.

5. The method according to claim 4, characterized in that, When the running metric is the CPU utilization rate, or the memory utilization rate, or the disk utilization rate, the obtaining the detected values of the running metrics of each database in the database cluster is specifically: collecting the detected values of the running metrics of each database; When the running metric is the structure table quantity overlimit rate, the obtaining the detected values of the running metrics of each database in the database cluster includes: collecting the quantity of structure tables of each database, and calculating the structure table quantity overlimit rate of each database according to a preset structure table quantity threshold value; When the operating metric is the overrun rate of the number of records in the structure form table, the obtaining of the detection values of the operating metrics of each database in the database cluster includes: collecting the number of records in the structure form table of each database, and calculating the overrun rate of the number of records in the structure form table of each database according to a preset threshold value of the number of records in the structure form table.

6. The method according to claim 1, characterized in that, After the step of obtaining the resource utilization rate of the database cluster according to the detection values of the operating metrics of each database, it further includes: If the resource utilization rate of the database cluster meets the preset expansion condition, obtain database configuration information according to the pre-obtained source mode of the database configuration information; Configure a new database for the database cluster according to the database configuration information.

7. The method according to claim 6, wherein The database configuration information includes first information representing the hardware performance of the database, second information representing the data processing strategy, and third information representing the database architecture; The configuring of a new database for the database cluster according to the database configuration information includes: Applying for a new database from the database resource pool according to the first information; Initializing the new database by using the third information; Setting the initialized new database by using the second information, and using the successfully set new database as the new database added to the database cluster.

8. The method according to claim 6, wherein The source mode of the database configuration information includes at least one of the following modes: obtaining from at least one database in the database cluster, obtaining from a local storage module, obtaining from a remote device.

9. The method according to claim 1, characterized in that, The selecting of candidate databases from each of the databases includes: Normalizing the statistical values of the operating metrics of the same database, and using the sum of the operating metrics of the normalized database as the resource utilization rate of the database; Selecting candidate databases from each of the databases according to the resource utilization rates of each of the databases and the resource utilization rate of the database cluster.

10. The method according to claim 1, characterized in that, After the step of selecting candidate databases from each of the databases, it further includes: If there is one candidate database, using the candidate database as the database to be reduced, and merging the database to be reduced into other databases in each of the databases except the database to be reduced; Clearing the database to be reduced.

11. The method according to claim 1, wherein One of the candidate databases is the candidate database with a smaller resource utilization rate among the two candidate databases in the group.

12. The method according to claim 1 or 10, characterized in that, The clearing of the database to be reduced includes: Clearing the database to be reduced based on a preset clearing rule; the clearing rule includes: deleting the data in the database to be reduced, and removing the database to be reduced from the database cluster; or, only deleting the data in the database to be reduced.

13. A service system, characterized in that, It includes: At least one processor; And, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the database cluster scaling method as described in any one of claims 1 to 12.

14. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method for scaling a database cluster according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Resource adjustment method, device, cloud platform and server

    CN109343965A

  • Strategy-based cloud database elastic scaling method

    CN109783577A