Database processing method and device, equipment and storage medium

By automatically monitoring and processing alarm information about insufficient database resources, and elastically expanding or shrinking the capacity according to container configuration information, the problem of long and high cost of manual processing in the prior art is solved, and the database operation and maintenance efficiency is improved.

CN118885458APending Publication Date: 2024-11-01CHINA UNIONPAY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410919371.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

In the prior art, the database operation and maintenance plan based on manual processing takes a long time, which reduces the database operation and maintenance efficiency and leads to high labor costs and is unable to effectively deal with the situation of surge in business data volume or idle resources.

Method used

By monitoring the insufficient database resources, obtaining alarm information, determining the number of capacity expansion or capacity reduction and configuration information, and automatically performing elastic capacity expansion or capacity reduction processing of the database based on the container configuration information and resource utilization rate to improve operation and maintenance efficiency.

Benefits of technology

It realizes the automation of database operation and maintenance, improves operation and maintenance efficiency, reduces labor costs, and can quickly respond to changes in business demand.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885458A_ABST
    Figure CN118885458A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a database processing method and device, equipment and a storage medium, and relates to the technical field of databases. The method comprises the following steps: monitoring that current database resources are insufficient, and obtaining alarm information of a database; determining the number of expansion times and expansion configuration information corresponding to the alarm type; if it is determined that the capacity expansion times are smaller than the configuration capacity expansion times, container configuration information of the database is obtained; and according to the single-time capacity expansion quantity and the container configuration information, carrying out capacity expansion processing on the database. According to the method, the database operation and maintenance efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a database processing method, device, equipment and storage medium. Background Art

[0002] In the process of handling financial business, there will be a surge in business data volume or idle database resources in a specific period of time. The database capacity demand will increase or decrease accordingly. Therefore, the database needs to be dynamically processed to meet the dynamic needs of the business.

[0003] In the prior art, when the amount of business data surges or database resources are idle, a database operation and maintenance plan is manually formulated, and the database is expanded or reduced based on the plan to increase or decrease the database capacity.

[0004] However, in the above method, the process of formulating a database operation and maintenance plan is time-consuming based on manual processing, which reduces the efficiency of database operation and maintenance and also leads to high labor costs. Summary of the invention

[0005] The embodiments of the present application provide a database processing method, apparatus, device and storage medium to solve the technical problem that the manual processing method reduces the efficiency of database operation and maintenance.

[0006] In a first aspect, an embodiment of the present application provides a database processing method, including:

[0007] It is detected that the current database resources are insufficient, and alarm information of the database is obtained; wherein the alarm information includes an alarm type, and the alarm type is the type of the resource in the database that is in an insufficient state;

[0008] Determine the number of capacity expansions and capacity expansion configuration information corresponding to the alarm type; wherein the number of capacity expansions is the number of capacity expansion operations that have been performed for each alarm type within a preset time period; the capacity expansion configuration information includes the number of configured capacity expansions and the number of single capacity expansions, wherein the number of configured capacity expansions is the number of capacity expansion operations that are allowed to be performed for each alarm type within a preset time period; the number of single capacity expansions is the number of capacity expansion resources allowed when a single capacity expansion operation is performed for each alarm type;

[0009] If it is determined that the number of expansion times is less than the number of configuration expansion times, obtaining container configuration information of the database; wherein the container configuration information represents configuration data required when the container where the database is located is running;

[0010] The database is expanded according to the single expansion quantity and the container configuration information.

[0011] In a possible implementation, performing capacity expansion processing on the database according to the single capacity expansion quantity and the container configuration information includes:

[0012] Determine the planned capacity expansion information of the database according to the single capacity expansion quantity and the container configuration information; wherein the planned capacity expansion information represents the planned number of resources to be achieved after the database capacity expansion;

[0013] According to the planned capacity expansion information, the container where the database is located is expanded;

[0014] Determine the type of the database, and perform memory expansion processing on the database according to the type of the database.

[0015] In a possible implementation, performing capacity expansion processing on the container where the database is located according to the planned capacity expansion information includes:

[0016] Determine a container allocation cycle of the database; wherein the container allocation cycle is a reallocation cycle of memory resources of the container where the database is located;

[0017] Determine the running time corresponding to the container allocation cycle; wherein the running time is the running time of the container where the database is located within the container allocation cycle;

[0018] The container where the database is located is expanded according to the planned expansion information, the container allocation cycle, and the running time.

[0019] In a possible implementation, the method further includes:

[0020] Determine container directory information of the database; wherein the container directory is a directory used by the container where the database is located;

[0021] According to the planned capacity expansion information and the container directory, directory capacity expansion processing is performed on the container where the database is located.

[0022] In a possible implementation, if it is determined that the number of expansion times is less than the number of configuration expansion times, obtaining the container configuration information of the database includes:

[0023] If it is determined that the number of expansion times is less than the number of configured expansion times, determining the container state of the database;

[0024] If it is determined that the container status indicates that all containers in the server where the database is located are running normally, then determining the database status of the database;

[0025] If it is determined that the database state indicates that the database runs normally, the container configuration information of the database is obtained.

[0026] In a possible implementation, monitoring that the current database resources are insufficient includes:

[0027] Monitoring the container status and database status of the database;

[0028] If it is monitored that all containers in the server where the container status represents the database are running normally, and if it is monitored that the database status represents the database is running normally, the resource usage rate of the database is collected, and the number of over-values ​​corresponding to the resource usage rate is determined; wherein the resource usage rate represents the resource usage of the container where the database is located; the number of over-values ​​is the total number of times the resource usage rate continuously exceeds a preset threshold within a preset time period;

[0029] If it is determined that the number of over-value times is greater than a preset number, it is determined that the current database resources are insufficient.

[0030] In a possible implementation, the method further includes:

[0031] Acquire resource usage information of the database; wherein the resource usage information represents resource usage of the database;

[0032] Determine the resource status of the database according to the resource usage information; wherein the resource status represents the idleness of the database service resources;

[0033] The database is scaled down according to the resource status of the database.

[0034] In a possible implementation, obtaining resource usage information of the database includes:

[0035] Determine the creation duration of the database, and if it is determined that the creation duration is greater than or equal to a preset duration, obtain unit information of the database; wherein the unit information is information of a database service unit;

[0036] Resource usage information of the database is determined according to the unit information.

[0037] In a possible implementation manner, determining the resource usage information of the database according to the unit information includes:

[0038] Determining a unit operation status of the database according to the unit information;

[0039] If it is determined that the unit operation status indicates that the resource requirement of the operation environment of the database service unit is minimal, then the resource usage information of the database is determined.

[0040] In a possible implementation, the resource usage information includes central processing unit CPU usage rate, memory change rate, table space change rate, log space change rate, number of connections and number of users;

[0041] Determining the resource status of the database according to the resource usage information includes:

[0042] If it is determined that the number of connections and the number of users are both zero, then determining that the resource state is an idle state;

[0043] If it is determined that the number of connections and the number of users are not zero, and if it is determined that any one of the memory change rate, the table space change rate, and the log space change rate is greater than a first preset threshold, then the resource status is determined to be a normal status.

[0044] In a possible implementation, the method further includes:

