[go: up one dir, main page]

WO2022068392A1 - Database cluster capacity expansion and reduction method, service system and storage medium - Google Patents

Database cluster capacity expansion and reduction method, service system and storage medium Download PDF

Info

Publication number
WO2022068392A1
WO2022068392A1 PCT/CN2021/110956 CN2021110956W WO2022068392A1 WO 2022068392 A1 WO2022068392 A1 WO 2022068392A1 CN 2021110956 W CN2021110956 W CN 2021110956W WO 2022068392 A1 WO2022068392 A1 WO 2022068392A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
cluster
databases
candidate
database cluster
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2021/110956
Other languages
French (fr)
Chinese (zh)
Inventor
赵光跃
宋志伟
邬春会
方楷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Publication of WO2022068392A1 publication Critical patent/WO2022068392A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Definitions

  • the embodiments of the present application relate to the field of information technology, and in particular, to a method, a service system, and a storage medium for expanding and shrinking a database cluster.
  • a database cluster is a technology that encapsulates a series of database servers in a cluster to provide external data services in a unified manner.
  • the disk space of the server where the database is located in the database cluster is insufficient, the concurrent read and write requests exceed the limit that the database cluster can carry, etc., the database cluster will be expanded or reduced in capacity, and most databases are implemented by receiving external requests.
  • Cluster scaling is a technology that encapsulates a series of database servers in a cluster to provide external data services in a unified manner.
  • An embodiment of the present application provides a method for expanding and shrinking a database cluster, including: acquiring detection values of operating indicators of each database in a database cluster; and obtaining resource usage of the database cluster according to the detected values of the operating indicators of each database If the resource utilization rate of the database cluster satisfies the preset capacity expansion and contraction conditions, the database cluster is expanded and contracted.
  • 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 data that can be executed by the at least one processor instructions, where the instructions are executed by the at least one processor, so that the at least one processor can execute the foregoing method for expanding or shrinking a database cluster.
  • 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 foregoing method for expanding or shrinking a database cluster is provided.
  • FIG. 1 is a schematic diagram of a system according to a first embodiment of the present application.
  • FIG. 2 is a flowchart of a method for expanding and shrinking a database cluster according to the first embodiment of the present application
  • FIG. 3 is a flowchart of sub-steps of a method for expanding and shrinking a database cluster according to the first embodiment of the present application;
  • FIG. 4 is a flowchart of a method for expanding and shrinking a database cluster according to a second embodiment of the present application
  • FIG. 5 is a flowchart of a method for expanding and shrinking a database cluster according to a third embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a service system according to a fourth embodiment of the present application.
  • the main purpose of the embodiments of the present application is to propose a database cluster expansion and contraction method, service system, and storage medium, which can automatically realize the dynamic database cluster expansion and contraction, and use the operation indicators for analysis, so as to obtain the timing of database expansion and contraction more accurately.
  • Table 1 Chinese and abbreviation comparison table of some parameters
  • the first embodiment of the present application relates to a method for expanding and shrinking the capacity of a database cluster.
  • the method includes: acquiring the detection value of the operation index of each database in the database cluster; obtaining the resource utilization rate of the database cluster according to the detection value of the operation index of each database; if the resource utilization rate of the database cluster satisfies a predetermined According to the set expansion and contraction conditions, the database cluster is expanded and contracted.
  • This embodiment can automatically realize the dynamic cluster shrinking and expansion of the database, and the detection value of the running index of the database can be used for analysis, and the running status of each database in the database cluster can be obtained, so that the analysis result is more accurate.
  • This embodiment can be applied to a system including a plurality of servers, but is not limited thereto.
  • the system can realize the expansion and contraction of the database, and the system can have different database applications, as well as a database resource monitoring module and a database resource pool.
  • the database resource monitoring module includes a resource cycle acquisition module, a database resource reduction module, a database resource expansion module, and a cluster analysis module.
  • the database resource monitoring module monitors the database resource pool to determine whether expansion or contraction is required.
  • the resource cycle acquisition module When the resource cycle acquisition module starts, it parses the expansion and contraction parameters configured by the user, loads the expansion and contraction parameters into the memory, obtains the parameter values defined by the cycle according to the database indicators, periodically obtains the operation indicators of each database, and detects each The data submitted to the cluster statistical analysis module; the cluster statistical analysis module periodically analyzes and counts the running indicators of all databases in the current cycle of the cluster according to the running indicators obtained by the configured cluster indicator statistical cycle; The information is normalized, the rate is normalized, and the cluster resource usage is normalized, and it is determined whether expansion or contraction is required. If expansion and contraction are required, the database resource expansion module is notified to expand the database resources. The capacity module is used to shrink the resources and return the idle resources after the shrinkage to the resource pool.
  • the scaling parameters include database thresholds, cluster thresholds, index impact factors, detection period parameters, database initialization methods, and database cleaning methods listed in Table 1.
  • FIG. 2 The flowchart of the first embodiment of the present application is shown in FIG. 2 .
  • Step 201 Acquire detection values of operating indicators of each database in the database cluster.
  • the detection values of the operation indicators of each database in the database cluster are periodically acquired.
  • the operation indicator is one of the following indicators: CPU utilization DCU, memory utilization DMU, disk utilization DDU, structure table quantity overrun rate DSNU, and structure table table record quantity overrun rate DTRU.
  • acquiring the detection value of the operation indicator of each database in the database cluster includes: collecting and obtaining each of the databases The detected value of the operation index, DCU, or DMU, or DDU; in the case that the operation index is the over-limit rate of the number of structure tables, the number of structure tables of each of the databases is collected, and the number of structure tables is obtained according to the preset number of structure tables.
  • the threshold value calculates the structure table quantity over-limit rate of each of the databases; in the case that the operating index is the structure table table record number over-limit rate, collect and obtain the structure table record numbers of each of the databases, and according to the forecast
  • the set threshold value of the number of records in the structure form table is used to calculate the excess rate of the number of records in the structure form table of each of the databases.
  • the database cluster manages K databases as an example.
  • the operation indicator is the number of structure tables exceeding the limit rate
  • the number of structure tables exceeding the threshold of the number of database structure tables is calculated according to the number of structure tables in a single database obtained each time.
  • the calculation method is: if the number of current table structures exceeds The database table structure number threshold value DSNT, then subtract the database table structure number threshold DSNT from the current number to obtain the current over-limit table structure number, and divide the over-limit by the database table structure number threshold to obtain the current database structure table number Overrun rate DSNU.
  • the operation indicator is the record number exceeding rate of the structure form table.
  • the number of table structures exceeding the table record threshold value is calculated according to the number of records of each table in a single database obtained each time. The calculation method is as follows: if the number of the current table has exceeded the threshold value of the number of records of a single table in the database, the number of tables in the database library exceeding the threshold value is obtained by counting and accumulating. Second, divide the number of overrun tables obtained in the first step by the total number of all tables in the database to obtain the overrun rate DTRU of the number of records in the database structure form table.
  • Step 202 Obtain the resource usage rate of the database cluster according to the detected value of the operation index of each database.
  • the resource usage rate of the database cluster is obtained according to the detection values of the operation indicators of each of the databases obtained in several detection cycles.
  • Sub-step 301 Calculate the statistical value of the operation index of the database according to the detection value of the same operation index of the same database obtained in several detection cycles.
  • the running indicator is memory utilization
  • the average memory utilization of a single database in the calculation cycle SCMB (DMU1+DMU2+...+DMUN), and the average memory utilization of K databases SCMB1, SCMB2... SCMBK.
  • the average disk utilization SDLB (DDU1+DDU2+...+DDUN) of a single database during the calculation period, so as to obtain the average disk utilization SDLB1, SDLB2...SDLBK of K databases.
  • Sub-step 302 Calculate the statistical value of the operational indicator of the database cluster according to the statistical value of the operational indicator of each database.
  • Sub-step 303 normalize the statistical values of each of the operating indicators of the database cluster, and use the sum of the normalized statistical values of each of the operating indicators of the database cluster as the resource utilization rate of the database cluster.
  • Step 203 if the resource utilization rate of the database cluster satisfies the preset capacity expansion and contraction conditions, expand and contract the database cluster.
  • the CRR is greater than the user-configured normalized upper limit of cluster shrinking and expansion CBNU, it is considered that capacity expansion is required; if the CRR is less than the user-configured lower normalized lower limit of cluster shrinking and expansion CBNU, it is deemed that the capacity needs to be reduced.
  • the detection value of the operation index of each database in the database cluster is obtained; according to the detection value of the operation index of each database, the resource utilization rate of the database cluster is obtained; if the resource utilization rate of the database cluster satisfies the predetermined According to the set expansion and contraction conditions, the database cluster can be expanded and contracted, which can automatically realize the dynamic cluster expansion and contraction of the database, and the operation status of each database in the database cluster can be obtained by using the detection value of the operation index of the database for analysis. make the analysis results more accurate.
  • the second embodiment of the present application relates to a method for expanding and shrinking the capacity of a database cluster.
  • the flowchart of the second embodiment of the present application is shown in FIG. 2 .
  • Step 401 Acquire the detection value of the operation index of each database in the database cluster.
  • Step 402 Obtain the resource utilization rate of the database cluster according to the detected value of the operation index of each database.
  • Steps 401 to 402 are substantially the same as steps 201 to 202 of the first embodiment, and to avoid repetition of expressions, they will not be repeated here.
  • Step 403 if the resource utilization rate of the database cluster satisfies the capacity expansion condition in the capacity expansion/contraction condition, obtain database configuration information according to the source mode of the pre-obtained database configuration information.
  • the source manner of the database configuration information includes at least one of the following manners: acquiring from at least one database in the database cluster, acquiring from a local storage module, and acquiring from a remote device.
  • 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, and find any source database information that meets the rules. , and load configuration information such as memory, CPU, disk configuration, active/standby strategy, backup strategy, and disaster recovery strategy into the configuration list, and then obtain database information, such as index information, database schema information, database table structure information, etc., and generate them separately. Related scripts, put them in the script list.
  • the database configuration information is sourced from a local storage module, that is, a local configuration file is obtained, the configuration information in the local file is directly loaded into the configuration list, and the script list that initializes the database is loaded.
  • the source method of the database configuration information is to obtain from the remote device, that is, to obtain the remote configuration file, download the remote configuration file to the local, and then load the configuration information downloaded to the local file into the configuration list, and set the List of scripts loaded by scripts that initialize the database.
  • the streaming mode can be selected when downloading files, and the content of the remote file can be loaded directly into the memory without downloading the local file, which reduces the IO of the local disk.
  • step 404 a newly added database of the database cluster is obtained according to the configuration of the database configuration information.
  • 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 database; use the third information to initialize the new database; use the second information to set the new database after successful initialization, and use the new database after successful setting as the A new database for the database cluster.
  • 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, disk resources, etc., from the cluster resource pool according to the first information in the obtained configuration list
  • Hardware resources if the resources cannot be obtained, then give up this expansion
  • use the third information to initialize the new database, that is, initialize the newly applied database according to the obtained database initialization script, if the initialization of the database fails, then Consider that the expansion fails, clean up the applied resources, and return them to the resource pool
  • use the second information to set the new database after the initialization is successful, and use the new database after the setting is successful as the
  • set database policies related to the database such as active/standby policies, backup policies, disaster recovery policies, etc. If the database policy fails to be set, the expansion will be considered a failure, and the applied resources will be cleaned up and returned to the resources pool.
  • the following is an example to illustrate the expansion of the database cluster.
  • the resource cycle collection module parses the configuration data of the current user, and the obtained parameter configuration is shown in Table 2.
  • the way that the database expansion module obtains the current database expansion during initialization is to obtain the local configuration file from the local storage module, and load the information obtained by parsing the obtained local configuration file into the memory.
  • Table 4 Statistical value table of the calculated operating indicators of the database
  • the statistical value of the operation index of the database cluster is calculated.
  • the statistical value is an average value, as shown in Table 5.
  • Table 5 Statistical value table of the calculated operating indicators of the database cluster
  • the database resource expansion module After the database resource expansion module receives the notification sent by the cluster statistics analysis module, it first applies for resources from the database resource pool according to the configuration parameters of CPU, memory and disk, and then creates a database after applying for the resources, that is, according to the first information from the database resource pool. Apply for a new database.
  • the database is initialized using the database initialization script specified in the local configuration file, that is, the new database is initialized by using the third information.
  • the database resource information is notified to the resource period collection module and the cluster statistics analysis module, and the newly created database is added to the statistics list later, and the database expansion is completed.
  • dynamic factors such as CPU utilization and memory occupancy are considered when implementing the expansion and contraction of the database cluster to analyze the expansion of the database, so as to determine whether the database meets the expansion conditions of the expansion and contraction conditions, so as to realize the expansion. , which makes the timing of expansion more accurate. In addition, it can automatically expand the database without manual participation, saving human resources.
  • the third embodiment of the present application relates to a method for expanding and shrinking the capacity of a database cluster.
  • the third embodiment is roughly the same as the first embodiment, except that: if the resource utilization rate of the database cluster satisfies the shrinking conditions in the expansion and shrinkage conditions, the operation indicators of the same database The statistical value is normalized, and the sum of the normalized operation indicators of the database is used as the resource utilization rate of the database; according to the resource utilization rate of each database and the resources of the database cluster According to the utilization rate, candidate databases are selected from each of the databases; and the database cluster is scaled down based on the candidate databases.
  • FIG. 5 The flowchart of the third embodiment of the present application is shown in FIG. 5 .
  • Step 501 Acquire the detection value of the running index of each database in the database cluster.
  • Step 502 Obtain the resource usage rate of the database cluster according to the detected values of the operating indicators of each database.
  • Steps 501 to 502 are substantially the same as steps 201 to 202 of the embodiment, and are not repeated here.
  • Step 503 If the resource utilization rate of the database cluster satisfies the capacity reduction condition in the capacity expansion/contraction condition, normalize the statistical value of each of the operation indicators of the same database, and normalize all the normalized data. The sum of each of the operational indicators of the database is used as the resource utilization rate of the database.
  • Step 504 Select candidate databases from each of the databases according to the resource usage rate of each of the databases and the resource usage rate of the database cluster.
  • a database whose resource usage rate in each of the databases is lower than the resource usage rate of the database cluster is used as the candidate database.
  • the cluster from the cluster to obtain the cluster resource utilization rate normalization index (CRR) in the current cycle from the cluster statistics analysis module; compare the SSR of each database with the obtained cluster CRR, and add the information of the database lower than the CRR to the data.
  • the pending list L is the candidate database.
  • Step 505 scale down the database cluster based on the candidate database.
  • the candidate database is one
  • the candidate database is used as the database to be reduced, and the database to be reduced is merged into other databases except the database to be reduced in each of the databases.
  • the number of candidate databases is greater than or equal to 2
  • at least one candidate database among the multiple candidate databases is used as the database to be reduced, and the databases to be reduced are merged into the multiple candidate databases except the to-be-reduced database.
  • other candidate databases outside the database clean up the database to be reduced.
  • the plurality of candidate databases are sorted in descending order of resource usage to obtain a first sequence, and the plurality of candidate databases are sorted in descending order of resource usage, and the first sequence is obtained.
  • Obtain the second sequence take two candidate databases with the same order number in the first sequence and the second sequence as a group, and filter out multiple different groups; One of the candidate databases in the group is merged into another candidate database in the group; the one of the candidate databases serves as the database to be reduced.
  • the database to be reduced can be cleaned based on a preset cleaning rule, and the cleaning rules can be as follows: delete the data in the database to be reduced, and remove the database to be reduced from all delete from the database cluster; or, delete only the data in the database to be reduced.
  • the list L to be processed is sorted according to SRR from small to large to obtain the first sequence Ls, and the second sequence Lb is obtained by sorting from large to small; the two lists Ls and Lb are traversed at the same time, when a certain traversal is performed.
  • the database indicators of the two lists are Lsc and Lbc. If the mean value of Lsc and Lbc is less than or equal to CRR, it is considered that the two databases can be merged. Otherwise, it is not allowed to merge. A list of mergeable databases is obtained. It is worth noting that the merged databases are two different candidate databases.
  • the mergeable list H traverse the mergeable list H in turn.
  • mergeable list H When merging, take the source database with the low resource occupancy index as the source database, and take the resource occupancy index as the target database, first determine whether the target database contains the table structure, index and other information of the source database, if not Create it first, and copy the data directly if it exists. In particular, to ensure data security, it is necessary to perform a database backup operation before performing data copying. If an exception occurs during the copying process, use the backup data to restore the database to the state before merging.
  • cleanup rules configured by the user are: clean up all, return the resources to the resource pool, delete all the information of the database, release the database resources, return them to the resource pool, and remove them from the cluster statistical analysis module Cleaned database; if the cleanup rule configured by the user is: only data is cleaned, and resources are not returned to the resource pool, the resources of the current database are retained and not returned to the resource pool.
  • the following uses an example to illustrate the scaling of the database cluster.
  • the resource period 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 2.
  • the database shrinking module parses the shrinking method loaded into the current database during initialization. Assuming that the current resource pool has used two databases for a tenant, the operating indicators of the two databases obtained by the resource cycle collection module are shown in Table 6. .
  • Table 6 Statistics of the operation indicators of the two databases obtained by the resource period collection module
  • Table 7 Statistical value table of the calculated operating indicators of the database
  • the statistical value of the operation index of the database cluster is calculated, as shown in Table 8.
  • Table 8 Statistical value table of the calculated operating indicators of the database cluster
  • the average index of each resource is multiplied by the corresponding normalization factor to obtain:
  • the shrink module handles shrinking.
  • the database shrinking module After the database shrinking module receives the notification sent by the cluster statistical analysis module, it first normalizes the resource indicators of a single database.
  • database 2 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 consolidation.
  • the database resources are released, and the information of the database 2 is notified to the resource period collection module and the cluster statistical analysis module for release. At this point, the database expansion is completed.
  • dynamic factors such as CPU utilization and memory occupancy are taken into account when implementing the expansion and contraction of the database cluster to analyze the expansion of the database, so as to determine whether the database satisfies the expansion and contraction conditions.
  • Expansion makes the timing of expansion more accurate.
  • the expansion of the database can be performed automatically without manual participation, saving human resources, and periodically obtaining the detection value of the operation index to realize the capacity reduction. Compared with the related technologies, only considering a certain The value of the time, the embodiment of the present application is more accurate, and the error is small.
  • the fourth embodiment of the present application relates to a service system, as shown in FIG. 6 , comprising at least one processor 601; and a memory 602 communicatively connected to the at least one processor; wherein the memory stores data that can be instructions executed by the at least one processor, where the instructions are executed by the at least one processor, so that the at least one processor can execute the foregoing method for expanding or shrinking a database cluster.
  • the memory and the processor are connected by a bus, and the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors and various circuits of the memory.
  • the bus may also connect together various other circuits, such as peripherals, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein.
  • the bus interface provides the interface between the bus and the transceiver.
  • a transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing a means for communicating with various other devices over a transmission medium.
  • the data processed by the processor is transmitted on the wireless medium through the antenna, and further, the antenna also receives the data and transmits the data to the processor.
  • the processor manages the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Instead, memory may be used to store data used by the processor in performing operations.
  • the fifth embodiment of the present application relates to a computer-readable storage medium storing a computer program.
  • the above method embodiments are implemented when the computer program is executed by the processor.
  • the aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A database cluster capacity expansion and reduction method, a service system and a storage medium, relating to the technical field of information. The method comprises: acquiring a detection value of an operation index of each database in a database cluster (201); obtaining a resource utilization rate of the database cluster according to the detection value of the operation index of each database (202); and if the resource utilization rate of the database cluster meets a preset capacity expansion and reduction condition, carrying out capacity expansion and reduction on the database cluster (203).