[0045] If it is determined that the number of connections is zero, the number of users is not zero, and it is determined that the CPU usage rate, the memory change rate, the table space change rate, and the log space change rate are all less than a second preset threshold, then it is determined that the resource state is an idle state;

[0046] If it is determined that the number of connections is zero and the number of users is not zero, and it is determined that any one of the CPU usage rate, the memory change rate, the table space change rate and the log space change rate is greater than or equal to the second preset threshold, then the resource status is determined to be a surplus status.

[0047] In a possible implementation, the method further includes:

[0048] If it is determined that the number of connections and the number of users are not zero, and it is determined that the memory change rate, the table space change rate, and the log space change rate are all less than or equal to the first preset threshold, then the resource state is determined to be a surplus state.

[0049] In a possible implementation, the method further includes:

[0050] If it is determined that the number of connections is not zero and the number of users is zero, then it is determined that the resource state is a surplus state.

[0051] In a possible implementation manner, the resource state is any one of an idle state, a surplus state, and a normal state; and scaling down the database according to the resource state of the database includes:

[0052] If it is determined that the resource state is an idle state or a surplus state, then determining a container state and a database state of the database;

[0053] If it is determined that all containers in the server where the container status represents the database are running normally, and it is determined that the database status represents that the database is running normally, the database is scaled down according to the container configuration information and the resource status of the database.

[0054] In a possible implementation, scaling down the database according to the container configuration information of the database and the resource status includes:

[0055] If it is determined that the resource state is a surplus state, then determining the single shrinkage quantity of the database; wherein the single shrinkage quantity is the shrinkage quantity of resources allowed when performing a single shrinkage operation;

[0056] Determine the planned shrinkage information of the database according to the single shrinkage quantity and the container configuration information; wherein the planned shrinkage information represents the planned resource quantity after the database is shrunk;

[0057] According to the database type of the database, performing memory reduction processing on the database;

[0058] The containers in the database are shrunk according to the planned shrinkage information.

[0059] In a possible implementation, the method further includes:

[0060] If it is determined that the resource state is an idle state, the database is subjected to memory shrinkage processing according to a preset minimum shrinkage amount; wherein the minimum shrinkage amount is the minimum resource amount planned to be reached after the database is shrunk.

[0061] In a second aspect, an embodiment of the present application provides a database processing device, including:

[0062] A first acquisition module is used to monitor that the current database resources are insufficient and obtain alarm information of the database; wherein the alarm information includes an alarm type, and the alarm type is the type of resources in the database that are in an insufficient state;

[0063] A determination module, used to determine the number of expansion times and expansion configuration information corresponding to the alarm type; wherein the number of expansion times is the number of expansion operations that have been performed for each alarm type within a preset time period; the expansion configuration information includes the number of configured expansion times and the number of single expansions, wherein the number of configured expansion times is the number of expansion operations allowed to be performed for each alarm type within a preset time period; the number of single expansions is the number of expansion resources allowed when a single expansion operation is performed for each alarm type;

[0064] A second acquisition module is used to acquire container configuration information of the database if it is determined that the number of expansion times is less than the number of configuration expansion times; wherein the container configuration information represents configuration data required when the container where the database is located is running;

[0065] The expansion module is used to expand the database according to the single expansion quantity and the container configuration information.

[0066] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;

[0067] The memory stores computer-executable instructions;

[0068] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.

[0069] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.

[0070] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.

[0071] The database processing method, apparatus, device and storage medium provided in the embodiments of the present application implement elastic expansion of the database through the type of resources in a insufficient state in the database. If it is determined that the number of expansion operations corresponding to the type executed within a preset time period is less than the number of expansion operations allowed to be executed, the number of expansion resources allowed when a single expansion operation is executed corresponding to the alarm type, and the configuration data required when the container where the database is located is running, thereby improving the efficiency of database operation and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0073] Figure 1 A schematic diagram of an application scenario provided for this application;

[0074] Figure 2 A flowchart of a database processing method provided in an embodiment of the present application;

[0075] Figure 3A schematic diagram of a database expansion configuration interface provided in an embodiment of the present application;

[0076] Figure 4 A flowchart of another database processing method provided in an embodiment of the present application;

[0077] Figure 5 A flowchart of a database monitoring process provided in an embodiment of the present application;

[0078] Figure 6 A flowchart of a database expansion process provided in an embodiment of the present application;

[0079] Figure 7 A flowchart of another database processing method provided in an embodiment of the present application;

[0080] Figure 8 A flowchart of a database shrinking process provided in an embodiment of the present application;

[0081] Fig. 9 A schematic diagram of the structure of a database processing device provided in an embodiment of the present application;

[0082] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0083] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0084] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application.

[0085] First, the terms involved in this application are explained:

[0086] Database: The database in the proposal of the present invention refers to a database in a broad sense, which refers to all systems that can store data, including relational databases, in-memory databases, non-relational databases, message middleware, etc.

[0087] Virtual Machine: Virtual Machine, referred to as VM, is a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment.

[0088] Database as a Service: Database as a Service, referred to as DBaaS, is based on traditional database technology and provides database resources to one or more tenants in the form of standard services.

[0089] Control Groups: Cgroups for short, a function of the Linux kernel, used to limit, control and separate the resources of a process group (such as CPU, memory, disk input and output, etc.).

[0090] Container: Docker is an open source application container engine that allows developers to package their applications and dependent packages into a portable image, and then publish them to any popular Linux or Windows operating system machine. It can also achieve virtualization. The container completely uses the sandbox mechanism and there is no interface between them.

[0091] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0092] It should be noted that the database processing method, device, equipment and storage medium of the present application can be used in the field of database technology, and can also be used in any field other than database technology. The application field of the database processing method, device, equipment and storage medium of the present application is not limited.

[0093] In the process of handling financial business, there will be a surge in business data volume or idle database resources in a specific period of time. The database capacity demand will increase or decrease accordingly. Therefore, the database needs to be dynamically processed to meet the dynamic needs of the business.

[0094] In one example, when the amount of business data surges or database resources are idle, a database operation and maintenance plan is manually formulated, and the database is expanded or reduced based on the plan to increase or decrease the database capacity.

[0095] However, in the above method, the process of formulating a database operation and maintenance plan is time-consuming based on manual processing, which reduces the efficiency of database operation and maintenance and also leads to high labor costs.

[0096] In another example, by obtaining the CPU usage corresponding to the instance deployed in each container of the container cluster, the current business load is determined based on the CPU usage, and then the distributed database is elastically scaled, including homogeneous expansion, heterogeneous expansion, or reduction.

[0097] However, in the above method, only the CPU load is used as the business load, and factors such as database instance memory, table space, log space, and number of connections are not considered. It cannot meet the elastic scaling requirements when other database resources are insufficient or excessive, and has obvious disadvantages.

[0098] In another example, a Corn Job is deployed in the Kubernetes cluster to periodically collect indicator data from each node in the MySQL cluster. The MySQL Monitor analyzes and processes the data and updates the MySQL Cluster custom resources with the results. The MySQL operator determines based on the data in the MySQL Cluster custom resources that, within a cycle, when the number of reported expansion or contraction requests reaches half or more of the total number of reports, the system is expanded or contracted.