Description

数据库集群扩缩容方法、服务系统、存储介质Database cluster expansion and contraction method, service system, storage medium

交叉引用cross reference

本申请基于申请号为“202011049631.4”、申请日为2020年09月29日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此以引入方式并入本申请。This application is based on the Chinese patent application with the application number "202011049631.4" and the application date is September 29, 2020, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby incorporated by reference. Apply.

技术领域technical field

本申请实施例涉及信息技术领域,特别涉及一种数据库集群扩缩容方法、服务系统、存储介质。The embodiments of the present application relate to the field of information technology, and in particular, to a method, a service system, and a storage medium for expanding and shrinking a database cluster.

背景技术Background technique

数据库集群是将一系列数据库服务器以集群的方式进行封装,统一对外提供数据服务的技术。通过结合分库分表、读写分离、数据均衡、主从同步等技术,解决单一数据库节点的读写访问瓶颈。当数据库集群中数据库所在服务器的磁盘空间不足、读写请求并发量超过了数据库集群能承载的极限等情况发生时,会对数据库集群进行扩容或缩容,大多通过接收外部请求的方式来实现数据库集群扩缩容。A database cluster is a technology that encapsulates a series of database servers in a cluster to provide external data services in a unified manner. By combining sub-database and sub-table, read-write separation, data balance, master-slave synchronization and other technologies, the bottleneck of read and write access of a single database node is solved. When the disk space of the server where the database is located in the database cluster is insufficient, the concurrent read and write requests exceed the limit that the database cluster can carry, etc., the database cluster will be expanded or reduced in capacity, and most databases are implemented by receiving external requests. Cluster scaling.

然而,通过接收外部请求的方式实现数据库集群扩缩容,需要人工进行参与,浪费人力资源。However, the expansion and contraction of database clusters by receiving external requests requires manual participation and wastes human resources.

发明内容SUMMARY OF THE INVENTION

本申请实施例提供了一种数据库集群扩缩容方法,包括:获取数据库集群中各数据库的运行指标的检测值;根据各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率;若所述数据库集群的资源使用率满足预设的扩缩容条件,对所述数据库集群进行扩缩容。An embodiment of the present application provides a method for expanding and shrinking a database cluster, including: acquiring detection values of operating indicators of each database in a database cluster; and obtaining resource usage of the database cluster according to the detected values of the operating indicators of each database If the resource utilization rate of the database cluster satisfies the preset capacity expansion and contraction conditions, the database cluster is expanded and contracted.

本申请实施例还提供了一种服务系统,包括:至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述的数据库集群扩缩容方法。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 data that can be executed by the at least one processor instructions, where the instructions are executed by the at least one processor, so that the at least one processor can execute the foregoing method for expanding or shrinking a database cluster.

本申请实施例还提供了一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时上述的数据库集群扩缩容方法。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 foregoing method for expanding or shrinking a database cluster is provided.

附图说明Description of drawings

图1是根据本申请第一实施例的系统的示意图;1 is a schematic diagram of a system according to a first embodiment of the present application;

图2是根据本申请第一实施例的数据库集群扩缩容方法的流程图;2 is a flowchart of a method for expanding and shrinking a database cluster according to the first embodiment of the present application;

图3是根据本申请第一实施例的数据库集群扩缩容方法的子步骤流程图;3 is a flowchart of sub-steps of a method for expanding and shrinking a database cluster according to the first embodiment of the present application;

图4是根据本申请第二实施例的数据库集群扩缩容方法的流程图;4 is a flowchart of a method for expanding and shrinking a database cluster according to a second embodiment of the present application;

图5是根据本申请第三实施例的数据库集群扩缩容方法的流程图;5 is a flowchart of a method for expanding and shrinking a database cluster according to a third embodiment of the present application;

图6是根据本申请第四实施例的服务系统的结构示意图。FIG. 6 is a schematic structural diagram of a service system according to a fourth embodiment of the present application.

具体实施方式Detailed ways

本申请实施例的主要目的在于提出一种数据库集群扩缩容方法、服务系统、存储介质,能够自动实现数据库动态集群缩扩容,并且采用运行指标进行分析,较为准确的获取数据库扩缩容的时机。The main purpose of the embodiments of the present application is to propose a database cluster expansion and contraction method, service system, and storage medium, which can automatically realize the dynamic database cluster expansion and contraction, and use the operation indicators for analysis, so as to obtain the timing of database expansion and contraction more accurately. .

为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请的各实施例进行详细的阐述。然而,本领域的普通技术人员可以理解,在本申请各实施例中,为了使读者更好地理解本申请而提出了许多技术细节。但是,即使没有这些技术细节和基于以下各实施例的种种变化和修改,也可以实现本申请所要求保护的技术方案。以下各个实施例的划分是为了描述方便,不应对本申请的具体实现方式构成任何限定,各个实施例在不矛盾的前提下可以相互结合相互引用。In order to make the objectives, technical solutions and advantages of the embodiments of the present application more clear, each embodiment of the present application will be described in detail below with reference to the accompanying drawings. However, those of ordinary skill in the art can understand that, in each embodiment of the present application, many technical details are provided for the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in the present application can be realized. The following divisions of the various embodiments are for the convenience of description, and should not constitute any limitation on the specific implementation of the present application, and the various embodiments may be combined with each other and referred to each other on the premise of not contradicting each other.

为简化说明,本申请的实施例所用到的部分参数的中文与缩写对照如表一所示。To simplify the description, the comparison between Chinese and abbreviations of some parameters used in the embodiments of the present application is shown in Table 1.

表一:部分参数的中文与缩写对照表Table 1: Chinese and abbreviation comparison table of some parameters

Figure PCTCN2021110956-appb-000001
Figure PCTCN2021110956-appb-000001

Figure PCTCN2021110956-appb-000002
Figure PCTCN2021110956-appb-000002

本申请的第一实施例涉及一种数据库集群扩缩容方法。该方法包括:获取数据库集群中各数据库的运行指标的检测值;根据各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率;若所述数据库集群的资源使用率满足预设的扩缩容条件,对所述数据库集群进行扩缩容。本实施例能够自动实现数据库动态集群缩扩容,并且,采用数据库的运行指标的检测值进行分析,能够获取数据库集群中各数据库的运行状况,使得分析结果更准确。The first embodiment of the present application relates to a method for expanding and shrinking the capacity of a database cluster. The method includes: acquiring the detection value of the operation index of each database in the database cluster; obtaining the resource utilization rate of the database cluster according to the detection value of the operation index of each database; if the resource utilization rate of the database cluster satisfies a predetermined According to the set expansion and contraction conditions, the database cluster is expanded and contracted. This embodiment can automatically realize the dynamic cluster shrinking and expansion of the database, and the detection value of the running index of the database can be used for analysis, and the running status of each database in the database cluster can be obtained, so that the analysis result is more accurate.

本实施例可以应用于包括多个服务器的系统,但不限于此。This embodiment can be applied to a system including a plurality of servers, but is not limited thereto.

例如,如图1所示的系统,该系统可以实现数据库的扩容和缩容,该系统中可以有不同数据库应用,以及数据库资源监控模块和数据库资源池。数据库资源监控模块中有资源周期获取模块,数据库资源缩容模块,数据库资源扩容模块,集群分析模块。数据库资源监控模块监控数据库资源池来判断是否需要扩缩容。For example, as shown in FIG. 1, the system can realize the expansion and contraction of the database, and the system can have different database applications, as well as a database resource monitoring module and a database resource pool. The database resource monitoring module includes a resource cycle acquisition module, a database resource reduction module, a database resource expansion module, and a cluster analysis module. The database resource monitoring module monitors the database resource pool to determine whether expansion or contraction is required.

资源周期获取模块启动时解析用户配置的扩缩容参数,将扩缩容参数加载到内存中,按照数据库指标获取周期定义的参数值,周期性获取每个数据库运行指标,并将每次检测到的数据提交给集群统计分析模块;集群统计分析模块根据配置的集群指标统计周期获取的运行指标,周期性的分析统计集群当前周期内所有数据库的运行指标;集群统计分析模块将每个周期内统计信息的进行归一化得到率归一化指标集群资源使用,并确定是否需要进行扩缩容,如果需要扩容则通知数据库资源扩容模块进行对数据库资源进行扩容,如果需要缩容则通知数据库资源缩容模块,对资源进行缩容,并将缩容后的闲置资源交还给资源池。When the resource cycle acquisition module starts, it parses the expansion and contraction parameters configured by the user, loads the expansion and contraction parameters into the memory, obtains the parameter values defined by the cycle according to the database indicators, periodically obtains the operation indicators of each database, and detects each The data submitted to the cluster statistical analysis module; the cluster statistical analysis module periodically analyzes and counts the running indicators of all databases in the current cycle of the cluster according to the running indicators obtained by the configured cluster indicator statistical cycle; The information is normalized, the rate is normalized, and the cluster resource usage is normalized, and it is determined whether expansion or contraction is required. If expansion and contraction are required, the database resource expansion module is notified to expand the database resources. The capacity module is used to shrink the resources and return the idle resources after the shrinkage to the resource pool.

在一个例子中,所述缩扩容参数有表1中所列的数据库门限阈值,集群门限阈值,指标影响因子,以及检测周期参数,数据库初始化方式,数据库清理方式。In an example, the scaling parameters include database thresholds, cluster thresholds, index impact factors, detection period parameters, database initialization methods, and database cleaning methods listed in Table 1.

下面对本申请第一实施例的数据库集群扩缩容转换方法的实现细节进行具体的说明,以下内容仅为方便理解提供的实现细节,并非实施本方案的必须。The implementation details of the database cluster expansion/contraction conversion method according to the first embodiment of the present application will be specifically described below. The following content is only provided for the convenience of understanding, and is not necessary for implementing this solution.

本申请第一实施例的流程图如图2所示。The flowchart of the first embodiment of the present application is shown in FIG. 2 .

步骤201,获取数据库集群中各数据库的运行指标的检测值。Step 201: Acquire detection values of operating indicators of each database in the database cluster.

在一个例子中,根据预设的检测周期,周期性地获取数据库集群中各数据库的运行指标的检测值。In one example, according to a preset detection period, the detection values of the operation indicators of each database in the database cluster are periodically acquired.

在一个例子中,所述运行指标为以下指标的其中之一:CPU利用率DCU、内存利用率DMU、磁盘利用率DDU、结构表数量超限率DSNU、结构表单表记录数量超限率DTRU。In an example, the operation indicator is one of the following indicators: CPU utilization DCU, memory utilization DMU, disk utilization DDU, structure table quantity overrun rate DSNU, and structure table table record quantity overrun rate DTRU.

在一个例子中,所述运行指标为CPU利用率、或者内存利用率、或者磁盘利用率的情况下,所述获取数据库集群中各数据库的运行指标的检测值,包括:采集得到各所述数据库的运行指标的检测值,DCU,或者DMU,或者DDU;在所述运行指标为结构表数量超限率的情况下,采集得到各所述数据库的结构表数量,并根据预设的结构表数量门限值计算各所述数据库的结构表数量超限率;在所述运行指标为结构表单表记录数量超限率的情况下,采集得到各所述数据库的结构表单表记录数量,并根据预设的结构表单表记录数量门限值计算各所述 数据库的结构表单表记录数量超限率。In an example, when the operation indicator is CPU utilization, memory utilization, or disk utilization, acquiring the detection value of the operation indicator of each database in the database cluster includes: collecting and obtaining each of the databases The detected value of the operation index, DCU, or DMU, or DDU; in the case that the operation index is the over-limit rate of the number of structure tables, the number of structure tables of each of the databases is collected, and the number of structure tables is obtained according to the preset number of structure tables. The threshold value calculates the structure table quantity over-limit rate of each of the databases; in the case that the operating index is the structure table table record number over-limit rate, collect and obtain the structure table record numbers of each of the databases, and according to the forecast The set threshold value of the number of records in the structure form table is used to calculate the excess rate of the number of records in the structure form table of each of the databases.

在一个例子中,以获取N次运行指标,数据库集群共管理K个数据库为例。In an example, taking N times of running indicators, the database cluster manages K databases as an example.

在一个例子中,运行指标为结构表数量超限率数量,根据每次获取到的单个数据库中的结构表数量计算超过数据库结构表数量门限的数量,计算方法为:如果当前表结构的数量超过数据库表结构数量门限值DSNT,则将当前数量减去数据库表结构数量门限DSNT后得到当前的超限的表结构数量,用超限量除以数据库表结构数量门限,得到本次数据库结构表数量超限率DSNU。In an example, the operation indicator is the number of structure tables exceeding the limit rate, and the number of structure tables exceeding the threshold of the number of database structure tables is calculated according to the number of structure tables in a single database obtained each time. The calculation method is: if the number of current table structures exceeds The database table structure number threshold value DSNT, then subtract the database table structure number threshold DSNT from the current number to obtain the current over-limit table structure number, and divide the over-limit by the database table structure number threshold to obtain the current database structure table number Overrun rate DSNU.