[0099] However, the above method is only applicable to the elastic scaling of MySQL database instances in the kubernetes cluster, and cannot meet the elastic scaling of other types of databases in the cloud platform, so its application scope is limited.

[0100] In response to the above technical problems, the present application proposes the following technical concept: when insufficient database resources are monitored, according to the type of insufficient resources in the database, if it is determined that the number of expansion operations corresponding to the type executed within the preset time period is less than the number of expansion operations allowed to be executed, the number of expansion resources allowed when a single expansion operation is executed according to the alarm type, and the configuration data required when the container where the database is located is running, to achieve elastic expansion of the database. In this way, the problem of time-consuming, labor-intensive and inefficient increase and decrease of database capacity through manual operation in the prior art can be solved.

[0101] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0102] Figure 1A schematic diagram of an application scenario provided by this application. Figure 1 As shown, the specific application scenario of the present application includes an electronic device 101 and a server 102 for deploying a database. The electronic device 101 can monitor the resource status of each database in the server 102, and if it is monitored that any database has insufficient resources, the database is expanded.

[0103] Figure 2 A flowchart of a database processing method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method includes:

[0104] 201. It is detected that the current database resources are insufficient, and alarm information of the database is obtained; wherein the alarm information includes an alarm type, and the alarm type is the type of the insufficient resources in the database.

[0105] Exemplarily, the execution subject of this embodiment may be an electronic device, hereinafter referred to as the device, and the device may be a physical device or a virtual device that executes the database processing method. The device deploys a database cloud platform, which is a new type of cloud computing service that provides high-performance, high-reliability, high-security, and scalable database hosting services. The platform can provide a variety of database services such as relational databases, non-relational databases, distributed databases, etc., and also provides a full set of database operation and maintenance solutions such as backup and recovery, monitoring, rapid expansion, and data transmission. The database cloud platform of the device includes a monitoring device, a configuration device, and a capacity expansion device; based on the monitoring device, the current database resource status can be monitored in real time. If it is detected that the current database resources are insufficient, an alarm is triggered. After the capacity expansion device receives the alarm generated by the monitoring device, it obtains the alarm information of the database such as the service name, service type, and alarm type. The alarm type is the type of resources in the database that are insufficient.

[0106] For example, based on the monitoring of current database resources such as central processing unit (CPU), memory, log space, table space, network traffic, number of connections, etc., the generated resource warning or alarm determines that the business volume has increased and the current resources are insufficient, triggering an alarm: XX Five Stations Direct XX1 Center_Direct 72158950_abcde001 upsql's CPU usage, value: 99, belonging to the host M4110101 192.120.171.11, belonging to the user Zhang San, belonging to the office operation team, belonging to the unit XX department, then it can be obtained that the database belongs to the area of ​​XX Five Stations, the service name is abcde001, the type is upsql, the alarm type is CPU usage, and if the acquisition is successful, proceed to the next step. If the reading fails, the exception processing is performed and the end is ended.

[0107] 202. Determine the number of expansion times and expansion configuration information corresponding to the alarm type; wherein the number of expansion times is the number of expansion operations that have been executed for each alarm type within a preset time period; the expansion configuration information includes the number of configured expansion times and the number of single expansions, wherein the number of configured expansion times is the number of expansion operations allowed to be executed for each alarm type within the preset time period; the number of single expansions is the number of expansion resources allowed when a single expansion operation is executed for each alarm type.

[0108] Exemplarily, after the device determines the alarm type, it obtains the relevant configuration of automatic expansion in the configuration device, including the number of expansion times and expansion configuration information corresponding to the alarm type; wherein the number of expansion times is the number of expansion operations that have been executed for each alarm type within a preset time period, and the expansion configuration information includes the number of configured expansion times and the number of single expansions. The number of configured expansion times is the number of expansion operations allowed to be executed for each alarm type within the preset time period, and the number of single expansions is the number of expansion resources allowed when a single expansion operation is executed for each alarm type, so as to prevent frequent expansion triggered by continuous surges in resource usage or regular fluctuations, which ultimately leads to exhaustion of server resources where the database is located.

[0109] For example, the relevant configuration of automatic expansion in the configuration device is obtained, mainly including area A (Area), database type (Type), frequency F (Frequency), alarm switch W (Warning), and also including the number of resources for a single automatic expansion, the number of CPUs C (unit), the number of memories M (unit G), the table space size D (unit G), and the log space size L (unit G), and compared with the database type in the alarm information. If the obtained area and database type match, the expansion work order record is queried to obtain the alarm type (such as CPU) and expansion frequency f of the database service within 24 hours in step 1; otherwise, exception processing is performed and the process ends.

[0110] 203. If it is determined that the number of expansion times is less than the number of configured expansion times, then obtain the container configuration information of the database; wherein the container configuration information represents the configuration data required when the container where the database is located is running.

[0111] For example, the database cloud platform of the device usually deploys instances of different businesses to achieve hybrid deployment and maximize resource utilization. In order to reduce the mutual impact of different instances on the same device, resource isolation is usually required, that is, container management based on container technology is performed to complete database container deployment and management. Each database instance in the platform is an independent container deployed on the host machine, and database processing configuration is performed. Figure 3 A schematic diagram of a database expansion configuration interface provided in an embodiment of the present application, such as Figure 3As shown, it mainly includes the region, type, and service type where the database elastic expansion function is enabled, the number of CPUs, memory quantity, data directory and log directory size for a single expansion, and the number of elastic expansions of a single database service within 24 hours, and whether an alarm is required to notify users and administrators after the elastic expansion is successful; the elements of the database shrinkage configuration are basically similar. After the device obtains the expansion times corresponding to the alarm type of the database and the corresponding configuration expansion times, if the corresponding expansion times f<the corresponding configuration expansion times F within the preset time period, such as 24 hours, it means that the number of automatic expansions in the last 24 hours has not reached the upper limit of the configuration, then the container configuration information of the pre-configured database is obtained to represent the configuration data required for the operation of the container where the database is located, including the dedicated IP address, CPU, memory, table space, and log space, where the table space stores data and the log space stores database logs; if the corresponding expansion times f>=the corresponding configuration expansion times F, it means that the number of automatic expansions in the last 24 hours has reached the upper limit of the configuration, then the exception processing is performed and the end is completed.

[0112] For example, to obtain the container configuration information of a pre-configured database, you can use the following method: docker inspect "${CONTAINER_ID}", where CONTAINER_ID is the ID of the container. By returning the result, you can obtain the CPU, memory size, and directory corresponding to the space configured in the container. For example, by querying information through docker inspect 45f30b204ef6|grep-imem: "Memory": 1073741824, "CpusetMems": "", "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 1610612736, "MemorySwappiness": -1, it means that the memory configuration of container 45f30b204ef6 is 1073741824, that is, 1G. If all container package configurations of the current service are obtained successfully, proceed to the next step. If the acquisition fails, perform exception handling and end. Among them, the exception handling step mainly records the failure-related logs, including time, operation steps, failure reasons, etc.

[0113] 204. Expand the database according to the single expansion quantity and container configuration information.

[0114] Exemplarily, the device determines a database expansion method according to the acquired single expansion quantity and container configuration information corresponding to the alarm type, and then can perform expansion processing on the database according to the database expansion method.