在一个例子中,运行指标为结构表单表记录数量超限率,首先根据每次获取到的单个数据库中每个表的记录数量计算超过表记录门限值的表结构数量。计算方法为:如果当前表的数量已经超过数据库单表记录数门限值则计数累加得到该数据库库超过门限值的表数量。其次,用第一步得到的超限表数量除以该数据库所有表的总数量,得到此次的数据库结构表单表记录数量超限率DTRU。In an example, the operation indicator is the record number exceeding rate of the structure form table. First, the number of table structures exceeding the table record threshold value is calculated according to the number of records of each table in a single database obtained each time. The calculation method is as follows: if the number of the current table has exceeded the threshold value of the number of records of a single table in the database, the number of tables in the database library exceeding the threshold value is obtained by counting and accumulating. Second, divide the number of overrun tables obtained in the first step by the total number of all tables in the database to obtain the overrun rate DTRU of the number of records in the database structure form table.

步骤202,根据各数据库的运行指标的检测值,得到所述数据库集群的资源使用率。Step 202: Obtain the resource usage rate of the database cluster according to the detected value of the operation index of each database.

在一个例子中,根据若干个所述检测周期内获取到的各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率。In one example, the resource usage rate of the database cluster is obtained according to the detection values of the operation indicators of each of the databases obtained in several detection cycles.

子步骤301,根据若干个所述检测周期内获取的同一数据库的同一运行指标的检测值,计算数据库的运行指标的统计值。Sub-step 301: Calculate the statistical value of the operation index of the database according to the detection value of the same operation index of the same database obtained in several detection cycles.

承上例,以统计值为均值,获取了N次运行指标,集群共管理K个数据库为例,Continuing from the above example, taking the statistical value as the mean value, N times of running indicators are obtained, and the cluster manages K databases as an example.

运行指标为CPU利用率的情况下,计算预设的检测周期内的单个数据库CPU平均利用率SCLB=(DCU1+DCU2+...+DCUN),以此方式得到K个数据库的CPU平均利用率SCLB1,SCLB2...SCLBK。When the running indicator is CPU utilization, calculate the average CPU utilization of a single database within the preset detection period SCLB=(DCU1+DCU2+...+DCUN), and obtain the average CPU utilization SCLB1 of K databases in this way , SCLB2...SCLBK.

运行指标为内存利用率的情况下,计算周期内单个数据库内存平均利用率SCMB=(DMU1+DMU2+...+DMUN),以此方式得到K个数据库的内存平均利用率SCMB1、SCMB2...SCMBK。When the running indicator is memory utilization, the average memory utilization of a single database in the calculation cycle SCMB=(DMU1+DMU2+...+DMUN), and the average memory utilization of K databases SCMB1, SCMB2... SCMBK.

运行指标为磁盘利用率的情况下,计算周期内单个数据库磁盘平均利用率SDLB=(DDU1+DDU2+...+DDUN),以此得到K个数据库的磁盘平均利用率SDLB1,SDLB2…SDLBK。When the operating indicator is the disk utilization, the average disk utilization SDLB=(DDU1+DDU2+...+DDUN) of a single database during the calculation period, so as to obtain the average disk utilization SDLB1, SDLB2...SDLBK of K databases.

运行指标为结构表数量超限率,假设N次采集中有M次超限,那么该数据库的平均超限率SSNU=(DSNU1+DSNU2+...+DSNUM)/N。The operation index is the overrun rate of the number of structured tables. Assuming that there are M overruns in N collections, the average overrun rate of the database is SSNU=(DSNU1+DSNU2+...+DSNUM)/N.

运行指标为结构表单表记录数量超限率,计算周期内单个数据库的结构表单表记录数平均超限率STRU=(DTRU1+DTRU2+...+DTRUN)/N。The running indicator is the over-limit rate of the number of records in the structured form table, and the average over-limit rate of the number of records in the structured sheet table of a single database in the calculation period STRU=(DTRU1+DTRU2+...+DTRUN)/N.

子步骤302,根据各数据库的运行指标的统计值,计算数据库集群的运行指标的统计值。Sub-step 302: Calculate the statistical value of the operational indicator of the database cluster according to the statistical value of the operational indicator of each database.

承上例,运行指标为CPU利用率的情况下,计算集群的CPU利用率均值CCLB=(SCLB1+SCLB2+...+SCLBK)/K;运行指标为内存利用率的情况下,计算集群的内存利用率均值CMLB=(SCMB1+SCMB2+...+SCMBK)/K;运行指标为磁盘使用率的情况下,计算集群的磁盘使用率均值CDLB=(SDLB1+SDLB2+...+SDLBK)/K;运行指标为结构表数量超限率的情况下,计算集群数据库结构表平均超限率CSNU=(SSNU1+SSNU2+...+SSNUK)/K;运行指标为结构表单表记录数量超限率的情况下,计算集群的数据库表记录数平均超限率CTRU=(STRU1+STRU1+...+STRUK)/K。Continuing from the above example, when the running index is CPU utilization, calculate the average CPU utilization of the cluster CCLB=(SCLB1+SCLB2+...+SCLBK)/K; when the running index is memory utilization, calculate the memory of the cluster Average utilization CMLB=(SCMB1+SCMB2+...+SCMBK)/K; when the operating indicator is disk usage, calculate the average disk usage of the cluster CDLB=(SDLB1+SDLB2+...+SDLBK)/K; When the operating index is the excess rate of the number of structured tables, calculate the average excess rate of the cluster database structure tables CSNU=(SSNU1+SSNU2+...+SSNUK)/K; the operating index is the excess rate of the number of records in the structured table table Next, calculate the average overrun rate of database table records in the cluster CTRU=(STRU1+STRU1+...+STRUK)/K.

子步骤303,对数据库集群的各所述运行指标的统计值进行归一化,并将归一化后的数据库集群的各运行指标的统计值之和作为数据库集群的资源使用率。Sub-step 303, normalize the statistical values of each of the operating indicators of the database cluster, and use the sum of the normalized statistical values of each of the operating indicators of the database cluster as the resource utilization rate of the database cluster.

在一个例子中,计算当前周期内归一化指标集群资源使用率CRR,其计算方法为:CRR=CCLB*CCIF+CMLB*CMIF+CDLB*CDIF+CSNU*CSNIF+CTRU*CTRIF。In an example, the normalized indicator cluster resource usage rate CRR in the current period is calculated, and the calculation method is: CRR=CCLB*CCIF+CMLB*CMIF+CDLB*CDIF+CSNU*CSNIF+CTRU*CTRIF.

步骤203,若所述数据库集群的资源使用率满足预设的扩缩容条件,对所述数据库集群进行扩缩容。Step 203 , if the resource utilization rate of the database cluster satisfies the preset capacity expansion and contraction conditions, expand and contract the database cluster.

在一个例子中,如果CRR大于用户配置的集群缩扩容归一化上限CBNU,则认为需要扩容;如果CRR小于用户配置的集群缩扩容归一化下限CBND,则认为需要缩容。In one example, if the CRR is greater than the user-configured normalized upper limit of cluster shrinking and expansion CBNU, it is considered that capacity expansion is required; if the CRR is less than the user-configured lower normalized lower limit of cluster shrinking and expansion CBNU, it is deemed that the capacity needs to be reduced.

本实施例,获取数据库集群中各数据库的运行指标的检测值;根据各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率;若所述数据库集群的资源使用率满足预设的扩缩容条件,对所述数据库集群进行扩缩容,能够自动实现数据库动态集群缩扩容,并且,采用数据库的运行指标的检测值进行分析,能够获取数据库集群中各数据库的运行状况,使得分析结果更准确。In this embodiment, the detection value of the operation index of each database in the database cluster is obtained; according to the detection value of the operation index of each database, the resource utilization rate of the database cluster is obtained; if the resource utilization rate of the database cluster satisfies the predetermined According to the set expansion and contraction conditions, the database cluster can be expanded and contracted, which can automatically realize the dynamic cluster expansion and contraction of the database, and the operation status of each database in the database cluster can be obtained by using the detection value of the operation index of the database for analysis. make the analysis results more accurate.

本申请的第二实施例涉及一种数据库集群扩缩容方法。本申请第二实施例的流程图如图2所示。The second embodiment of the present application relates to a method for expanding and shrinking the capacity of a database cluster. The flowchart of the second embodiment of the present application is shown in FIG. 2 .

步骤401,获取数据库集群中各数据库的运行指标的检测值。Step 401: Acquire the detection value of the operation index of each database in the database cluster.

步骤402,根据各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率。Step 402: Obtain the resource utilization rate of the database cluster according to the detected value of the operation index of each database.

步骤401至步骤402与第一实施例步骤201至步骤202大致相同,为避免表达上的重复,此处不再赘述。Steps 401 to 402 are substantially the same as steps 201 to 202 of the first embodiment, and to avoid repetition of expressions, they will not be repeated here.

步骤403,若所述数据库集群的资源使用率满足所述扩缩容条件中的扩容条件,根据预获取的数据库配置信息来源方式,获取数据库配置信息。Step 403 , if the resource utilization rate of the database cluster satisfies the capacity expansion condition in the capacity expansion/contraction condition, obtain database configuration information according to the source mode of the pre-obtained database configuration information.

在一个例子中,所述数据库配置信息来源方式包括以下方式的至少其中之一:从所述数据库集群中的至少一个数据库获取、从本地存储模块获取、从远端设备获取。In an example, the source manner of the database configuration information includes at least one of the following manners: acquiring from at least one database in the database cluster, acquiring from a local storage module, and acquiring from a remote device.

示例性的,数据库配置信息来源方式为从所述数据库集群中的至少一个数据库获取,即,拷贝已有租户数据库信息,获取用户配置的源数据库寻址规则,找到任意一个符合规则的源数据库信息,并将配置信息如内存、CPU、磁盘配置,主备策略,备份策略,容灾策略加载到配置列表,其次获取数据库信息,例如索引信息,数据库schema信息,数据库表结构信息等,并分别生成相关脚本,放到脚本列表。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, and find any source database information that meets the rules. , and load configuration information such as memory, CPU, disk configuration, active/standby strategy, backup strategy, and disaster recovery strategy into the configuration list, and then obtain database information, such as index information, database schema information, database table structure information, etc., and generate them separately. Related scripts, put them in the script list.

示例性的,数据库配置信息来源方式为从本地存储模块,即获取本地配置文件,直接加载本地文件中的配置信息到配置列表,并将初始化数据库的脚本加载的脚本列表。Exemplarily, the database configuration information is sourced from a local storage module, that is, a local configuration file is obtained, the configuration information in the local file is directly loaded into the configuration list, and the script list that initializes the database is loaded.

示例性的,数据库配置信息来源方式为从远端设备获取,即获取远端配置文件,将远端的配置文件下载到本地,然后加载下载到本地的文件中的配置信息到配置列表,并将初始化数据库的脚本加载的脚本列表。Exemplarily, the source method of the database configuration information is to obtain from the remote device, that is, to obtain the remote configuration file, download the remote configuration file to the local, and then load the configuration information downloaded to the local file into the configuration list, and set the List of scripts loaded by scripts that initialize the database.

在一个例子中,在下载文件时可以选择流式方式,直接将远端的文件内容加载到内存,而无需下载成本地文件,减少本地磁盘的IO。In one example, the streaming mode can be selected when downloading files, and the content of the remote file can be loaded directly into the memory without downloading the local file, which reduces the IO of the local disk.

步骤404,根据数据库配置信息配置得到所述数据库集群的新增数据库。In step 404, a newly added database of the database cluster is obtained according to the configuration of the database configuration information.

在一个例子中,所述数据库配置信息包括表征数据库硬件性能的第一信息、表征数据处理策略的第二信息以及表征数据库架构的第三信息;根据所述第一信息从数据库资源池申请新的数据库;利用所述第三信息对所述新的数据库进行初始化;利用所述第二信息对初始化成功后的所述新的数据库进行设置,并将设置成功后的所述新的数据库作为所述数据库集群的新增数据库。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 database; use the third information to initialize the new database; use the second information to set the new database after successful initialization, and use the new database after successful setting as the A new database for the database cluster.

示例性的,根据所述第一信息从数据库资源池申请新的数据库,即,根据获取到的配置列表中的第一信息向集群资源池申请数据库资源,例如内存资源、CPU资源、磁盘资源等硬件资源,如果获取不到资源则放弃此次扩容;利用所述第三信息对所述新的数据库进行初始化,即,根据获取到的数据库初始化脚本初始化新申请的数据库,如果初始化数据库失败,则认为扩容失败,将申请到的资源进行清理,返还给资源池;利用所述第二信息对初始化成功后的所述新的数据库进行设置,并将设置成功后的所述新的数据库作为所述数据库集群的新增数据库,即设置数据库相关的数据库策略,例如主备策略,备份策略,容灾策略等;如果设置数据库策略失败,则认为扩容失败,将申请到的资源进行清理,返还给资源池。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, disk resources, etc., from the cluster resource pool according to the first information in the obtained configuration list Hardware resources, if the resources cannot be obtained, then give up this expansion; use the third information to initialize the new database, that is, initialize the newly applied database according to the obtained database initialization script, if the initialization of the database fails, then Consider that the expansion fails, clean up the applied resources, and return them to the resource pool; use the second information to set the new database after the initialization is successful, and use the new database after the setting is successful as the To add a new database to a database cluster, set database policies related to the database, such as active/standby policies, backup policies, disaster recovery policies, etc. If the database policy fails to be set, the expansion will be considered a failure, and the applied resources will be cleaned up and returned to the resources pool.

下面通过一个例子,说明数据库集群的扩容。The following is an example to illustrate the expansion of the database cluster.

在初始化时,资源周期采集模块解析当前用户的配置数据,得到的参数配置如表二所示。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.

表二:初始化参数配置表Table 2: Initialization parameter configuration table

Figure PCTCN2021110956-appb-000003
Figure PCTCN2021110956-appb-000003

Figure PCTCN2021110956-appb-000004
Figure PCTCN2021110956-appb-000004

数据库扩容模块在初始化时获取到当前数据库扩容的方式是从本地存储模块获取,以此得到本地配置文件,将获得的本地配置文件解析得到的信息加载到内存中。The way that the database expansion module obtains the current database expansion during initialization is to obtain the local configuration file from the local storage module, and load the information obtained by parsing the obtained local configuration file into the memory.

当前数据库集群中有2个数据库,在某个预设的检测周期内资源周期采集模块采集到两个数据库的运行指标如表三所示。There are two databases in the current database cluster, and the operation indicators of the two databases collected by the resource period collection module within a preset detection period are shown in Table 3.

表三:两个数据库的运行指标统计表Table 3: Statistics of running indicators of the two databases

Figure PCTCN2021110956-appb-000005
Figure PCTCN2021110956-appb-000005

Figure PCTCN2021110956-appb-000006
Figure PCTCN2021110956-appb-000006

根据10个检测周期内获取的同一数据库的同一运行指标的检测值,计算所述数据库的所述运行指标的统计值,数据如表四所示:According to the detection value of the same operation index of the same database obtained in 10 detection cycles, the statistical value of the operation index of the database is calculated, and the data is shown in Table 4:

表四:计算得到的数据库的运行指标的统计值表Table 4: Statistical value table of the calculated operating indicators of the database

Figure PCTCN2021110956-appb-000007
Figure PCTCN2021110956-appb-000007

Figure PCTCN2021110956-appb-000008
Figure PCTCN2021110956-appb-000008

根据各所述数据库的所述运行指标的统计值,计算所述数据库集群的所述运行指标的统计值,本实施例中统计值为平均值,如表五所示。According to the statistical value of the operation index of each database, the statistical value of the operation index of the database cluster is calculated. In this embodiment, the statistical value is an average value, as shown in Table 5.

表五:计算得到的数据库集群的运行指标的统计值表Table 5: Statistical value table of the calculated operating indicators of the database cluster

指标index 平均值average value 计算方式Calculation CCLBCCLB 0.7530.753 (0.753+0.753)/2(0.753+0.753)/2 CMLBCMLB 0.7550.755 (0.748+0.762)/2(0.748+0.762)/2 CDLBCDLB 0.7410.741 (0.739+0.743)/2(0.739+0.743)/2 CSNUCSNU 0.84770.8477 (0.8418+0.8535)/2(0.8418+0.8535)/2 CTRUCTRU 0.71640.7164 (0.7149+0.7179)/2(0.7149+0.7179)/2

对所述数据库集群的各所述运行指标的统计值进行归一化,并将归一化后的所述数据库集群的各所述运行指标的统计值之和作为所述数据库集群的资源使用率,数据库集群归一化如下:CRR=0.753*0.25+0.755*0.25+0.741*0.25+0.8477*0.15+0.7164*0.15=0.797,由于0.797已经大于集群扩容门限0.7,所以集群统计分析模块将发通知给数据库资源扩容模块处理扩容。Normalize the statistical value of each of the operating indicators of the database cluster, and use the normalized sum of the statistical values of each of the operating indicators of the database cluster as the resource utilization rate of the database cluster , the database cluster is normalized as follows: 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 notification to The database resource expansion module handles expansion.

数据库资源扩容模块收到集群统计分析模块发送的通知后,首先向数据库资源池按CPU、内存、磁盘的配置参数申请资源,申请到资源后创建数据库,即根据所述第一信息从数据库资源池申请新的数据库。After the database resource expansion module receives the notification sent by the cluster statistics analysis module, it first applies for resources from the database resource pool according to the configuration parameters of CPU, memory and disk, and then creates a database after applying for the resources, that is, according to the first information from the database resource pool. Apply for a new database.

然后使用本地配置文件指定的数据库初始化脚本对数据库进行初始化,即利用所述第三信息对所述新的数据库进行初始化。Then, the database is initialized using the database initialization script specified in the local configuration file, that is, the new database is initialized by using the third information.

接下来,配置新数据库的主备策略,备份策略,容灾策略,利用所述第二信息对初始化成功后的所述新的数据库进行设置。Next, configure an active/standby strategy, a backup strategy, and a disaster recovery strategy of the new database, and use the second information to set the new database after successful initialization.

最后,将数据库资源信息通知给资源周期采集模块及集群统计分析模块,以后将新建的数据库增加到统计列表中,至此数据库扩容完成。Finally, the database resource information is notified to the resource period collection module and the cluster statistics analysis module, and the newly created database is added to the statistics list later, and the database expansion is completed.

本申请的第二实施例在实现数据库集群扩缩容时考虑了CPU利用率,内存占用情况等动态因素进行数据库扩容的分析,以此判断数据库是否满足扩缩容条件的扩容条件,来实现扩容,使得扩容的时机更加准确,另外,能自动进行数据库的扩容不需要人工参与,节省人力资源。In the second embodiment of the present application, dynamic factors such as CPU utilization and memory occupancy are considered when implementing the expansion and contraction of the database cluster to analyze the expansion of the database, so as to determine whether the database meets the expansion conditions of the expansion and contraction conditions, so as to realize the expansion. , which makes the timing of expansion more accurate. In addition, it can automatically expand the database without manual participation, saving human resources.

本申请的第三实施例涉及一种数据库集群扩缩容方法。第三实施例与第一实施例大致相同,主要区别之处在于:若所述数据库集群的资源使用率满足所述扩缩容条件中的缩容条件,对同一数据库的各所述运行指标的统计值进行归一化,并将归一化后的所述数据库的各所述运行指标之和作为所述数据库的资源使用率;根据各所述数据库的资源使用率和所述数据库集群的资源使用率,从各所述数据库中选出候选数据库;基于所述候选数据库对所述数据库集群进行缩容。The third embodiment of the present application relates to a method for expanding and shrinking the capacity of a database cluster. The third embodiment is roughly the same as the first embodiment, except that: if the resource utilization rate of the database cluster satisfies the shrinking conditions in the expansion and shrinkage conditions, the operation indicators of the same database The statistical value is normalized, and the sum of the normalized operation indicators of the database is used as the resource utilization rate of the database; according to the resource utilization rate of each database and the resources of the database cluster According to the utilization rate, candidate databases are selected from each of the databases; and the database cluster is scaled down based on the candidate databases.

本申请第三实施例的流程图如图5所示。The flowchart of the third embodiment of the present application is shown in FIG. 5 .

步骤501,获取数据库集群中各数据库的运行指标的检测值。Step 501: Acquire the detection value of the running index of each database in the database cluster.

步骤502,根据各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率。Step 502: Obtain the resource usage rate of the database cluster according to the detected values of the operating indicators of each database.

步骤501至502与实施例步骤201至202大致相同,此处不再赘述。Steps 501 to 502 are substantially the same as steps 201 to 202 of the embodiment, and are not repeated here.

步骤503,若所述数据库集群的资源使用率满足所述扩缩容条件中的缩容条件,对同一数据库的各所述运行指标的统计值进行归一化,并将归一化后的所述数据库的各所述运行指标之和作为所述数据库的资源使用率。Step 503: If the resource utilization rate of the database cluster satisfies the capacity reduction condition in the capacity expansion/contraction condition, normalize the statistical value of each of the operation indicators of the same database, and normalize all the normalized data. The sum of each of the operational indicators of the database is used as the resource utilization rate of the database.

在一个例子中,从集群统计分析模块获取当前周期内数据库集群中每个数据库资源使用率归一化指标(SRR)=SCLB*CCIF+SCMB*CMIF+SDLB*CDIF+SSNU*CSNIF+STRU*CTRIF。In an example, the normalized index (SRR) of each database resource usage rate in the database cluster in the current period is obtained from the cluster statistical analysis module = SCLB*CCIF+SCMB*CMIF+SDLB*CDIF+SSNU*CSNIF+STRU*CTRIF .

步骤504,根据各所述数据库的资源使用率和所述数据库集群的资源使用率,从各所述数据库中选出候选数据库。Step 504: Select candidate databases from each of the databases according to the resource usage rate of each of the databases and the resource usage rate of the database cluster.

在一个例子中,将各所述数据库中资源使用率小于所述数据库集群的资源使用率的数据库,作为所述候选数据库。In an example, a database whose resource usage rate in each of the databases is lower than the resource usage rate of the database cluster is used as the candidate database.