[0115] In this embodiment, a database processing method is provided. According to the type of resources in a database that are in a state of shortage, if it is determined that the number of expansion operations corresponding to this type that have been executed within a preset time period is less than the number of expansion operations allowed to be executed, the number of expansion resources allowed when a single expansion operation is executed corresponding to the alarm type, and the configuration data required when the container where the database is located is run, the database is elastically expanded; thereby, the database operation and maintenance efficiency can be improved.

[0116] Figure 4 A flowchart of another database processing method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the method includes:

[0117] 301. Monitor the container status and database status of the database.

[0118] For example, Figure 5 A flowchart of a database monitoring process provided by an embodiment of the present application is shown as follows: Figure 5 As shown, based on the monitoring device on the database platform deployed in the device, a monitoring process of the database container resource usage is initiated according to a set period to check the container status and the database status.

[0119] 302. If it is monitored that the container status indicates that all containers in the server where the database is located are running normally, and if it is monitored that the database status indicates that the database is running normally, collect the resource usage rate of the database and determine the number of over-value times corresponding to the resource usage rate; wherein the resource usage rate indicates the resource usage of the container where the database is located; the number of over-value times is the total number of times the resource usage rate continuously exceeds a preset threshold within a preset time period.

[0120] For example, in combination Figure 5 Based on the monitoring device, if the container status is normal, the next step is to check the database status. If the container status is abnormal, the exception processing is performed and the process ends; check the database status. If the database status is normal, the next step is to collect resource usage. The resource usage represents the resource usage of the container where the database is located, including CPU, memory, log space, table space, network traffic and number of connections, etc. The usage data and the current time are recorded in the monitoring database, and the total number of times the resource usage exceeds the preset threshold continuously within the preset time period, that is, the number of over-values, is obtained; if the database status is abnormal, the exception processing is performed and the process ends.

[0121] 303. If it is determined that the number of over-value times is greater than the preset number, it is determined that the current database resources are insufficient.

[0122] For example, in combination Figure 5If it is determined that the resource usage rate exceeds the preset number of times, it is determined that the current database resources are insufficient; for example, check whether each resource usage rate indicator exceeds the set alarm threshold for N consecutive times, where N is a positive integer greater than 1. It mainly solves the warning or alarm burr scenario caused by the instantaneous surge of resources. If it exceeds, an alarm is sent, and if not, the process ends. Furthermore, based on the current database resource monitoring, the elastic expansion is triggered by the generated resource warning or alarm, without the need to collect and query resource usage information additionally. It can be well adapted to the existing database operation and maintenance system and platform, with low transformation cost, simple and reliable.

[0123] 304. It is detected that the current database resources are insufficient, and alarm information of the database is obtained; wherein the alarm information includes an alarm type, and the alarm type is the type of the resource in the database that is in an insufficient state.

[0124] Exemplarily, this step may refer to step 201 and will not be described in detail here.

[0125] 305. Determine the number of expansions and expansion configuration information corresponding to the alarm type; wherein the expansion configuration information includes the number of configured expansions and the number of single expansions, the number of configured expansions is the number of expansion operations allowed to be performed for each alarm type within a preset time period; the number of single expansions is the number of expansion resources allowed when a single expansion operation is performed for each alarm type.

[0126] Exemplarily, this step may refer to step 201 and will not be described in detail here.

[0127] 306. If it is determined that the number of expansion times is less than the configured number of expansion times, determine the container state of the database.

[0128] For example, Figure 6 A flowchart of a database expansion process provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, check the container status, including the running status of all containers in the database server and the database status in the container. For example, the container running status check method is: docker inspect-f"{{.State.Running}}""${CONTAINER_ID}". If the returned result is true, it is normal, otherwise it is abnormal. If it is abnormal, the capacity cannot be expanded, and the exception needs to be handled and ended.

[0129] 307. If it is determined that the container status indicates that all containers in the server where the database is located are running normally, then determine the database status of the database.

[0130] For example, in combination Figure 6If the container status is normal, that is, all containers in the server where the database is located are running normally, then check the database status. The database status in the container is mainly determined by whether the database can be connected or whether the process exists. For example, the method to determine whether the redis status is normal is as follows: redis-cli-h "${ip}"-p "${port}"-a "${auth}"info, where ip, port and auth are the IP address, port and password of redis respectively. Connect to the redis server through the client and execute info to view the information. If the execution is successful, it means that redis is normal, otherwise it is abnormal.

[0131] 308. If it is determined that the database status indicates that the database is running normally, then obtain the container configuration information of the database.

[0132] For example, in combination Figure 6 If the service in the container is normal, that is, the database is running normally, then the package configuration of the current database service, that is, the container configuration information, is obtained; if it is abnormal, the capacity cannot be expanded, and exception handling is required and the process ends; thus, the needs of refined management of elastic expansion and contraction of the database are met, and the database processing efficiency is improved.

[0133] 309. Determine the planned capacity expansion information of the database according to the single capacity expansion quantity and the container configuration information; wherein the planned capacity expansion information represents the planned resource quantity after the database is expanded.

[0134] Exemplarily, when the device obtains the single expansion quantity corresponding to the alarm type and the container configuration information of the current database, it is necessary to process the obtained single expansion quantity and container configuration information according to the preset processing rules, calculate the expansion package, and obtain the planned expansion information of the database, that is, the planned number of resources after the database is expanded.

[0135] For example, combining Figure 6 , the current database CPU usage alarm triggers CPU expansion. The current container CPU number is 4, and the configured single expansion CPU number is 2. This time, the container CPU number is planned to be expanded to 6, recorded as cpu_number; the calculation method of memory, data space, and log space is similar, recorded as mem_number, data_number, and log_number respectively. If the execution is successful, proceed to the next step. If the execution fails, the exception is handled and the process ends.

[0136] 310. According to the planned expansion information, expand the container where the database is located.

[0137] Exemplarily, after the device calculates the planned expansion information, it expands the container where the database is located according to the obtained planned expansion information, including CPU, memory, and storage space; for example, if the CPU resource warning is triggered, the CPU expansion of the database container is triggered, such as the method based on the binding core number limit: docker update--cpus cpu_number "${CONTAINER_ID}", where cpu_number is the calculated planned expansion number, representing the number of cores allocated to the container; if the tablespace resource warning is triggered, the database container storage space expansion is triggered, such as docker update--memory mem_number "${CONTAINER_ID}", where mem_number is the calculated planned expansion number.

[0138] In one example, step 310 includes the following steps:

[0139] The first step of step 310 is to determine the container allocation cycle of the database; wherein the container allocation cycle is the reallocation cycle of the memory resources of the container where the database is located.

[0140] The second step of step 310 is to determine the running time corresponding to the container allocation cycle; wherein the running time is the running time of the container where the database is located within the container allocation cycle.

[0141] The third step of step 310 is to expand the container where the database is located according to the planned expansion information, the container allocation cycle and the running time.

[0142] Exemplarily, the specific method of expanding the container CPU varies according to the binding mode. Based on the binding cycle restriction method, the database container allocation cycle is determined, which is the memory resource redistribution cycle of the container where the database is located, and the running time corresponding to the container allocation cycle is determined, which is the running time of the container where the database is located within the container allocation cycle. Based on the obtained planned expansion information, container allocation cycle and running time, the container where the current database is located is expanded. In turn, the problem of elastic expansion due to insufficient CPU resources in the database can be solved.

[0143] For example, based on the binding period restriction method, docker update --cpu-quota cpu_number*cpu-period "${CONTAINER_ID}", where cpu_number is the planned expansion quantity calculated in step 7*cpu-period, where cpu-period is used to specify how long it takes for the container to reallocate the CPU usage, and cpu-quota is used to specify the maximum time that can be used to run the container within this period. The units of cpu-period and cpu-quota are microseconds (μs), the minimum value of cpu-period is 1000 microseconds, the maximum value is 1 second (10^6μs), and the default value is 0.1 second (100000μs). The default value of cpu-quota is -1, which means no control. The two parameters cpu-period and cpu-quota are generally used together.

[0144] In one example, step 310 includes the following steps: determining container directory information of the database; wherein the container directory is a directory used by the container where the database is located; and performing directory expansion processing on the container where the database is located according to the planned expansion information and the container directory.

[0145] Exemplarily, if the alarm type is insufficient data and log space, the expansion of the data and log space used by the container does not need to be performed through the container, and the directory expansion needs to be performed on the server where the container is located, then the container directory information of the database, that is, the directory used by the container where the database is located, is determined; and based on the preset rules, according to the planned expansion information corresponding to the alarm type and the obtained container directory, the directory expansion processing is performed on the container where the database is located; for example, combined with Figure 6 , lvextend-l LV name, xfs_grow LV name, where LV name is the LV mapped to the container on the physical machine. To expand the log directory used by container 396c6048_odcac01 by 40G, use the following command: lvextend-l+40G / dev / F04080501_SSD_VG / 396c6048_odcac01_LOG, xfs_grow / dev / F04080501_SSD_VG / 396c6048_odcac01_LOG. If the execution is successful, proceed to the next step. If the execution fails, perform exception handling and end. In addition, the problem of elastic expansion due to insufficient database log space and table space resources can be solved.

[0146] 311. Determine the type of database and expand the memory capacity of the database based on the type of database.

[0147] Exemplarily, after the database container is expanded, the type of database is determined, and memory expansion is performed as needed according to the database type; for example, Figure 6 To expand the memory of the MySQL database, you need to modify the bufferpool size of the database after expanding the container memory to increase the number of data caches and improve database performance. To expand the memory of the Redis database, you need to modify the maxmemory of the database after expanding the container memory to increase the upper limit of the number of caches. If the execution is successful, proceed to the next step. If the execution fails, perform exception processing and end. In addition, it can support elastic expansion of various types of databases.

[0148] In this embodiment, based on the above embodiment, different elastic expansions are triggered according to resource types, which can solve the problem of elastic expansion of insufficient resources of different types in the database.

[0149] Figure 7 A flowchart of another database processing method provided in an embodiment of the present application is shown as follows: Figure 7 As shown, the method includes:

[0150] 401. Obtain resource usage information of a database; wherein the resource usage information represents resource usage of the database.

[0151] For example, Figure 8 A flowchart of a database shrinking process provided by an embodiment of the present application is shown in FIG. Figure 8 As shown, the device also includes a capacity reduction device. After the capacity reduction device is started, it periodically checks the resource usage information of each database service to characterize the resource usage of the database. The execution cycle can be configured as hours, days or weeks. The shorter the configured cycle, the more timely the idle or surplus resources of the database can be recovered.

[0152] In one example, step 401 includes the following steps:

[0153] The first step of step 401 is to determine the creation time of the database. If it is determined that the creation time is greater than or equal to the preset time, the unit information of the database is obtained; wherein the unit information is the information of the database service unit.

[0154] The second step of step 401 is to determine the resource usage information of the database according to the unit information.

[0155] For example, in combination Figure 8, for the database service unit, in order to prevent the data resources that have just been created but not yet put into operation from being recycled, check the creation time of the database service. If the creation time is greater than or equal to the preset time, obtain the information of the data service unit, including the name of the unit, the server where it is located, and the type. For example, odcac01 is a MySQL database service with a master-slave architecture. The information of the two master and slave MySQL subunits obtained includes: serial number 1, subunit 396c6048_odcac01, server F04080501, type MySQL, package 4C16G; serial number 2, subunit 13fcdd06_odcac01, server F04070401, type MySQL, package 4C16G. If the acquisition is successful, proceed to the next step. If the acquisition fails, perform exception handling and end; if the creation time is less than one week (specifically 7*24*60=10080 minutes), end.

[0156] In one example, the second step of step 401 includes: determining the unit operation state of the database according to the unit information; if it is determined that the unit operation state indicates that the resource demand of the operation environment of the database service unit is minimal, determining the resource usage information of the database.

[0157] Exemplarily, when obtaining the resource usage of each sub-unit in the database service unit, the operating status of the service unit in the database is determined based on the information of the service unit in the database to determine whether the resource demand of the operating environment of the database service unit is minimized. That is, if it is determined that the resource demand of the operating environment of the database service unit is minimized, the historical monitoring data of the service unit is queried through the monitoring device to determine the resource usage information of the database.

[0158] For example, combining Figure 8 , check whether the unit is running with minimized resources. Minimized resource operation means that the database operating environment has the minimum resource requirements. For example, a container that supports MySQL's minimized operation requires at least 1 CPU and 1G memory. Smaller resources will cause MySQL to fail to start or be unusable. According to the package information in the obtained unit information, determine whether the unit is running with minimized resources. If so, it means that the unit does not need to be scaled down, and the process ends. If not, proceed to the next step.

[0159] 402. Determine a resource status of the database according to the resource usage information; wherein the resource status represents an idle state of database service resources.

[0160] Exemplarily, after checking the database resource usage, the device scores the obtained resource usage information and determines the idleness of the database service resources, whether the resources are idle or surplus, according to pre-set rules.

[0161] In one example, the resource usage information includes the CPU usage rate, memory change rate, table space change rate, log space change rate, number of connections, and number of users; step 402 includes the following steps:

[0162] In the first step of step 402, if it is determined that the number of connections and the number of users are both zero, then the resource state is determined to be an idle state.

[0163] In the second step of step 402, if it is determined that the number of connections and the number of users are not zero, and it is determined that any one of the memory change rate, the table space change rate, and the log space change rate is greater than the first preset threshold, then the resource status is determined to be normal.