示例性的,从集群从集群统计分析模块获取当前周期内集群资源使用率归一化指标(CRR);将每各数据库的SSR和得到的集群CRR对比,将低于CRR的数据库的信息加入到待处理列表L,即候选数据库。Exemplarily, from the cluster to obtain the cluster resource utilization rate normalization index (CRR) in the current cycle from the cluster statistics analysis module; compare the SSR of each database with the obtained cluster CRR, and add the information of the database lower than the CRR to the data. The pending list L is the candidate database.

步骤505,基于所述候选数据库对所述数据库集群进行缩容。Step 505 , scale down the database cluster based on the candidate database.

在一个例子中,若所述候选数据库为一个,将所述候选数据库作为待缩减数据库,将所述待缩减数据库合并到各所述数据库中除所述待缩减数据库外的其他数据库中。In an example, if the candidate database is one, the candidate database is used as the database to be reduced, and the database to be reduced is merged into other databases except the database to be reduced in each of the databases.

若所述候选数据库为大于或等于2个,将多个所述候选数据库中的至少一个候选数据库作为待缩减数据库,将所述待缩减数据库合并到多个所述候选数据库中除所述待缩减数据库外的其他候选数据库中;清理所述待缩减数据库。If the number of candidate databases is greater than or equal to 2, at least one candidate database among the multiple candidate databases is used as the database to be reduced, and the databases to be reduced are merged into the multiple candidate databases except the to-be-reduced database. In other candidate databases outside the database; clean up the database to be reduced.

在一个例子中,将多个所述候选数据库按照资源使用率由小到大的顺序进行排序并得到第一序列,将多个所述候选数据库按照资源使用率由大到小的顺序进行排序并得到第二序列;将所述第一序列和所述第二序列中排序号相同的两个候选数据库作为一个组,并筛选出多个不同的组;对于筛选出的每个组,将所述组内的其中一个候选数据库合并到所述组内的另一个候选数据库中;所述其中一个候选数据库作为所述待缩减数据库。In one example, the plurality of candidate databases are sorted in descending order of resource usage to obtain a first sequence, and the plurality of candidate databases are sorted in descending order of resource usage, and the first sequence is obtained. Obtain the second sequence; take two candidate databases with the same order number in the first sequence and the second sequence as a group, and filter out multiple different groups; One of the candidate databases in the group is merged into another candidate database in the group; the one of the candidate databases serves as the database to be reduced.

在一个例子中,清理待缩减数据库,可以基于预设的清理规则清理所述待缩减数据库,清理规则可以有以下集中,删除所述待缩减数据库中的数据,并将所述待缩减数据库从所述数据库集群中移除;或者,仅删除所述待缩减数据库中的数据。In one example, to clean up the database to be reduced, the database to be reduced can be cleaned based on a preset cleaning rule, and the cleaning rules can be as follows: delete the data in the database to be reduced, and remove the database to be reduced from all delete from the database cluster; or, delete only the data in the database to be reduced.

示例性的,将待处理列表L按SRR由小到大进行排序得到第一序列Ls,按从大到小排序得到第二序列Lb;同时遍历列表Ls和Lb两个列表,当某次遍历时两个列表的数据库指标分别为,Lsc,Lbc,如果Lsc,Lbc的均值小于等于CRR,则认为两个数据库可以进行合并,否则不允许合并,将能够合并的两个数据库放到列表H中,得到可合并数据库列表,值得说明的是,合并的数据库是两个不同的候选数据库。Exemplarily, the list L to be processed is sorted according to SRR from small to large to obtain the first sequence Ls, and the second sequence Lb is obtained by sorting from large to small; the two lists Ls and Lb are traversed at the same time, when a certain traversal is performed. The database indicators of the two lists are Lsc and Lbc. If the mean value of Lsc and Lbc is less than or equal to CRR, it is considered that the two databases can be merged. Otherwise, it is not allowed to merge. A list of mergeable databases is obtained. It is worth noting that the merged databases are two different candidate databases.

然后,依次遍历可合并列表H,合并时,以资源占用指标低的为源数据库,以资源占用高的为目标数据库,首先判断目标数据库是否包含源数据库的表结构,索引等信息,若不存在则先创建,若存在则直接拷贝数据。特别的,为保证数据的安全性,在执行数据拷贝前需要执行对数据库的备份操作,如果在拷贝过程中出现异常则使用备份数据,将数据库恢复到 合并前状态。Then, traverse the mergeable list H in turn. When merging, take the source database with the low resource occupancy index as the source database, and take the resource occupancy index as the target database, first determine whether the target database contains the table structure, index and other information of the source database, if not Create it first, and copy the data directly if it exists. In particular, to ensure data security, it is necessary to perform a database backup operation before performing data copying. If an exception occurs during the copying process, use the backup data to restore the database to the state before merging.

最后,合并成功后,如果用户配置的清理规则为:全部清理,资源交回资源池,则删除数据库的所有信息,并将数据库资源释放,交还给资源池,并从集群统计分析模块中移除清理后的数据库;如果用户配置的清理规则为:只清理数据,资源不交回资源池,则保留当前数据库的资源,不交回资源池。Finally, after the merge is successful, if the cleanup rules configured by the user are: clean up all, return the resources to the resource pool, delete all the information of the database, release the database resources, return them to the resource pool, and remove them from the cluster statistical analysis module Cleaned database; if the cleanup rule configured by the user is: only data is cleaned, and resources are not returned to the resource pool, the resources of the current database are retained and not returned to the resource pool.

下面用一个例子,说明数据库集群的缩容。The following uses an example to illustrate the scaling of the database cluster.

在初始化时,资源周期采集模块解析当前用户的配置数据,本实施例的配置数据与第二实施例相同,如表二所示。During initialization, the resource period 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 2.

数据库缩容模块在初始化时解析加载到当前数据库的缩容的方式,假设当前资源池对某个租户已经使用2个数据库,资源周期采集模块获取到的两个数据库的运行指标如表六所示。The database shrinking module parses the shrinking method loaded into the current database during initialization. Assuming that the current resource pool has used two databases for a tenant, the operating indicators of the two databases obtained by the resource cycle collection module are shown in Table 6. .

表六:资源周期采集模块获取到的两个数据库的运行指标统计表Table 6: Statistics of the operation indicators of the two databases obtained by the resource period collection module

Figure PCTCN2021110956-appb-000009
Figure PCTCN2021110956-appb-000009

Figure PCTCN2021110956-appb-000010
Figure PCTCN2021110956-appb-000010

根据若干个所述检测周期内获取的同一数据库的同一运行指标的检测值,计算所述数据库的所述运行指标的统计值,数据如表七所示:According to the detection values of the same operation index of the same database obtained in several detection cycles, the statistical value of the operation index of the database is calculated, and the data is shown in Table 7:

表七:计算得到的数据库的运行指标的统计值表Table 7: Statistical value table of the calculated operating indicators of the database

Figure PCTCN2021110956-appb-000011
Figure PCTCN2021110956-appb-000011

根据各所述数据库的所述运行指标的统计值,计算所述数据库集群的所述运行指标的统计值,如表八所示。According to the statistical value of the operation index of each database, the statistical value of the operation index of the database cluster is calculated, as shown in Table 8.

表八:计算得到的数据库集群的运行指标的统计值表Table 8: Statistical value table of the calculated operating indicators of the database cluster

指标index 指标值Index value 计算方式Calculation CCLBCCLB 0.13650.1365 (0.158+0.115)/2(0.158+0.115)/2 CMLBCMLB 0.1160.116 (0.118+0.114)/2(0.118+0.114)/2 CDLBCDLB 0.1210.121 (0.122+0.12)/2(0.122+0.12)/2 CSNUCSNU 00 ((0)+(0))/2((0)+(0))/2 CTRUCTRU 0.04260.0426 ((0.0629)+(0.0224))/2((0.0629)+(0.0224))/2

各个资源平均指标乘以相应的归一化因子后得到:The average index of each resource is multiplied by the corresponding normalization factor to obtain:

集群归一化指标CRR=0.1365*0.25+0.116*0.25+0.121*0.25+0*0.15+0.0426*0.15=0.0998,由于0.0998已经小于集群缩容门限0.3,所以集群统计分析模块将发通知给数据库资源缩容模块处理缩容。The cluster normalization index CRR=0.1365*0.25+0.116*0.25+0.121*0.25+0*0.15+0.0426*0.15=0.0998, since 0.0998 is less than the cluster shrinkage threshold of 0.3, the cluster statistical analysis module will send a notification to the database resource The shrink module handles shrinking.

数据库缩容模块收到集群统计分析模块发送的通知后,首先单个数据库的资源指标归一化率。After the database shrinking module receives the notification sent by the cluster statistical analysis module, it first normalizes the resource indicators of a single database.

数据库1的资源使用率:Resource usage of database 1:

SRR1=0.158*0.25+0.118*0.25+0.122*0.25+0*0.15+0.0698*0.15=0.02199。SRR1=0.158*0.25+0.118*0.25+0.122*0.25+0*0.15+0.0698*0.15=0.02199.

数据库2的资源使用率:Resource usage of database 2:

SRR2=0.1365*0.25+0.116*0.25+0.121*0.25+0*0.15+0.0461*0.15=0.01812。SRR2=0.1365*0.25+0.116*0.25+0.121*0.25+0*0.15+0.0461*0.15=0.01812.

可选的,两个数据库均值(0.02199+0.01812)/2=0.02005<=CRR,因此两个数据库数据可以合并。Optionally, the mean of the two databases is (0.02199+0.01812)/2=0.02005<=CRR, so the data of the two databases can be merged.

由于数据库2的资源利用率更小,因此将数据库2作为源数据库,数据库1作为目标数据库进行合并。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 consolidation.

合并前首先备份数据库1和数据库2的数据,然后判断数据库1中是否包含数据库2的全部完整表结构,如果不存在则在数据库1中补充相关内容。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, and if not, supplement relevant content in database 1.

其次,待表结构补充完成后将数据库2的数据拷贝到数据库1。Next, copy the data of database 2 to database 1 after the table structure is supplemented.

再次,数据拷贝完成后,将数据库资源释放,并将数据库2的信息通知给资源周期采集模块及集群统计分析模块释放。至此数据库扩容完成。Thirdly, after the data copying is completed, the database resources are released, and the information of the database 2 is notified to the resource period collection module and the cluster statistical analysis module for release. At this point, the database expansion is completed.

本申请的第三实施例在实现数据库集群扩缩容时考虑了CPU利用率,内存占用情况等动态因素进行数据库扩容的分析,以此判断数据库是否满足扩缩容条件的缩容条件,来实现扩容,使得扩容的时机更加准确,另外,能自动进行数据库的扩容不需要人工参与,节省人力资源,周期性的获取运行指标的检测值,实现缩容,相比于相关技术中只考虑某个时刻的值,本申请实施例更加精确,误差小。In the third embodiment of the present application, dynamic factors such as CPU utilization and memory occupancy are taken into account when implementing the expansion and contraction of the database cluster to analyze the expansion of the database, so as to determine whether the database satisfies the expansion and contraction conditions. Expansion makes the timing of expansion more accurate. In addition, the expansion of the database can be performed automatically without manual participation, saving human resources, and periodically obtaining the detection value of the operation index to realize the capacity reduction. Compared with the related technologies, only considering a certain The value of the time, the embodiment of the present application is more accurate, and the error is small.

本申请第四实施例涉及一种服务系统,如图6所示,包括至少一个处理器601;以及,与所述至少一个处理器通信连接的存储器602;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述的数据库集群扩缩容方法。The fourth embodiment of the present application relates to a service system, as shown in FIG. 6 , comprising at least one processor 601; and a memory 602 communicatively connected to the at least one processor; wherein the memory stores data that can be instructions executed by the at least one processor, where the instructions are executed by the at least one processor, so that the at least one processor can execute the foregoing method for expanding or shrinking a database cluster.

其中,存储器和处理器采用总线方式连接,总线可以包括任意数量的互联的总线和桥, 总线将一个或多个处理器和存储器的各种电路连接在一起。总线还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路连接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口在总线和收发机之间提供接口。收发机可以是一个元件,也可以是多个元件,比如多个接收器和发送器,提供用于在传输介质上与各种其他装置通信的单元。经处理器处理的数据通过天线在无线介质上进行传输,进一步,天线还接收数据并将数据传送给处理器。The memory and the processor are connected by a bus, and the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors and various circuits of the memory. The bus may also connect together various other circuits, such as peripherals, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides the interface between the bus and the transceiver. A transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing a means for communicating with various other devices over a transmission medium. The data processed by the processor is transmitted on the wireless medium through the antenna, and further, the antenna also receives the data and transmits the data to the processor.

处理器负责管理总线和通常的处理,还可以提供各种功能,包括定时,外围接口,电压调节、电源管理以及其他控制功能。而存储器可以被用于存储处理器在执行操作时所使用的数据。The processor manages the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Instead, memory may be used to store data used by the processor in performing operations.

本申请第五实施例涉及一种计算机可读存储介质,存储有计算机程序。计算机程序被处理器执行时实现上述方法实施例。The fifth embodiment of the present application relates to a computer-readable storage medium storing a computer program. The above method embodiments are implemented when the computer program is executed by the processor.