[0164] For example, in combination Figure 8, the resource usage information of the database obtained by the monitoring device includes the CPU usage rate of the central processing unit, the memory change rate, the table space change rate, the log space change rate, the number of connections and the number of users; wherein, the maximum value of the CPU usage rate of each sub-unit in the database service unit in the past week is obtained, and the result of the sub-unit with the largest CPU usage rate is taken as the maximum value of the CPU usage rate of the current database service unit, that is, the CPU usage rate; the maximum value and minimum value of the memory usage rate of each sub-unit in the database service unit in the past week are obtained, and the change rate therein is calculated, and the calculation method is the maximum value-minimum value to obtain the memory change rate; the maximum value and minimum value of the table space usage rate of each sub-unit in the database service unit in the past week are obtained, and the change rate therein is calculated, and the calculation method is the maximum value-minimum value to obtain the table space change rate. The calculation method is similar to the memory change rate and will not be repeated; obtain the database service The maximum and minimum values ​​of the log space usage rate of each sub-unit in the unit in the most recent week are used to calculate the change rate. The calculation method is maximum value minus minimum value to obtain the log space change rate. The calculation method is similar to the memory change rate and will not be repeated here. The maximum value of the number of connections of each sub-unit in the database service unit in the most recent week is obtained, and the result of the unit with the largest number of connections is taken as the maximum value of the number of connections of the current database service unit, that is, the number of connections. The current number of users of each sub-unit in the database service unit is obtained, and the result of the sub-unit with the largest number of users is taken as the number of users of the current database service unit. The result is an integer. If the current database service has no users or does not support user queries, the number of users is recorded as 0. This step does not require querying monitoring data, and can be obtained by querying the information in the current database. If the above information is successfully obtained, proceed to the next step. If it is unsuccessful, exception handling is required and the process ends. Based on the obtained resource usage information, the current database service resource status is judged, including idle, surplus and normal status. If it is determined that the number of connections and the number of users are both zero, the resource status is determined to be idle; if it is determined that the number of connections and the number of users are not zero, and it is determined that any one of the memory change rate, the table space change rate and the log space change rate is greater than the first preset threshold, if any one exceeds the threshold by 50%, the resource status is determined to be normal.

[0165] In one example, step 402 also includes: if it is determined that the number of connections is zero and the number of users is not zero, and it is determined that the CPU usage, memory change rate, table space change rate, and log space change rate are all less than a second preset threshold, then the resource state is determined to be an idle state; if it is determined that the number of connections is zero and the number of users is not zero, and it is determined that any one of the CPU usage, memory change rate, table space change rate, and log space change rate is greater than or equal to the second preset threshold, then the resource state is determined to be a surplus state.

[0166] Exemplarily, if it is determined that the number of connections is zero and the number of users is not zero, and it is determined that the CPU usage rate, memory change rate, table space change rate, and log space change rate are all less than the second preset threshold, such as all less than 5, then the resource status is still determined to be idle; if it is determined that the number of connections is zero and the number of users is not zero, and it is determined that the memory change rate, table space change rate, and log space change rate are all less than or equal to the second preset threshold, if one is greater than or equal to 5, then the resource status is determined to be surplus.

[0167] In one example, step 402 further includes: if it is determined that the number of connections and the number of users are not zero, and it is determined that the memory change rate, the table space change rate, and the log space change rate are all less than or equal to the first preset threshold, then determining that the resource state is a surplus state.

[0168] Exemplarily, if it is determined that the number of connections and the number of users are not zero, and it is determined that the memory change rate, table space change rate and log space change rate are all less than or equal to the first preset threshold, such as none of them exceeds the threshold of 50%, the resource status of the database is still judged to be abundant.

[0169] In one example, step 402 further includes: if it is determined that the number of connections is not zero and the number of users is zero, determining that the resource state is a surplus state.

[0170] Exemplarily, if it is determined that the number of connections is not zero and the number of users is zero, it is directly determined that the resource state of the database is a surplus state.

[0171] 403. Scale down the database according to the resource status of the database.

[0172] Exemplarily, the device checks the resource status of the database. If the database is in a surplus state, the database can be scaled down according to the scaling down settings in the configuration device. The recovered resources can be returned to the resource pool and provided to other databases when needed.

[0173] In one example, the resource state is any one of an idle state, a surplus state, and a normal state; step 403 includes the following steps:

[0174] Step 1: If it is determined that the resource status is an idle status or a surplus status, then the container status and the database status of the database are determined.

[0175] Step 2: If it is determined that the container status indicates that all containers in the server where the database is located are running normally, and it is determined that the database status indicates that the database is running normally, then the database is scaled down according to the container configuration information and resource status of the database.

[0176] For example, in combination Figure 8The current database service resource status includes three states: idle, surplus and normal. If it is idle or surplus, check the database container status. If the container status is normal, check the database status. If the container status is abnormal, it cannot be scaled down and exception handling is required and the process ends. After checking the database status, if it is determined that the service in the database container is normal, obtain the container configuration, that is, the database container configuration information, and scale down the database according to the database container configuration information and resource status, including CPU, memory, and storage space.

[0177] In one example, the step 2 of scaling down the database according to the container configuration information and resource status of the database includes:

[0178] The first step is to determine the single shrinkage quantity of the database if the resource state is determined to be a surplus state; wherein the single shrinkage quantity is the shrinkage quantity of resources allowed when performing a single shrinkage operation.

[0179] The second step is to determine the planned shrinkage information of the database according to the single shrinkage quantity and the container configuration information; wherein the planned shrinkage information represents the planned resource quantity after the database is shrunk.

[0180] The third step is to reduce the memory capacity of the database according to the database type.

[0181] The fourth step is to reduce the capacity of the containers in the database according to the planned reduction information.

[0182] For example, in combination Figure 8 If the resource status is determined to be surplus, the number of shrinking resources allowed when the database performs a single shrinking operation, i.e., the single shrinking number, is determined, and the single shrinking number and the obtained container configuration information are calculated and processed to determine the number of resources planned to be achieved after the database is shrunk, i.e., the planned shrinking information. For example, the number of CPUs in the current database container is 4, and the number of CPUs configured for single shrinking in step 2 is 2. This time, the number of container CPUs is planned to be shrunk to 2, recorded as cpu_number. The memory calculation method is similar, recorded as mem_number. If the execution is successful, proceed to the next step. If the execution fails, perform exception processing and end. Perform memory shrinking processing as needed according to the database type, such as modifying the bufferpool size of the database and modifying the maxmemory of the database to reduce the upper limit of the cacheable number. According to the number of resources planned to be achieved after the database is shrunk, i.e., the planned shrinking information, perform memory shrinking and directory shrinking processing on the database container.

[0183] In one example, in step 2, scaling down the database according to the container configuration information and resource status of the database includes: if it is determined that the resource status is idle, scaling down the database memory according to a preset minimum scaling amount; wherein the minimum scaling amount is the minimum resource amount planned to be reached after the database is scaled down;

[0184] For example, in combination Figure 8 If the resource status is determined to be idle, there is no need to calculate the shrinking package. The database is directly shrunk to the preset minimum shrinking quantity, that is, the minimum number of resources planned to be reached after the database is shrunk. The database memory is shrunk according to the preset minimum shrinking quantity. If the execution is successful, the next step is carried out. If the execution fails, the exception is handled and the process ends. Furthermore, by periodically checking the database resource usage rate, the elastic shrinking of various types of databases can be supported, and idle database resources can be discovered and recycled.

[0185] In this embodiment, on the basis of the above embodiment, by periodically checking the utilization rate of database resources, elastic shrinkage of various types of databases can be supported, which has wide versatility and is effective in saving manpower and improving efficiency.

[0186] Fig. 9 A schematic diagram of the structure of a database processing device provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, the device comprises:

[0187] The first acquisition module 501 is used to monitor that the current database resources are insufficient and obtain the alarm information of the database; wherein the alarm information includes the alarm type, and the alarm type is the type of the resource in the database that is in an insufficient state;

[0188] Determination module 502, used to determine the number of expansions and expansion configuration information corresponding to the alarm type; wherein the number of expansions is the number of expansion operations that have been performed for each alarm type within a preset time period; the expansion configuration information includes the number of configured expansions and the number of single expansions, wherein the number of configured expansions is the number of expansion operations allowed to be performed for each alarm type within a preset time period; the number of single expansions is the number of expansion resources allowed when a single expansion operation is performed for each alarm type;

[0189] The second acquisition module 503 is used to acquire the container configuration information of the database if it is determined that the number of expansion times is less than the number of configured expansion times; wherein the container configuration information represents the configuration data required when the container where the database is located is running;

[0190] The capacity expansion module 504 is used to expand the database according to the single capacity expansion quantity and container configuration information.

[0191] In a possible implementation, the expansion module 504 is specifically used to: determine the planned expansion information of the database based on the single expansion quantity and container configuration information; wherein the planned expansion information represents the planned number of resources to be achieved after the database is expanded; according to the planned expansion information, expand the container where the database is located; determine the type of the database, and according to the type of the database, perform memory expansion on the database.

[0192] In a possible implementation, the expansion module 504 is further specifically used to: determine a container allocation cycle of the database; wherein the container allocation cycle is a reallocation cycle of memory resources of the container where the database is located; determine an operating time corresponding to the container allocation cycle; wherein the operating time is the operating time of the container where the database is located within the container allocation cycle; and expand the container where the database is located according to the planned expansion information, the container allocation cycle, and the operating time.

[0193] In a possible implementation, the expansion module 504 is specifically used to: determine container directory information of the database; wherein the container directory is a directory used by the container where the database is located; and perform directory expansion processing on the container where the database is located according to the planned expansion information and the container directory.

[0194] In a possible implementation, the second acquisition module 503 is specifically used to: if it is determined that the number of expansion times is less than the configured expansion times, determine the container state of the database; if it is determined that the container state indicates that all containers in the server where the database is located are running normally, determine the database state of the database; if it is determined that the database state indicates that the database is running normally, obtain the container configuration information of the database.

[0195] In a possible implementation, the first acquisition module 501 is specifically used to: monitor the container status and database status of the database; if it is monitored that the container status indicates that all containers in the server where the database is located are running normally, and if it is monitored that the database status indicates that the database is running normally, collect the resource usage of the database and determine the number of over-values ​​corresponding to the resource usage; wherein the resource usage represents the resource usage of the container where the database is located; the number of over-values ​​is the total number of times the resource usage continuously exceeds a preset threshold within a preset time period; if it is determined that the number of over-values ​​is greater than the preset number, it is determined that the current database resources are insufficient.

[0196] In a possible implementation, the device is also used to: obtain resource usage information of the database; wherein the resource usage information represents the resource usage of the database; determine the resource status of the database based on the resource usage information; wherein the resource status represents the idle status of the database service resources; and scale down the database based on the resource status of the database.

[0197] In a possible implementation, the device is also specifically used to: determine the creation duration of the database, and if it is determined that the creation duration is greater than or equal to a preset duration, obtain unit information of the database; wherein the unit information is information of the database service unit; and determine the resource usage information of the database based on the unit information.

[0198] In a possible implementation, the device is further specifically used to: determine the unit operation state of the database according to the unit information; if it is determined that the unit operation state represents that the resource demand of the operation environment of the database service unit is minimal, determine the resource usage information of the database.

[0199] In one possible implementation, the resource usage information includes the central processing unit CPU usage rate, the memory change rate, the table space change rate, the log space change rate, the number of connections and the number of users; the device is also specifically used to: if it is determined that the number of connections and the number of users are both zero, then determine that the resource state is idle; if it is determined that the number of connections and the number of users are not zero, and it is determined that any one of the memory change rate, the table space change rate and the log space change rate is greater than a first preset threshold, then determine that the resource state is normal.

[0200] In a possible implementation, the device is also specifically used to: if it is determined that the number of connections is zero and the number of users is not zero, and it is determined that the CPU usage, memory change rate, table space change rate and log space change rate are all less than a second preset threshold, then determine that the resource state is an idle state; if it is determined that the number of connections is zero and the number of users is not zero, and it is determined that any one of the CPU usage, memory change rate, table space change rate and log space change rate is greater than or equal to the second preset threshold, then determine that the resource state is a surplus state.

[0201] In a possible implementation, the device is also specifically used to: if it is determined that the number of connections and the number of users are not zero, and it is determined that the memory change rate, the table space change rate, and the log space change rate are all less than or equal to a first preset threshold, then determine that the resource state is a surplus state.

[0202] In a possible implementation manner, the device is further specifically configured to: if it is determined that the number of connections is not zero and the number of users is zero, determine that the resource state is a surplus state.

[0203] In a possible implementation, the resource state is any one of an idle state, a surplus state, and a normal state; the device is further used to: if it is determined that the resource state is an idle state or a surplus state, determine the container state and the database state of the database; if it is determined that the container state indicates that all containers in the server where the database is located are running normally, and it is determined that the database state indicates that the database is running normally, then according to the container configuration information and resource state of the database, shrink the database.

[0204] In a possible implementation, the device is further specifically used to: if it is determined that the resource state is a surplus state, determine the single shrinkage quantity of the database; wherein the single shrinkage quantity is the number of shrinkage resources allowed when performing a single shrinkage operation; determine the planned shrinkage information of the database based on the single shrinkage quantity and container configuration information; wherein the planned shrinkage information represents the number of resources planned to be reached after the database is shrunk; according to the database type of the database, perform memory shrinkage processing on the database; and according to the planned shrinkage information, shrink the containers in the database.

[0205] In a possible implementation, the device is further specifically used to: if it is determined that the resource state is an idle state, then perform memory shrinkage processing on the database according to a preset minimum shrinkage amount; wherein the minimum shrinkage amount is the minimum resource amount planned to be reached after the database is shrunk.

[0206] The device of this embodiment can execute the technical solution in the above method. Its specific implementation process and technical principles are the same and will not be repeated here.

[0207] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. Each module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The functions of each module. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0208] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig.10 As shown, the electronic device includes: a memory 601, a processor 602; the memory 601; and a memory for storing instructions executable by the processor 602.

[0209] The processor 602 is configured to execute the method provided in the above embodiment.

[0210] The electronic device 600 further includes a receiver 603 and a transmitter 604. The receiver 603 is used to receive instructions and data sent by other devices, and the transmitter 604 is used to send instructions and data to external devices.

[0211] An embodiment of the present application also provides a chip for executing instructions, which is used to execute the technical solution of the processing method in the above embodiment.

[0212] The embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the technical solution of the processing method of the above embodiment.

[0213] An embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When at least one processor executes the computer program, the technical solution of the processing method in the above embodiment can be implemented.

[0214] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0215] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.

[0216] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.

[0217] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