即,本领域技术人员可以理解,实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。That is, those skilled in the art can understand that all or part of the steps in the method of implementing the above embodiments can be completed by instructing relevant hardware through a program, and the program is stored in a storage medium and includes several instructions to make a device ( It may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .

本领域的普通技术人员可以理解,上述各实施方式是实现本申请的具体实施例,而在实际应用中,可以在形式上和细节上对其作各种改变,而不偏离本申请的精神和范围。Those of ordinary skill in the art can understand that the above-mentioned embodiments are specific examples for realizing the present application, and in practical applications, various changes can be made in form and details without departing from the spirit and the spirit of the present application. scope.

Claims (15)

一种数据库集群扩缩容方法,包括:A method for expanding and shrinking a database cluster, comprising: 获取数据库集群中各数据库的运行指标的检测值;Obtain the detection value of the running indicators of each database in the database cluster; 根据各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率;Obtaining the resource usage rate of the database cluster according to the detected value of the operation index of each of the databases; 若所述数据库集群的资源使用率满足预设的扩缩容条件,对所述数据库集群进行扩缩容。If the resource utilization rate of the database cluster satisfies the preset capacity expansion and contraction conditions, the database cluster is expanded and contracted. 根据权利要求1所述的方法,其中,所述获取数据库集群中各数据库的运行指标的检测值,包括:The method according to claim 1, wherein the acquiring the detection value of the operation indicator of each database in the database cluster comprises: 根据预设的检测周期,周期性地获取数据库集群中各数据库的运行指标的检测值;According to the preset detection period, periodically obtain the detection value of the operation indicators of each database in the database cluster; 所述根据各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率,包括:The obtaining of the resource utilization rate of the database cluster according to the detection value of the operation indicators of each of the databases includes: 根据若干个所述检测周期内获取到的各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率。The resource usage rate of the database cluster is obtained according to the detected values of the operation indicators of each of the databases obtained in several of the detection cycles. 根据权利要求2所述的方法,其中,所述运行指标的数量大于或等于2;所述根据若干个所述检测周期内获取到的各所述数据库的运行指标的检测值,得到所述数据库集群的资源使用率,包括:The method according to claim 2, wherein the number of the operation indicators is greater than or equal to 2; the database is obtained according to the detection values of the operation indicators of each of the databases obtained in several of the detection cycles The resource usage of the cluster, including: 根据若干个所述检测周期内获取的同一数据库的同一运行指标的检测值,计算所述数据库的所述运行指标的统计值;Calculate the statistic value of the operation index of the database according to the detection value of the same operation index of the same database obtained in several detection cycles; 根据各所述数据库的所述运行指标的统计值,计算所述数据库集群的所述运行指标的统计值;Calculate the statistical value of the operational indicator of the database cluster according to the statistical value of the operational indicator of each of the databases; 对所述数据库集群的各所述运行指标的统计值进行归一化,并将归一化后的所述数据库集群的各所述运行指标的统计值之和作为所述数据库集群的资源使用率。Normalize the statistical value of each of the operating indicators of the database cluster, and use the normalized sum of the statistical values of each of the operating indicators of the database cluster as the resource utilization rate of the database cluster . 根据权利要求1或2所述的方法,其中,所述运行指标为以下指标的其中之一:CPU利用率、内存利用率、磁盘利用率、结构表数量超限率、结构表单表记录数量超限率。The method according to claim 1 or 2, wherein the operation indicator is one of the following indicators: CPU utilization, memory utilization, disk utilization, the rate of exceeding the limit of the number of structure tables, and the number of records in the structure table table exceeding the limit. rate limit. 根据权利要求4所述的方法,其中,在所述运行指标为CPU利用率、或者内存利用率、或者磁盘利用率的情况下,所述获取数据库集群中各数据库的运行指标的检测值包括:采集得到各所述数据库的运行指标的检测值;The method according to claim 4, wherein, in the case that the operation index is CPU utilization, memory utilization, or disk utilization, the acquiring the detection value of the operation index of each database in the database cluster comprises: Collect and obtain the detection value of the operation index of each described database; 在所述运行指标为结构表数量超限率的情况下,所述获取数据库集群中各数据库的运行指标的检测值,包括:采集得到各所述数据库的结构表数量,并根据预设的结构表数量门限值计算各所述数据库的结构表数量超限率;In the case that the operation indicator is the over-limit rate of the number of structured tables, the acquiring the detection value of the operation indicator of each database in the database cluster includes: collecting and obtaining the number of structured tables of each database, and according to a preset structure The table quantity threshold value calculates the over-limit rate of the structure table quantity of each described database; 在所述运行指标为结构表单表记录数量超限率的情况下,所述获取数据库集群中各数据库的运行指标的检测值,包括:采集得到各所述数据库的结构表单表记录数量,并根据预设的结构表单表记录数量门限值计算各所述数据库的结构表单表记录数量超限率。In the case that the operation indicator is the over-limit rate of the number of records in the structure form table, the acquiring the detection value of the operation index of each database in the database cluster includes: collecting and obtaining the number of records in the structure table table of each database, and according to The preset structural form table record quantity threshold value is used to calculate the over-limit rate of the structural form table records of each database. 根据权利要求1所述的方法,其中,所述若所述数据库集群的资源使用率满足预设的扩缩容条件,对所述数据库集群进行扩缩容,包括:The method according to claim 1, wherein, if the resource utilization rate of the database cluster satisfies a preset capacity expansion and contraction condition, expanding or shrinking the database cluster comprises: 若所述数据库集群的资源使用率满足所述扩缩容条件中的扩容条件,根据预获取的数据库配置信息来源方式,获取数据库配置信息;If the resource utilization rate of the database cluster satisfies the expansion conditions in the expansion and contraction conditions, obtain database configuration information according to the source mode of the pre-obtained database configuration information; 根据所述数据库配置信息配置得到所述数据库集群的新增数据库。The newly added database of the database cluster is obtained according to the configuration of the database configuration information. 根据权利要求6所述的方法,其中,所述数据库配置信息包括表征数据库硬件性能的第一信息、表征数据处理策略的第二信息以及表征数据库架构的第三信息;The method of claim 6, wherein the database configuration information includes first information representing database hardware performance, second information representing data processing strategies, and third information representing database architecture; 所述根据所述数据库配置信息配置得到所述数据库集群的新增数据库,包括:The configuring and obtaining the newly added database of the database cluster according to the database configuration information includes: 根据所述第一信息从数据库资源池申请新的数据库;Apply for a new database from the database resource pool according to the first information; 利用所述第三信息对所述新的数据库进行初始化;using the third information to initialize the new database; 利用所述第二信息对初始化成功后的所述新的数据库进行设置,并将设置成功后的所述新的数据库作为所述数据库集群的新增数据库。The new database after successful initialization is set by using the second information, and the new database after the successful setting is used as the newly added database of the database cluster. 根据权利要求6所述的方法,其中,所述数据库配置信息来源方式包括以下方式的至少其中之一:从所述数据库集群中的至少一个数据库获取、从本地存储模块获取、从远端设备获取。The method according to claim 6, wherein the source manner of the database configuration information comprises at least one of the following manners: acquiring from at least one database in the database cluster, acquiring from a local storage module, acquiring from a remote device . 根据权利要求3所述的方法,其中,所述若所述数据库集群的资源使用率满足预设的扩缩容条件,对所述数据库集群进行扩缩容,包括:The method according to claim 3, wherein, if the resource utilization rate of the database cluster satisfies a preset capacity expansion and contraction condition, expanding or shrinking the database cluster comprises: 若所述数据库集群的资源使用率满足所述扩缩容条件中的缩容条件,对同一数据库的各所述运行指标的统计值进行归一化,并将归一化后的所述数据库的各所述运行指标之和作为所述数据库的资源使用率;If the resource usage rate of the database cluster satisfies the scaling conditions in the scaling conditions, normalize the statistical values of the operating indicators of the same database, and normalize the normalized database The sum of each of the operating indicators is used as the resource utilization rate of the database; 根据各所述数据库的资源使用率和所述数据库集群的资源使用率,从各所述数据库中选出候选数据库;According to the resource usage rate of each of the databases and the resource usage rate of the database cluster, a candidate database is selected from each of the databases; 基于所述候选数据库对所述数据库集群进行缩容。The database cluster is scaled down based on the candidate database. 根据权利要求9所述的方法,其中,所述根据各所述数据库的资源使用率和所述数据库集群的资源使用率,从各所述数据库中选出候选数据库,包括:The method according to claim 9, wherein the selecting a candidate database from each of the databases according to the resource usage rate of each of the databases and the resource usage rate of the database cluster comprises: 将各所述数据库中资源使用率小于所述数据库集群的资源使用率的数据库,作为所述候选数据库;Using a database whose resource usage rate in each of the databases is less than the resource usage rate of the database cluster as the candidate database; 所述基于所述候选数据库对所述数据库集群进行缩容,包括:The shrinking of the database cluster based on the candidate database includes: 若所述候选数据库为一个,将所述候选数据库作为待缩减数据库,将所述待缩减数据库合并到各所述数据库中除所述待缩减数据库外的其他数据库中;If the candidate database is one, the candidate database is used as the database to be reduced, and the database to be reduced is merged into other databases except the database to be reduced in each of the databases; 若所述候选数据库为大于或等于2个,将多个所述候选数据库中的至少一个候选数据库作为待缩减数据库,将所述待缩减数据库合并到多个所述候选数据库中除所述待缩减数据库外的其他候选数据库中;If the number of candidate databases is greater than or equal to 2, at least one candidate database among the multiple candidate databases is used as the database to be reduced, and the databases to be reduced are merged into the multiple candidate databases except the to-be-reduced database. In other candidate databases other than the database; 清理所述待缩减数据库。Clean up the database to be reduced. 根据权利要求10所述的方法,其中,所述将多个候选数据库中的至少一个候选数据库作为待缩减数据库,将所述待缩减数据库合并到多个所述候选数据库中除所述待缩减数据库外的其他候选数据库中,包括:The method according to claim 10, wherein the at least one candidate database among the plurality of candidate databases is used as the database to be reduced, and the database to be reduced is merged into the plurality of candidate databases except the database to be reduced In addition to other candidate databases, including: 将多个所述候选数据库按照资源使用率由小到大的顺序进行排序并得到第一序列,将多个所述候选数据库按照资源使用率由大到小的顺序进行排序并得到第二序列;Sorting the multiple candidate databases in descending order of resource utilization to obtain a first sequence, and sorting the multiple candidate databases in descending order of resource utilization to obtain a second sequence; 将所述第一序列和所述第二序列中排序号相同的两个候选数据库作为一个组,并筛选出多个不同的组;Taking two candidate databases with the same order number in the first sequence and the second sequence as one group, and filtering out a plurality of different groups; 对于筛选出的每个组,将所述组内的其中一个候选数据库合并到所述组内的另一个候选数据库中;所述其中一个候选数据库作为所述待缩减数据库。For each group that is screened out, one of the candidate databases in the group is merged into another candidate database in the group; the one of the candidate databases is used as the database to be reduced. 根据权利要求11所述的方法,其中,所述其中一个候选数据库为所述组内两个候选数据库中资源使用率较小的候选数据库。The method according to claim 11, wherein the one of the candidate databases is a candidate database with a smaller resource usage rate among the two candidate databases in the group. 根据权利要求10-12任一项所述的方法,其中,所述清理所述待缩减数据库,包括:The method according to any one of claims 10-12, wherein the cleaning the to-be-reduced database comprises: 基于预设的清理规则清理所述待缩减数据库;所述清理规则包括:删除所述待缩减数据库中的数据,并将所述待缩减数据库从所述数据库集群中移除;或者,仅删除所述待缩减数据库中的数据。Clean up the database to be reduced based on a preset cleaning rule; the cleaning rule includes: deleting the data in the database to be reduced, and removing the database to be reduced from the database cluster; or, deleting only the database to be reduced Describe the data in the database to be reduced. 一种服务系统,包括:A service system including: 至少一个处理器;以及,at least one processor; and, 与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein, 所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求1至13中任一所述的数据库集群扩缩容方法。the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the execution of any one of claims 1 to 13 database cluster scaling method. 一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1至13中任一所述的数据库集群扩缩容方法。A computer-readable storage medium storing a computer program, when the computer program is executed by a processor, the method for expanding or shrinking a database cluster according to any one of claims 1 to 13 is implemented.
PCT/CN2021/110956 2020-09-29 2021-08-05 Database cluster capacity expansion and reduction method, service system and storage medium Ceased WO2022068392A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011049631.4A CN114328440B (en) 2020-09-29 2020-09-29 Database cluster expansion and contraction method, service system, and storage medium
CN202011049631.4 2020-09-29

Publications (1)

Publication Number Publication Date
WO2022068392A1 true WO2022068392A1 (en) 2022-04-07

Family

ID=80951068

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/110956 Ceased WO2022068392A1 (en) 2020-09-29 2021-08-05 Database cluster capacity expansion and reduction method, service system and storage medium

Country Status (2)

Country Link
CN (1) CN114328440B (en)
WO (1) WO2022068392A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979276A (en) * 2022-05-13 2022-08-30 深信服科技股份有限公司 Resource dynamic scheduling method, device, equipment and storage medium
CN115016985A (en) * 2022-06-27 2022-09-06 平安付科技服务有限公司 Data sub-database method and system
CN115065685A (en) * 2022-06-21 2022-09-16 中国工商银行股份有限公司 Cloud computing resource scheduling method, device, equipment and medium
CN115185774A (en) * 2022-07-11 2022-10-14 河北平普数政科技有限公司 Automatic database based on open source technology
CN116185635A (en) * 2023-02-24 2023-05-30 阿里巴巴(中国)有限公司 Data processing, elastic scaling method, computing device and computer storage medium
CN118245471A (en) * 2024-05-29 2024-06-25 济南浪潮数据技术有限公司 Database management method, computer device, storage medium and program product

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115269558A (en) * 2022-08-16 2022-11-01 中国工商银行股份有限公司 Data storage method, apparatus, device, storage medium and program product
CN116048806B (en) * 2023-01-18 2025-08-01 福建天晴数码有限公司 Method and system for dynamic capacity expansion and contraction of stateful service
CN116595100B (en) * 2023-05-30 2025-11-07 中电科金仓(北京)科技股份有限公司 Capacity expansion method for distributed database

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170011082A1 (en) * 2015-07-07 2017-01-12 Futurewei Technologies, Inc. Mechanisms for merging index structures in molap while preserving query consistency
CN108469989A (en) * 2018-03-13 2018-08-31 广州西麦科技股份有限公司 A kind of reaction type based on clustering performance scalable appearance method and system automatically
CN109766182A (en) * 2018-12-18 2019-05-17 平安科技(深圳)有限公司 The scalable appearance method, apparatus of system resource dynamic, computer equipment and storage medium
CN110019503A (en) * 2017-09-01 2019-07-16 北京京东尚科信息技术有限公司 The dilatation of Redis cluster and/or the method and device of capacity reducing
CN111355606A (en) * 2020-02-10 2020-06-30 天津大学 Web application-oriented container cluster adaptive scaling system and method
CN111464355A (en) * 2020-03-31 2020-07-28 北京金山云网络技术有限公司 Method and device for controlling expansion capacity of Kubernetes container cluster and network equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110321214A (en) * 2018-03-29 2019-10-11 阿里巴巴集团控股有限公司 A kind of data query method, device and equipment
CN109343965A (en) * 2018-10-31 2019-02-15 北京金山云网络技术有限公司 Resource adjustment method, device, cloud platform and server
CN109783577B (en) * 2019-01-05 2021-10-08 咪付(广西)网络技术有限公司 A policy-based cloud database elastic scaling method
CN110753112A (en) * 2019-10-23 2020-02-04 北京百度网讯科技有限公司 Elastic scaling method and device for cloud service

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170011082A1 (en) * 2015-07-07 2017-01-12 Futurewei Technologies, Inc. Mechanisms for merging index structures in molap while preserving query consistency
CN110019503A (en) * 2017-09-01 2019-07-16 北京京东尚科信息技术有限公司 The dilatation of Redis cluster and/or the method and device of capacity reducing
CN108469989A (en) * 2018-03-13 2018-08-31 广州西麦科技股份有限公司 A kind of reaction type based on clustering performance scalable appearance method and system automatically
CN109766182A (en) * 2018-12-18 2019-05-17 平安科技(深圳)有限公司 The scalable appearance method, apparatus of system resource dynamic, computer equipment and storage medium
CN111355606A (en) * 2020-02-10 2020-06-30 天津大学 Web application-oriented container cluster adaptive scaling system and method
CN111464355A (en) * 2020-03-31 2020-07-28 北京金山云网络技术有限公司 Method and device for controlling expansion capacity of Kubernetes container cluster and network equipment

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979276A (en) * 2022-05-13 2022-08-30 深信服科技股份有限公司 Resource dynamic scheduling method, device, equipment and storage medium
CN114979276B (en) * 2022-05-13 2024-02-23 深信服科技股份有限公司 Dynamic scheduling method, device, equipment and storage medium for resources
CN115065685A (en) * 2022-06-21 2022-09-16 中国工商银行股份有限公司 Cloud computing resource scheduling method, device, equipment and medium
CN115065685B (en) * 2022-06-21 2024-06-07 中国工商银行股份有限公司 Cloud computing resource scheduling method, device, equipment and medium
CN115016985A (en) * 2022-06-27 2022-09-06 平安付科技服务有限公司 Data sub-database method and system
CN115185774A (en) * 2022-07-11 2022-10-14 河北平普数政科技有限公司 Automatic database based on open source technology
CN115185774B (en) * 2022-07-11 2023-07-07 河北平普数政科技有限公司 Automatic database based on open source technology
CN116185635A (en) * 2023-02-24 2023-05-30 阿里巴巴(中国)有限公司 Data processing, elastic scaling method, computing device and computer storage medium
CN118245471A (en) * 2024-05-29 2024-06-25 济南浪潮数据技术有限公司 Database management method, computer device, storage medium and program product

Also Published As

Publication number Publication date
CN114328440B (en) 2025-07-01
CN114328440A (en) 2022-04-12

Similar Documents

Publication Publication Date Title
WO2022068392A1 (en) Database cluster capacity expansion and reduction method, service system and storage medium
CN111355606B (en) Web application-oriented container cluster self-adaptive expansion and contraction system and method
CN110865992A (en) A retrieval library management method, retrieval method, device and medium
US9960983B2 (en) Monitoring item selection method and device, and storage medium
CN107346270B (en) Method and system for real-time computation based radix estimation
US7895247B2 (en) Tracking space usage in a database
CN110147470B (en) Cross-machine-room data comparison system and method
US10250550B2 (en) Social message monitoring method and apparatus
CN113064554B (en) Optimal storage node matching method, device and medium based on distributed storage
CN120407197A (en) Server resource allocation method and device, storage medium and electronic device
CN107423188B (en) Log processing method and device
CN106656522A (en) Data calculation method and system of cross-data center
US8849833B1 (en) Indexing of data segments to facilitate analytics
CN111611463A (en) A Distributed Web Crawler Optimization Method Based on Scrapy-Redis
CN111324513B (en) Monitoring management method and system for artificial intelligence development platform
CN104580498B (en) A kind of adaptive cloud management platform
CN117667327A (en) Job scheduling method, scheduler and related equipment
CN119183115B (en) Equipment correlation ad hoc network method, system, terminal and readable storage medium
EP2833279A1 (en) Method and apparatus for managing data segments for analytics queries
Chihoub et al. Chameleon: customized application-specific consistency by means of behavior modeling
CN115202880B (en) Data processing method, device, electronic equipment and computer readable storage medium
CN118796451A (en) Computing power reconstruction configuration method and device
JPH11232153A (en) Database system
CN119645664A (en) Dynamic resource management method, electronic equipment and computer readable storage medium
CN118503221A (en) Data processing method and system for sharing document diversified data sources

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21874054

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 11.08.2023)

122 Ep: pct application non-entry in european phase

Ref document number: 21874054

Country of ref document: EP

Kind code of ref document: A1