[0218] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0219] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A database processing method, characterized in that: include: It is detected that the current database resources are insufficient, and alarm information of the database is obtained; wherein the alarm information includes an alarm type, and the alarm type is the type of the resource in the database that is in an insufficient state; Determine the number of capacity expansions and capacity expansion configuration information corresponding to the alarm type; wherein the number of capacity expansions is the number of capacity expansion operations that have been performed for each alarm type within a preset time period; the capacity expansion configuration information includes the number of configured capacity expansions and the number of single capacity expansions, wherein the number of configured capacity expansions is the number of capacity expansion operations that are allowed to be performed for each alarm type within a preset time period; the number of single capacity expansions is the number of capacity expansion resources allowed when a single capacity expansion operation is performed for each alarm type; If it is determined that the number of expansion times is less than the number of configuration expansion times, obtaining container configuration information of the database; wherein the container configuration information represents configuration data required when the container where the database is located is running; The database is expanded according to the single expansion quantity and the container configuration information.

2. The method according to claim 1, characterized in that: The database is expanded according to the single expansion quantity and the container configuration information, including: Determine the planned capacity expansion information of the database according to the single capacity expansion quantity and the container configuration information; wherein the planned capacity expansion information represents the planned number of resources to be achieved after the database capacity expansion; According to the planned capacity expansion information, the container where the database is located is expanded; Determine the type of the database, and perform memory expansion processing on the database according to the type of the database.

3. The method according to claim 2, characterized in that According to the planned capacity expansion information, the container where the database is located is expanded, including: Determine a container allocation cycle of the database; wherein the container allocation cycle is a reallocation cycle of memory resources of the container where the database is located; Determine the running time corresponding to the container allocation cycle; wherein the running time is the running time of the container where the database is located within the container allocation cycle; The container where the database is located is expanded according to the planned expansion information, the container allocation cycle, and the running time.

4. The method according to claim 3, characterized in that: The method further comprises: Determine container directory information of the database; wherein the container directory is a directory used by the container where the database is located; According to the planned capacity expansion information and the container directory, directory capacity expansion processing is performed on the container where the database is located.

5. The method according to claim 1, characterized in that If it is determined that the number of expansion times is less than the number of configuration expansion times, obtaining container configuration information of the database includes: If it is determined that the number of expansion times is less than the number of configured expansion times, determining the container state of the database; If it is determined that the container status indicates that all containers in the server where the database is located are running normally, then determining the database status of the database; If it is determined that the database state indicates that the database runs normally, the container configuration information of the database is obtained.

6. The method according to claim 1, characterized in that The current database resources are insufficient, including: Monitoring the container status and database status of the database; If it is monitored that all containers in the server where the container status represents the database are running normally, and if it is monitored that the database status represents the database is running normally, the resource usage rate of the database is collected, and the number of over-values ​​corresponding to the resource usage rate is determined; wherein the resource usage rate represents the resource usage of the container where the database is located; the number of over-values ​​is the total number of times the resource usage rate continuously exceeds a preset threshold within a preset time period; If it is determined that the number of over-value times is greater than a preset number, it is determined that the current database resources are insufficient.

7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: Acquire resource usage information of the database; wherein the resource usage information represents resource usage of the database; Determine the resource status of the database according to the resource usage information; wherein the resource status represents the idleness of the database service resources; The database is scaled down according to the resource status of the database.

8. The method according to claim 7, characterized in that Obtain resource usage information of the database, including: Determine the creation duration of the database, and if it is determined that the creation duration is greater than or equal to a preset duration, obtain unit information of the database; wherein the unit information is information of a database service unit; Resource usage information of the database is determined according to the unit information.

9. The method according to claim 8, characterized in that Determining resource usage information of the database according to the unit information includes: Determining a unit operation status of the database according to the unit information; If it is determined that the unit operation status indicates that the resource requirement of the operation environment of the database service unit is minimal, then the resource usage information of the database is determined.

10. The method according to claim 7, characterized in that The resource usage information includes CPU usage, memory change rate, table space change rate, log space change rate, number of connections, and number of users; Determining the resource status of the database according to the resource usage information includes: If it is determined that the number of connections and the number of users are both zero, then determining that the resource state is an idle state; If it is determined that the number of connections and the number of users are not zero, and if it is determined that any one of the memory change rate, the table space change rate, and the log space change rate is greater than a first preset threshold, then the resource status is determined to be a normal status.

11. The method according to claim 10, characterized in that The method further comprises: If it is determined that the number of connections is zero, the number of users is not zero, and it is determined that the CPU usage rate, the memory change rate, the table space change rate, and the log space change rate are all less than a second preset threshold, then it is determined that the resource state is an idle state; If it is determined that the number of connections is zero and the number of users is not zero, and it is determined that any one of the CPU usage rate, the memory change rate, the table space change rate and the log space change rate is greater than or equal to the second preset threshold, then the resource status is determined to be a surplus status.

12. The method according to claim 10, characterized in that The method further comprises: If it is determined that the number of connections and the number of users are not zero, and it is determined that the memory change rate, the table space change rate, and the log space change rate are all less than or equal to the first preset threshold, then the resource state is determined to be a surplus state.

13. The method according to claim 10, characterized in that The method further comprises: If it is determined that the number of connections is not zero and the number of users is zero, then it is determined that the resource state is a surplus state.

14. The method according to claim 7, characterized in that The resource state is any one of an idle state, a surplus state, and a normal state; and the database is scaled down according to the resource state of the database, including: If it is determined that the resource state is an idle state or a surplus state, then determining a container state and a database state of the database; If it is determined that all containers in the server where the container status represents the database are running normally, and it is determined that the database status represents that the database is running normally, the database is scaled down according to the container configuration information and the resource status of the database.

15. The method according to claim 14, characterized in that The database is scaled down according to the container configuration information of the database and the resource status, including: If it is determined that the resource state is a surplus state, then determining the single shrinkage quantity of the database; wherein the single shrinkage quantity is the shrinkage quantity of resources allowed when performing a single shrinkage operation; Determine the planned shrinkage information of the database according to the single shrinkage quantity and the container configuration information; wherein the planned shrinkage information represents the planned resource quantity after the database is shrunk; According to the database type of the database, performing memory reduction processing on the database; The containers in the database are shrunk according to the planned shrinkage information.

16. The method according to claim 14, characterized in that The method further comprises: If it is determined that the resource state is an idle state, the database is subjected to memory shrinkage processing according to a preset minimum shrinkage amount; wherein the minimum shrinkage amount is the minimum resource amount planned to be reached after the database is shrunk.

17. A database processing device, characterized in that: include: A first acquisition module is used to monitor that the current database resources are insufficient and obtain alarm information of the database; wherein the alarm information includes an alarm type, and the alarm type is the type of resources in the database that are in an insufficient state; A determination module, used to determine the number of expansion times and expansion configuration information corresponding to the alarm type; wherein the number of expansion times is the number of expansion operations that have been performed for each alarm type within a preset time period; the expansion configuration information includes the number of configured expansion times and the number of single expansions, wherein the number of configured expansion times is the number of expansion operations allowed to be performed for each alarm type within a preset time period; the number of single expansions is the number of expansion resources allowed when a single expansion operation is performed for each alarm type; A second acquisition module is used to acquire container configuration information of the database if it is determined that the number of expansion times is less than the number of configuration expansion times; wherein the container configuration information represents configuration data required when the container where the database is located is running; The expansion module is used to expand the database according to the single expansion quantity and the container configuration information.

18. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 16.

19. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1 to 16.

20. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 16 is implemented.