A resource configuration method and device of a database server

By setting the resource configuration of the standby database to the minimum configuration during primary-standby database switching and adjusting the resource configuration of the primary database as needed, the problem of low database server resource utilization is solved, achieving more efficient resource utilization and applicability.

CN115438021BActive Publication Date: 2026-05-15CHINA UNIONPAY
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA UNIONPAY
Filing Date
2022-08-08
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

In existing technologies, the low utilization rate of database server resources is mainly due to the difficulty for users to accurately predict resource needs, resulting in resource waste and the fact that backup databases still occupy a large amount of resources even when they are not in use.

Method used

When switching between primary and standby databases, the resource configuration of the standby database is updated to the minimum configuration, and the resource configuration of the primary database is dynamically adjusted as needed. This avoids dynamic scaling of the primary database and only adjusts the resource configuration of the standby database.

Benefits of technology

It improves the resource utilization of the database server, is suitable for various use cases, avoids the inaccuracy and lag of dynamic scaling, and saves server resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115438021B_ABST
    Figure CN115438021B_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to a resource configuration method and device of a database server. The method comprises: in response to a master-slave switching instruction for any first database system, obtaining a master resource configuration amount of a master database in the first database system; updating a standby resource configuration amount of a standby database in the first database system to the master resource configuration amount; the standby resource configuration amount is set to a minimum configuration amount in the case that the standby database in the first database system has no service demand; updating the standby database in the first database system to a master database in the first database system, so that the updated master database provides services based on the updated master resource configuration amount. The standby database does not occupy server resources when it does not provide services, thereby saving more resources for the host server of the standby database to deploy other master databases, and improving the resource utilization of the server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a resource configuration method, apparatus, computing device, and computer-readable storage medium for a database server. Background Technology

[0002] To improve database server resource utilization, the current approach is to deploy multiple databases on a single database server. A database cloud platform manages multiple database servers. Users request database systems with certain resources from the platform, and the platform allocates the appropriate database resources from any database server to the user based on their request. A database system is a collective term for one or more databases requested by the user. For example, a database system can include only one database, one primary database and one backup database, or one primary database and multiple backup databases. Backup databases are used to ensure data security and business continuity. For instance, when the database server hosting the primary database fails, the backup database immediately takes over the business operations on the primary database, thereby shortening the database system's downtime and meeting high availability requirements.

[0003] Figure 1a This illustrates a possible application scenario: a database cloud platform manages multiple database servers (database server 100, database server 200, and database server 300 as shown in the figure). For ease of description, it is assumed that each database server has 48 central processing unit (CPU) cores. User A, after assessing their required CPU resources, requests a database system from the database cloud platform. This database system includes a primary database with 8 CPU cores and a backup database with 8 CPU cores. If the database cloud platform determines that database server 100 can meet the request for 8 CPU cores, it deploys a primary database for user A on database server 100; if it determines that database server 200 can meet the request for 8 CPU cores, it deploys a backup database for user A on database server 200 (to ensure high availability, the primary and backup databases are generally not located on the same database server). At this point, the database system requested by user A has been deployed. Figure 1bThe diagram illustrates a possible database deployment scenario for database server 100. For simplicity, it is assumed that database server 100 has 48 CPU cores, and each user requests a database with 8 CPU cores from the database cloud platform. Database server 100 deploys a primary database with 8 CPU cores for user A; a primary database with 8 CPU cores for user B; a primary database with 8 CPU cores for user C; a standby database with 8 CPU cores for user D; and a standby database with 8 CPU cores for user E. Generally, the database server reserves approximately 20% of its resources for expanding the current databases, therefore the remaining 8 CPU cores are not allocated.

[0004] However, the above methods inevitably lead to low resource utilization of the database server. This is mainly reflected in the following aspects: 1. Users cannot accurately predict their actual resource usage needs. To ensure that the database usage demand can be met during peak periods, they tend to apply for higher-specification database systems, resulting in a waste of database server resources. For example, for user A, a database with 4 CPU cores is sufficient for most of the time, but 8 CPU cores are required during rare peak periods. Therefore, user A will apply for a database with 8 CPU cores from the cloud database platform. 2. Most users have high requirements for data security and business continuity, so they will apply for one or more backup databases. When the primary database fails or other situations occur, the backup database will switch to provide external services. To ensure that the capabilities provided by the backup database are not degraded after the switch, even if the backup database has not yet provided external services, it needs to be configured with the same resources as the primary database, further wasting database server resources. For example... Figure 1b In the database server 100, there may currently only be 3 primary databases providing external services, while the other 2 backup databases do not provide external services, but still occupy a considerable amount of CPU resources. Summary of the Invention

[0005] This invention provides a resource configuration method for a database server to improve the resource utilization of the database server.

[0006] In a first aspect, embodiments of the present invention provide a resource configuration method for a database server, comprising:

[0007] In response to a master-slave switchover command for any first database system, the master resource configuration amount of the master database in the first database system is obtained; the master-slave switchover command is used to instruct the standby database of the first database system to replace the master database to provide services; the resource configuration amount is the amount of central processing unit CPUs configured for the database on the host server of the database;

[0008] The backup resource configuration of the backup database in the first database system is updated to the primary resource configuration; the backup resource configuration is set to the minimum configuration when the backup database in the first database system has no service requirements; the shared resource configuration of the host server of the backup database in the first database system is greater than or equal to the primary resource configuration; the shared resource configuration is shared by each backup database deployed in the host server;

[0009] The backup database of the first database system is updated to become the primary database of the first database system, so that the updated primary database provides services based on the updated primary resource configuration.

[0010] When the backup database in the first database system has no service requirements, its backup resource configuration is set to the minimum configuration, and it provides service only through the primary database's primary resource configuration. When the first database system needs to perform a primary-backup switchover, the backup resource configuration of the backup database is updated to the primary resource configuration, allowing the updated primary database to provide service based on the updated primary resource configuration. In the above scheme, the backup database does not occupy server resources when it is not providing service, thereby saving more resources for the host server of the backup database to deploy other primary databases, improving server resource utilization. Compared with predictive and monitoring methods, the method provided in this embodiment does not dynamically scale up or down the primary database that is currently providing service and the backup database that is not providing service simultaneously. Instead, it does not make any changes to the resource configuration of the primary database that is currently providing service, and sets the resource configuration of the backup database to the minimum configuration. Only after receiving a primary-backup switchover instruction is the backup resource configuration of the backup database set to the same primary resource configuration as the primary database. Since the primary database provides services based on its primary resource allocation—a sufficient amount requested by users to support business operations according to their specific needs—dynamic scaling is unnecessary. This allows it to handle extreme situations such as sudden business surges without the inaccuracies and lags caused by dynamic scaling. It caters to various use cases and is highly adaptable. Conversely, saving the backup database's backup resource allocation to improve server resource utilization differs from predictive or monitoring-based methods.

[0011] In some embodiments, the backup resource configuration amount of the backup database of the first database system is set to the minimum configuration amount in the following ways:

[0012] Based on the shared triggering behavior of the first database system, the account patterns of each account using the first database system are obtained; the shared triggering behavior is the user's application behavior to the first database system or the behavior of adding a new account in the first database system.

[0013] Based on the account patterns, it is determined that the first database system does not have a service requirement for both the primary database and the backup database to provide services simultaneously.

[0014] Set the backup resource configuration of the backup database of the first database system to the minimum configuration.

[0015] When a user applies for a new account in the first database system, or when a new account is added in the first database system, the account schema of each account using the first database system is obtained. Based on the account schema, it is determined that there is no service requirement for the first database system to provide services from both the primary and backup databases simultaneously. Therefore, the backup resource configuration of the backup database can be set to the minimum configuration. In this way, by determining the account schema, the problem of setting the backup resource configuration of the backup database to the minimum configuration in situations where both the primary and backup databases need to provide services simultaneously is prevented.

[0016] In some embodiments, setting the backup resource configuration amount of the backup database of the first database system to the minimum configuration amount includes:

[0017] Obtain the backup resource requirements of the first database system requested by the user;

[0018] Select any database server and determine whether the shared resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then deploy the backup database of the first database system in the database server and set the backup resource configuration of the backup database of the first database system to the minimum configuration.

[0019] If the remaining resource configuration of the database server is not greater than or equal to the backup resource requirement, then it is determined whether the remaining resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then the backup database of the first database system is deployed in the database server, and the backup resource configuration of the backup database of the first database system is set to the minimum configuration. The shared resource configuration of the database server is updated to the backup resource requirement. If the remaining resource configuration is not greater than or equal to the backup resource requirement, then the backup database of the first database system is not deployed in the database server.

[0020] In some embodiments, it also includes:

[0021] If, based on the account patterns, it is determined that the first database system has a service requirement where both the primary and backup databases provide services simultaneously, then the backup resource configuration of the backup database in the first database system is set to the primary resource configuration.

[0022] It takes into full consideration various possible scenarios, making it more applicable.

[0023] In some embodiments, determining that the first database system does not have a service requirement for simultaneous service from both the primary and backup databases based on each account model includes:

[0024] If there are no read-write separation and read-only backup database account modes in each account mode, then it is determined that the first database system does not have a service requirement for the primary database and backup database to provide services simultaneously.

[0025] In some embodiments, after updating the backup database of the first database system to the primary database of the first database system, the method further includes:

[0026] The initial primary database of the first database system is updated to a backup database, and the backup resource configuration of the updated backup database is updated to the minimum configuration.

[0027] To enable rapid primary / standby failover, the system is configured to update the original primary database to the standby database after the failover, and then update the standby database's resource configuration to the minimum required level. This automatically sets the resource configuration of standby databases with no service requirements to the minimum, minimizing server resource consumption and improving server resource utilization.

[0028] In some embodiments, after updating the backup database of the first database system to the primary database of the first database system, the method further includes:

[0029] Update the initial primary database of the first database system to a backup database;

[0030] The method further includes:

[0031] Periodically retrieve multiple secondary database systems running on various servers; determine whether any backup database in any secondary database system has a backup resource configuration that is not at the minimum configuration level;

[0032] If so, then for the second database system, obtain the account patterns of each account using the second database system;

[0033] Based on the account patterns, it was determined that the second database system does not have a service requirement for both the primary and backup databases to provide services simultaneously.

[0034] Set the backup resource configuration of the backup database in the second database system to the minimum configuration.

[0035] To enable rapid primary / standby failover, only the standby resource configuration of the standby database is updated to the primary resource configuration before the failover. After the failover, the initial primary database of the database system is then updated to the standby database. To ensure timely setting of the resource configuration of each standby database to the minimum configuration, multiple second database systems running on each server are periodically retrieved. Each second database system is checked; if there is no service requirement for both the primary and standby databases to operate simultaneously, the standby resource configuration of the standby database in that second database system is set to the minimum configuration. This eliminates the need to set the standby database's resource configuration to the minimum configuration after each initial primary database is updated to the standby database; instead, it allows for periodic discovery and unified updates, which is simpler. This achieves unified updates of the standby resource configuration of the standby databases in each second database system.

[0036] Secondly, embodiments of the present invention also provide a resource configuration apparatus for a database server, comprising:

[0037] The acquisition unit is configured to acquire the primary resource configuration amount of the primary database in the first database system in response to a primary / standby switchover instruction for any first database system; the primary / standby switchover instruction is used to instruct the standby database of the first database system to replace the primary database in providing services; the resource configuration amount is the amount of central processing unit CPUs configured for the database on the host server of the database;

[0038] Processing unit, used for:

[0039] The backup resource configuration of the backup database in the first database system is updated to the primary resource configuration; the backup resource configuration is set to the minimum configuration when the backup database in the first database system has no service requirements; the shared resource configuration of the host server of the backup database in the first database system is greater than or equal to the primary resource configuration; the shared resource configuration is shared by each backup database deployed in the host server;

[0040] The backup database of the first database system is updated to become the primary database of the first database system, so that the updated primary database provides services based on the updated primary resource configuration.

[0041] In some embodiments, the processing unit is specifically used for:

[0042] Based on the shared triggering behavior of the first database system, the account patterns of each account using the first database system are obtained; the shared triggering behavior is the user's application behavior to the first database system or the behavior of adding a new account in the first database system.

[0043] Based on the account patterns, it is determined that the first database system does not have a service requirement for both the primary database and the backup database to provide services simultaneously.

[0044] Set the backup resource configuration of the backup database of the first database system to the minimum configuration.

[0045] In some embodiments, the processing unit is specifically used for:

[0046] Obtain the backup resource requirements of the first database system requested by the user;

[0047] Select any database server and determine whether the shared resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then deploy the backup database of the first database system in the database server and set the backup resource configuration of the backup database of the first database system to the minimum configuration.

[0048] If the remaining resource configuration of the database server is not greater than or equal to the backup resource requirement, then it is determined whether the remaining resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then the backup database of the first database system is deployed in the database server, and the backup resource configuration of the backup database of the first database system is set to the minimum configuration. The shared resource configuration of the database server is updated to the backup resource requirement. If the remaining resource configuration is not greater than or equal to the backup resource requirement, then the backup database of the first database system is not deployed in the database server.

[0049] In some embodiments, the processing unit is further configured to:

[0050] If, based on the account patterns, it is determined that the first database system has a service requirement where both the primary and backup databases provide services simultaneously, then the backup resource configuration of the backup database in the first database system is set to the primary resource configuration.

[0051] In some embodiments, the processing unit is specifically used for:

[0052] If there are no read-write separation and read-only backup database account modes in each account mode, then it is determined that the first database system does not have a service requirement for the primary database and backup database to provide services simultaneously.

[0053] In some embodiments, the processing unit is further configured to:

[0054] The initial primary database of the first database system is updated to a backup database, and the backup resource configuration of the updated backup database is updated to the minimum configuration.

[0055] In some embodiments, the processing unit is further configured to:

[0056] Update the initial primary database of the first database system to a backup database;

[0057] Periodically retrieve multiple secondary database systems running on various servers; determine whether any backup database in any secondary database system has a backup resource configuration that is not at the minimum configuration level;

[0058] If so, then for the second database system, obtain the account patterns of each account using the second database system;

[0059] Based on the account patterns, it was determined that the second database system does not have a service requirement for both the primary and backup databases to provide services simultaneously.

[0060] Set the backup resource configuration of the backup database in the second database system to the minimum configuration.

[0061] Thirdly, embodiments of the present invention also provide a computing device, comprising:

[0062] Memory, used to store computer programs;

[0063] The processor is configured to invoke a computer program stored in the memory and execute the resource configuration method of the database server listed in any of the above methods according to the obtained program.

[0064] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer-executable program, the computer-executable program being used to cause a computer to execute the resource configuration method of the database server listed in any of the above methods. Attached Figure Description

[0065] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0066] Figure 1a This is one possible application scenario provided by an embodiment of the present invention;

[0067] Figure 1b This invention provides a possible database deployment configuration for a database server 100 according to an embodiment of the invention.

[0068] Figure 2 A flowchart illustrating a resource configuration method for a database server provided in an embodiment of the present invention;

[0069] Figure 3 A schematic diagram illustrating a possible deployment method provided in an embodiment of the present invention;

[0070] Figure 4 A schematic diagram illustrating the used resource allocation, shared resource allocation, and remaining resource allocation of a possible database server, provided for an embodiment of the present invention.

[0071] Figure 5a A schematic diagram of a database server not deployed using the method provided in this embodiment of the invention;

[0072] Figure 5b A schematic diagram of a database server deployed using the method provided in this embodiment of the invention;

[0073] Figure 6 A flowchart illustrating a resource configuration method for a database server provided in an embodiment of the present invention;

[0074] Figure 7 This is a schematic diagram of the execution flow of a shared unit provided in an embodiment of the present invention;

[0075] Figure 8 A schematic diagram of the execution flow of a multi-configuration unit provided in an embodiment of the present invention;

[0076] Figure 9 A schematic diagram of the execution flow of a periodic inspection unit provided in an embodiment of the present invention;

[0077] Figure 10 A schematic diagram of the structure of a resource configuration device for a database server provided in an embodiment of the present invention;

[0078] Figure 11 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation

[0079] To make the objectives, implementation methods and advantages of this application clearer, the exemplary implementation methods of this application will be clearly and completely described below with reference to the accompanying drawings of the exemplary embodiments of this application. Obviously, the described exemplary embodiments are only some embodiments of this application, and not all embodiments.

[0080] Based on the exemplary embodiments described in this application, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of the appended claims. Furthermore, although the disclosures in this application are presented by way of one or more exemplary examples, it should be understood that each aspect of these disclosures can also constitute a complete implementation on its own.

[0081] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.

[0082] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities and do not necessarily imply a specific order or sequence, unless otherwise indicated. It should be understood that such terms can be used interchangeably where appropriate, for example, to implement the application in a sequence other than those given in the embodiments illustrated or described herein.

[0083] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclusively include, for example, a product or device that includes a series of components is not necessarily limited to those that are explicitly listed, but may include other components that are not explicitly listed or that are inherent to such product or device.

[0084] This invention provides two methods for configuring database server resources to improve the resource utilization of database servers.

[0085] Method 1, Predictive Method: By learning the historical usage patterns of any user's database resources, this method predicts the user's future database resource needs for a given time period. Based on the prediction results, it dynamically scales up or down the user's database resources. For example, if it is predicted that user A's CPU resource usage requirement for the next hour is 4 cores, then in the next hour, the CPU resources allocated to user A's primary database on database server 100 will be adjusted to 4 cores, and the CPU resources allocated to user A's backup database on database server 200 will also be adjusted to 4 cores.

[0086] Method 2, Monitoring Method: By collecting monitoring metrics of each database on any database server during the current time period, and comparing these metrics with those of other database servers offering the same business type, it is determined whether to dynamically scale up or down the resources of each database on that database server in the next time period. For example, based on the comparison results for the current time period, the CPU resources allocated to the primary database for user A on database server 100 in the next time period might be adjusted to 4 cores, and the CPU resources allocated to the backup database for user A on database server 200 in the next time period might also be adjusted to 4 cores.

[0087] The drawback of using predictive methods for dynamic scaling is the difficulty in guaranteeing the accuracy of predictions. This is especially true in scenarios like marketing campaigns and flash sales where resources are needed randomly and in a short period, making it difficult to accurately predict resource demands based on patterns and thus preventing proactive scaling. The drawback of using monitoring methods for dynamic scaling is poor real-time performance. Formulating scaling plans for the next period based on current monitoring metrics is prone to lag and cannot meet the needs of scenarios with random occurrences and short-term resource demands.

[0088] In summary, both of these methods have the drawback of untimely or inaccurate resource scaling, which may lead to failure to meet user needs. They can only be applied in certain specific business scenarios, such as scenarios where user resource needs are relatively stable.

[0089] This invention provides another resource configuration method for a database server, which no longer dynamically scales up and down the primary and backup databases simultaneously, but only dynamically scales up and down the backup database. Furthermore, the dynamic scaling of the backup database is not based on prediction or monitoring of user resource usage needs, thus eliminating the problem of untimely or inaccurate resource scaling. This improves the resource utilization of the database server and can meet various usage scenarios, demonstrating strong applicability.

[0090] Figure 2 This invention illustrates a resource configuration method for a database server, which sets the backup resource configuration amount of a backup database in a user-requested database system to the minimum configuration amount. The method includes:

[0091] Step 201: Based on the shared triggering behavior for the first database system, obtain the account patterns of each account using the first database system; the shared triggering behavior is the user's application behavior to the first database system or the behavior of adding a new account in the first database system.

[0092] Step 202: Determine, based on the account patterns, that the first database system does not have a service requirement where the primary database and backup database provide services simultaneously.

[0093] Step 203: Set the backup resource configuration of the backup database of the first database system to the minimum configuration.

[0094] In step 201, the user applies for a database system from the database cloud platform. The database system can include only one primary database, one primary database and one backup database, or one primary database and multiple backup databases; there are no restrictions. If the database system does not include backup databases, there is no need to set the backup resource configuration of the backup databases to the minimum configuration; the primary resource configuration of the primary database can be set directly according to the user's needs. Therefore, the first database system in this embodiment specifically refers to a database system that includes one or more backup databases.

[0095] One possible scenario is that after a user applies for the first database system from the database cloud platform, the platform obtains the account schemas of each account using that system. An account refers to the account that will subsequently use the first database system for operations such as querying and modifying data; therefore, there may be one or more accounts.

[0096] For example, user A applies to a database cloud platform for a first database system, including a primary database with 8 CPU cores and a backup database with 8 CPU cores. The database cloud platform obtains the account schemas for each account corresponding to this first database system. These account schemas may be submitted by user A when applying for the first database system, retrieved proactively by the database cloud platform, or obtained through other methods. No restrictions are placed on this.

[0097] Another possible scenario is that a user has already applied for the first database system, and one or more accounts are already using it. When a new account uses the first database system, the database cloud platform will also obtain the account patterns of each account using the first database system, including the account patterns of the newly added account.

[0098] For example, user A has already applied for the first database system. The primary database in this first database system is deployed on database server 100, and the backup database is deployed on database server 200. Accounts zhangsan and lisi are already using this first database system. When a new account wangwu is added, the database cloud platform will also obtain the account patterns of all accounts using this first database system, specifically the account patterns of zhangsan, lisi, and wangwu.

[0099] In step 202, it is determined that the first database system does not have a service requirement for both the primary database and the backup database to provide services simultaneously, based on the account patterns of each account.

[0100] Among the accounts using this first database system, there may be service requirements that necessitate simultaneous service from both the primary and backup databases. This can be determined by the account configuration of each account. For example, if it is determined that read-write splitting mode and / or read-only slave mode exist among the account configurations, it indicates that the first database system has a service requirement where both the primary and backup databases must provide services simultaneously. In this case, the backup resource configuration of the backup database in the first database system cannot be the minimum configuration; it should be consistent with the primary resource configuration of the primary database.

[0101] For example, the primary database is configured with 8 cores, and the backup database is also configured with 8 cores.

[0102] If it is determined that there is no read-write separation mode or read-only slave mode in each account mode, then the backup resource configuration of the backup database of the first database system can be the minimum configuration. Setting it to the minimum configuration will not affect the normal service of the first database system.

[0103] In step 203, the backup resource configuration amount of the backup database of the first database system is set to the minimum configuration amount.

[0104] One possible scenario is that the backup database has not yet been deployed on any database server before step 203. Therefore, the backup database is deployed on any database server only after it is determined that the first database system does not have a service requirement for both the primary and backup databases to provide services simultaneously. Figure 3 One possible deployment method is shown, which includes the following steps:

[0105] Step 301: Obtain the backup resource requirements of the first database system requested by the user.

[0106] For example, a user requests a primary database with 8 CPU cores and a backup database with 8 CPU cores. The database cloud platform determines that the user's requested backup resource requirement is 8 cores.

[0107] Step 302: Select any database server and determine whether the shared resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, deploy the backup database of the first database system in the database server and set the backup resource configuration of the backup database of the first database system to the minimum configuration.

[0108] For any database server's resources, two components are defined: used resource allocation and shared resource allocation. Used resource allocation is the sum of the resource allocations allocated to the primary databases; shared resource allocation is the amount of resources prepared for each standby database, used for sharing among them. Shared resource allocation can be fixed or dynamically adjusted. For example, database server 100 has 48 CPU cores, of which 24 cores are allocated to the primary databases, each with 8 cores. Therefore, the used resource allocation for database server 100 is 24 cores. If the shared resource allocation is fixed at 10 cores, then each standby database deployed on database server 100 shares these 10 CPU cores, with no single standby database having a resource allocation greater than 10 cores. When two more primary databases, each requiring 8 cores, and one primary database, requiring 10 cores, are deployed on database server 100, the used resource allocation becomes 32 cores, while the shared resource allocation remains 10 cores. The current database server 100 can also accept multiple backup databases deployed on it, as long as the backup resource requirements of these backup databases do not exceed 10 cores.

[0109] If the shared resource allocation is dynamically adjusted, it can be done as follows: For example, database server 100 has 48 CPU cores, of which 24 cores are allocated to the primary databases. Each primary database has 8 cores. Therefore, the used resource allocation of database server 100 is 24 cores, and the shared resource allocation is 0 cores. When backup database a is deployed on database server 100, and the user requests 8 cores for backup database a, the shared resource allocation is 8 cores. When backup database b is deployed on database server 100, and the user requests 10 cores for backup database b, the shared resource allocation is updated to 10 cores. When primary database c is deployed on database server 100, and the user requests 14 cores for primary database c, the used resource allocation is 38 cores.

[0110] For example, when the backup resource requirement of the first database system is 8 cores, database server 100 is selected. It is then determined whether the shared resource configuration of database server 100 is greater than or equal to the backup resource requirement of 8 cores. If it is, the backup database of the first database system is deployed on database server 100, and the backup resource configuration of the backup database of the first database system is set to the minimum configuration. This minimum configuration can be 0 cores, 1 core, or other configurations that meet the minimum requirement. In other words, the shared configuration is not actually fully provided to the backup database.

[0111] Step 303: If the remaining resource configuration of the database server is not greater than or equal to the backup resource requirement, then determine whether the remaining resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then deploy the backup database of the first database system in the database server, set the backup resource configuration of the backup database of the first database system to the minimum configuration, and update the shared resource configuration of the database server to the backup resource requirement. If the remaining resource configuration is not greater than or equal to the backup resource requirement, then do not deploy the backup database of the first database system in the database server.

[0112] The remaining configuration is the total resource configuration of the database server minus the used configuration.

[0113] For example, if the database server has a shared resource configuration of 8 cores and a backup resource requirement of 10 cores, and the shared resource configuration is not greater than or equal to the backup resource requirement, then it is determined whether the remaining resource configuration is greater than or equal to the backup resource requirement. If the remaining resource configuration is 10 cores, then the condition that the remaining resource configuration is greater than or equal to the backup resource requirement is met. Therefore, the backup database is still deployed on the database server, and the backup resource configuration of the backup database is set to the minimum configuration, such as 0 cores. The shared resource configuration of the database server is then updated to 10 cores.

[0114] Figure 4 This diagram illustrates the used resource allocation, shared resource allocation, and remaining resource allocation of a possible database server. Both backup databases have a backup resource allocation of 0 cores each, and share a common resource allocation of 8 cores.

[0115] Another possible scenario for step 203 is that, prior to step 203, the primary and backup databases of the first database system have already been deployed on database servers according to their respective resource requirements. For example, if a user requests the first database system, including a primary database with 8 CPU cores and a backup database with 8 CPU cores, the database cloud platform deploys the primary database on database server 100, allocating it 8 CPU cores, and deploys the backup database on database server 200, allocating it 8 CPU cores. This configuration method does not require any changes to the original database deployment code logic. Upon receiving the user's database system request, for the primary database, it only needs to compare the remaining resource allocation of any database server with the primary database's resource requirements. If it is greater than or equal to the primary database's resource requirements, the primary database is deployed on that database server; otherwise, the next database server is used for judgment, until the primary database is deployed on a database server. For the backup database, the remaining resource allocation of any database server is compared with the backup resource requirement of the backup database. If it is greater than or equal to the backup resource requirement of the backup database, the backup database is deployed on that database server. If it is not greater than or equal to the backup resource requirement of the backup database, the next database server is used for judgment, until the backup database is deployed on a certain database server.

[0116] After the above deployment, the database cloud platform obtains the backup resource configuration amount of the backup database and changes the backup resource configuration amount to the minimum configuration amount.

[0117] For example, change the backup resource configuration of 8 cores to the minimum configuration of 0 cores.

[0118] The above method does not require changing the original deployment logic, nor does it require comparing resource requirements with shared and remaining resources. Deploying the backup database according to its resource requirements ensures that the deployed database server can support the backup database's resource needs during a primary-backup switch. For example, during a primary-backup switch, if the backup database's resource configuration is updated from 0 to 8 cores, the remaining resource configuration of the backup database's host server will definitely be sufficient to meet this update.

[0119] Figure 5a A database server not deployed using the method provided in the embodiments of the present invention is shown; Figure 5bThe figure illustrates a database server deployed using the method provided in this embodiment of the invention. As shown, without the method provided in this embodiment, only five databases can be deployed on the database server because each backup database also requires an allocation of 8 CPU cores, even if that backup database is not providing external services. With the method provided in this embodiment, each backup database shares 8 CPU cores, allowing more than five databases to be deployed on the database server, such as the nine shown in the figure. The increased number of databases on the database server leads to increased resource utilization.

[0120] In the above deployment method, multiple backup databases share the remaining unallocated CPU resources of the database server, for example... Figure 5b In this database, all 8 cores of CPU resources are shared. Although the resource isolation between the backup databases is reduced, since these backup databases do not provide services to the outside world—that service is provided by the primary database—the reduced resource isolation does not affect the normal operation of the database system.

[0121] In the above technical solution, when a user applies for a new application for the first database system, or when a new account is added to the first database system, the account patterns of each account using the first database system are obtained. Based on the account patterns, it is determined that the first database system does not have a service requirement for both the primary and backup databases to provide services simultaneously. Therefore, the backup resource configuration of the backup database can be set to the minimum configuration. In this way, by determining the account patterns, the problem of setting the backup resource configuration of the backup database to the minimum configuration in situations where both the primary and backup databases need to provide services simultaneously is prevented. If the first database system requires both the primary and backup databases to provide services simultaneously, and the backup resource configuration of the backup database is set to the minimum configuration, then the first database service cannot provide the services required by the user.

[0122] In some embodiments, databases are deployed using containers for any given database server. A container (DOCKER) is a virtualization technology, a lightweight virtualization solution based on process containers. Unlike virtual machine (VM) technology, container technology achieves lightweight virtualization by isolating resources and processes, with negligible performance overhead. Each database is deployed in an independent container on the database server, and each container is configured with a dedicated IP address, CPU and memory, and an independent file system for tablespaces and log spaces.

[0123] After the above deployment, the backup database has the minimum resource configuration. The following describes how to restore the backup database to its minimum resource configuration.

[0124] Figure 6 This invention illustrates a resource configuration method for a database server provided in an embodiment of the invention, including:

[0125] Step 601: In response to a master-slave switchover command for any of the first database systems, obtain the master resource configuration amount of the master database in the first database system; the master-slave switchover command is used to instruct the standby database of the first database system to replace the master database in providing services; the resource configuration amount is the amount of central processing unit CPUs configured for the database on the host server of the database.

[0126] Step 602: Update the backup resource configuration of the backup database in the first database system to the primary resource configuration; the backup resource configuration is set to the minimum configuration when the backup database in the first database system has no service requirements; the shared resource configuration of the host server of the backup database in the first database system is greater than or equal to the primary resource configuration; the shared resource configuration is shared by each backup database deployed in the host server.

[0127] Step 603: Update the backup database of the first database system to the primary database of the first database system, so that the updated primary database provides services based on the updated primary resource configuration.

[0128] In step 601, the primary database of the first database system needs to be switched to the backup database for some reason. The reason for the primary / backup switch could be a failure of the primary database's host server, or a switch required by maintenance personnel for testing purposes. This embodiment of the invention does not impose such limitations.

[0129] Upon receiving the master-slave switchover command, the database cloud platform obtains the master resource configuration of the master database in the first database system. For example, the database cloud platform obtains that the master database has a master resource configuration of 6 cores.

[0130] In step 602, the host server of the backup database of the first database system is obtained, and the backup resource configuration of the backup database in the host server is updated to the primary resource configuration, for example, from 0 cores to 6 cores.

[0131] The host server deploys one or more backup databases, each sharing a portion of the resource allocation, with the shared resource allocation being greater than or equal to the primary resource allocation. For example... Figure 5b As shown, the four backup databases share the 8 CPU cores of the database server 100.

[0132] In step 603, the backup database of the first database system is updated to the primary database of the first database system. Then, the updated primary database can provide services based on the updated primary resource configuration.

[0133] When the backup database in the first database system has no service requirements, its backup resource configuration is set to the minimum configuration, and it provides service only through the primary database's primary resource configuration. When the first database system needs to perform a primary-backup switchover, the backup resource configuration of the backup database is updated to the primary resource configuration, allowing the updated primary database to provide service based on the updated primary resource configuration. In the above scheme, the backup database does not occupy server resources when it is not providing service, thereby saving more resources for the host server of the backup database to deploy other primary databases, improving server resource utilization. Compared with predictive and monitoring methods, the method provided in this embodiment does not dynamically scale up or down the primary database that is currently providing service and the backup database that is not providing service simultaneously. Instead, it does not make any changes to the resource configuration of the primary database that is currently providing service, and sets the resource configuration of the backup database to the minimum configuration. Only after receiving a primary-backup switchover instruction is the backup resource configuration of the backup database set to the same primary resource configuration as the primary database. Since the primary database provides services based on the primary resource configuration, which is a sufficient amount of resources requested by the user to support business operations according to their own business needs, there is no need for dynamic scaling up or down. It can meet extreme situations such as sudden business increases and does not have the inaccuracy and lag issues caused by dynamic scaling up or down. It can meet various types of use cases and has strong applicability.

[0134] When users apply for a database system, they typically request resources based on their maximum needs. For example, if they only need 8 CPU cores for one hour a day and 4 CPU cores for the remaining 23 hours, they would request an 8-core primary database and an 8-core standby database. The method provided in this embodiment does not dynamically scale the primary database's resource allocation; it consistently uses 8 CPU cores to provide services, thus ensuring it can support business operations. Therefore, there are no inaccuracies or lag issues caused by dynamic scaling. Dynamic scaling only applies to the standby database's resource allocation, and it's based on primary-standby failover. This differs from predictive and monitoring methods for dynamic scaling, addressing a different problem from the perspective of the methods used.

[0135] In some embodiments, after updating the backup database of the first database system to the primary database of the first database system, the method further includes: updating the initial primary database of the first database system to the backup database, and updating the backup resource configuration of the updated backup database to the minimum configuration.

[0136] To enable rapid primary / standby failover, the system is configured to update the original primary database to the standby database after the failover, and then update the standby database's resource configuration to the minimum required level. This automatically sets the resource configuration of standby databases with no service requirements to the minimum, minimizing server resource consumption and improving server resource utilization.

[0137] In some embodiments, after updating the initial primary database of the first database system to a standby database, the standby resource configuration of the updated standby database is not directly updated to the minimum configuration. Instead, a periodic check is used to identify standby databases that are not set to the minimum configuration and set them to the minimum configuration.

[0138] Specifically, the process involves periodically acquiring multiple second database systems running on various servers; determining whether any backup database in any second database system has a backup resource configuration that is not at the minimum configuration level; if so, acquiring the account patterns of each account using the second database system; determining, based on each account pattern, that the second database system does not have a service requirement for both the primary and backup databases to provide services simultaneously; and setting the backup resource configuration level of the backup database in the second database system to the minimum configuration level.

[0139] To enable rapid primary / standby failover, only the standby resource configuration of the standby database is updated to the primary resource configuration before the failover. After the failover, the initial primary database of the database system is then updated to the standby database. To ensure timely setting of the resource configuration of each standby database to the minimum configuration, multiple second database systems running on each server are periodically retrieved. Each second database system is checked; if there is no service requirement for both the primary and standby databases to operate simultaneously, the standby resource configuration of the standby database in that second database system is set to the minimum configuration. This eliminates the need to set the standby database's resource configuration to the minimum configuration after each initial primary database is updated to the standby database; instead, it allows for periodic discovery and unified updates, which is simpler. This achieves unified updates of the standby resource configuration of the standby databases in each second database system.

[0140] Before performing a master-slave switch, the backup database's backup resource configuration is modified, which takes only milliseconds. This has a negligible impact on the database system's external services.

[0141] Because the number of servers managed by a database cloud platform is quite large, the likelihood of multiple backup databases being switched to the primary database simultaneously on any given database server is low. For example... Figure 5bIn this setup, the primary databases corresponding to each backup database are likely distributed across different database servers, and the probability of these database servers failing simultaneously is very small. If they do fail simultaneously, all backup databases will switch to becoming primary databases, and these primary databases will share 8 CPU cores to provide services. Therefore, some resource isolation is sacrificed.

[0142] Therefore, in some embodiments, the number of backup databases participating in sharing on any database server can be limited, i.e., the number of backup databases participating in sharing on any database server is greater than a first threshold and less than a second threshold, for example, greater than 2 and less than 5. The first threshold is set to improve server resource utilization, and the second threshold is set to reduce the probability of sacrificing resource isolation.

[0143] To better explain the embodiments of the present invention, the resource configuration method of the database server described above will be described below in a specific implementation scenario.

[0144] In this embodiment of the invention, a shared unit, a reconfiguration unit, and a periodic check unit are set up in the database cloud platform.

[0145] The shared unit can be triggered in three scenarios: 1. When a user requests a database system, the shared unit will obtain the database system; 2. When a new account is added to the database system, the shared unit will obtain the database system; 3. When the periodic check unit detects that there is a backup database that is not set to the minimum configuration, the shared unit will obtain the database system corresponding to the backup database.

[0146] The execution flow of the shared unit is described below, such as... Figure 7 As shown, it includes:

[0147] Step 701: Receive the first database system and determine whether the database server where each backup database of the first database system is located allows the backup resource configuration of the backup database to be set to the minimum configuration.

[0148] The first database system here is the database system obtained after any one of the three scenarios above is triggered.

[0149] If not allowed, record it in the log and end the process.

[0150] Since some user businesses have high requirements for processing speed, such as transaction processing, the corresponding backup databases for these businesses can be deployed on a specific database server. The specific database server does not allow the backup resource configuration of any backup database deployed on it to be set to the minimum configuration value, because if this is done, during the primary-backup switch, the minimum configuration value needs to be restored to the primary resource configuration value, and a delay of a few milliseconds is not allowed.

[0151] Step 702: Obtain the deployment architecture information of the first database system.

[0152] The deployment architecture information includes the names, number of CPUs, amount of memory, IP addresses, ports, status, roles, and database server information of each database contained in the first database system. For example, it can retrieve information about three databases in the first database system, along with their names, number of CPUs, amount of memory, IP addresses, ports, status, roles, and database servers.

[0153] Step 703: parse the roles in the database.

[0154] Determine the primary and backup databases included in the first database system. For example, determine that the first database system contains one primary database and two backup databases.

[0155] Step 704: Obtain the CPU resource configuration of the main database.

[0156] Step 705: Obtain account information for using the first database system.

[0157] Call the database user query interface provided by the platform to obtain the account information configured in the first database service, including account name, account mode, blacklist / whitelist, number of connections and permission information.

[0158] Step 706: parse the account patterns of the first database system to determine whether there are account patterns for read-write separation and read-only slave databases.

[0159] These two modes refer to routing some SQL query requests to the standby database, reducing the query pressure on the primary database and meeting the needs of business scenarios with fewer writes and more reads. In this scenario, like the primary database, the standby database also provides services directly to the outside world, but only provides query services and does not provide data writing, updating, or deletion services.

[0160] Step 707: Set the backup resource configuration of each backup database to the minimum configuration.

[0161] Specifically, for any standby database, execute a command on the host server of that standby database to set the standby resource configuration to the minimum configuration.

[0162] Step 708: Set the backup resource configuration of each backup database to be the same as the primary resource configuration.

[0163] Specifically, for any standby database, execute a command on the host server of that standby database to set the standby resource configuration to the same as the primary resource configuration.

[0164] If any of the above steps fails, the exception will be logged for administrators to review.

[0165] The execution flow of the reconfiguration unit is described below, such as... Figure 8 As shown, it includes:

[0166] Step 801: In response to the master-slave switchover command for the first database system, obtain the deployment architecture information of the first database system.

[0167] The deployment architecture information includes the names, number of CPUs, amount of memory, IP addresses, ports, status, roles, and database server information of each database contained in the first database system. For example, it can retrieve information about three databases in the first database system, along with their names, number of CPUs, amount of memory, IP addresses, ports, status, roles, and database servers.

[0168] Step 802: Obtain the master resource configuration of the master database in the first database system.

[0169] Step 803: Obtain the name of the container and host server information of the first database system backup database.

[0170] Step 804: On the host server, execute a command to update the resource configuration of the container where the backup database is located to the primary resource configuration.

[0171] If it cannot be determined which backup database will be updated to the primary database, then execute the above update command on all backup databases. If it can be determined which backup database will be updated to the primary database, then only execute the above update command on the backup database that will be updated to the primary database.

[0172] If any of the above steps fails, the exception will be logged for administrators to review.

[0173] The execution flow of the periodic check unit is described below, such as... Figure 9 As shown, it includes:

[0174] Step 901: Determine whether a periodic check needs to be initiated at the current moment.

[0175] Step 902: Obtain the database systems running on each server.

[0176] Step 903: Wait 1 minute, then return to step 901.

[0177] Step 904: For any given database system, determine the deployment architecture information of that database system.

[0178] Call the database cloud platform interface to query the deployment architecture information of this database system, including database name, number of CPUs, amount of memory, IP address, port, status, role, and information related to the physical server it is located on.

[0179] Step 905: For any backup database in the database system, determine whether the number of CPUs in the backup database is 0. If yes, proceed to step 907. If no, proceed to step 906.

[0180] Step 906: Invoke the shared unit.

[0181] Step 907: Perform step 905 on the next backup database.

[0182] During primary / standby failover, the reconfiguration unit is only responsible for restoring the standby database's resource configuration to the primary resource configuration. This is to reduce operation time and perform the failover as quickly as possible after restoring the primary resource configuration. As mentioned in previous solutions, if there are multiple standby databases, because it's uncertain which standby database will be switched to the primary database, the resource configuration of each standby database will be restored to the primary resource configuration. For example, three standby databases might all be restored from 0 cores to 8 cores. Then, a primary / standby failover is performed. Furthermore, the initial primary database has been updated to a standby database and is no longer providing services, but its resource configuration remains at 8 cores.

[0183] All of the above situations can be detected by the periodic inspection unit. The periodic inspection unit will detect the initial primary database that has been updated to a backup database and the backup database whose backup resource configuration has been restored, and send the database systems corresponding to these backup databases to the shared unit for processing.

[0184] Based on the same technological concept Figure 10 An exemplary embodiment of the present invention illustrates the structure of a resource configuration apparatus for a database server, which can execute the resource configuration process of the database server.

[0185] like Figure 10 As shown, the device specifically includes:

[0186] The acquisition unit 1001 is used to acquire the primary resource configuration amount of the primary database in the first database system in response to a primary / standby switch command for any first database system; the primary / standby switch command is used to instruct the standby database of the first database system to replace the primary database to provide services; the resource configuration amount is the amount of central processing unit CPUs configured for the database on the host server of the database.

[0187] Processing unit 1002 is used for:

[0188] The backup resource configuration of the backup database in the first database system is updated to the primary resource configuration; the backup resource configuration is set to the minimum configuration when the backup database in the first database system has no service requirements; the shared resource configuration of the host server of the backup database in the first database system is greater than or equal to the primary resource configuration; the shared resource configuration is shared by each backup database deployed in the host server;

[0189] The backup database of the first database system is updated to become the primary database of the first database system, so that the updated primary database provides services based on the updated primary resource configuration.

[0190] In some embodiments, the processing unit 1002 is specifically used for:

[0191] Based on the shared triggering behavior of the first database system, the account patterns of each account using the first database system are obtained; the shared triggering behavior is the user's application behavior to the first database system or the behavior of adding a new account in the first database system.

[0192] Based on the account patterns, it is determined that the first database system does not have a service requirement for both the primary database and the backup database to provide services simultaneously.

[0193] Set the backup resource configuration of the backup database of the first database system to the minimum configuration.

[0194] In some embodiments, the processing unit 1002 is specifically used for:

[0195] Obtain the backup resource requirements of the first database system requested by the user;

[0196] Select any database server and determine whether the shared resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then deploy the backup database of the first database system in the database server and set the backup resource configuration of the backup database of the first database system to the minimum configuration.

[0197] If the remaining resource configuration of the database server is not greater than or equal to the backup resource requirement, then it is determined whether the remaining resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then the backup database of the first database system is deployed in the database server, and the backup resource configuration of the backup database of the first database system is set to the minimum configuration. The shared resource configuration of the database server is updated to the backup resource requirement. If the remaining resource configuration is not greater than or equal to the backup resource requirement, then the backup database of the first database system is not deployed in the database server.

[0198] In some embodiments, the processing unit 1002 is further configured to:

[0199] If, based on the account patterns, it is determined that the first database system has a service requirement where both the primary and backup databases provide services simultaneously, then the backup resource configuration of the backup database in the first database system is set to the primary resource configuration.

[0200] In some embodiments, the processing unit 1002 is specifically used for:

[0201] If there are no read-write separation and read-only backup database account modes in each account mode, then it is determined that the first database system does not have a service requirement for the primary database and backup database to provide services simultaneously.

[0202] In some embodiments, the processing unit 1002 is further configured to:

[0203] The initial primary database of the first database system is updated to a backup database, and the backup resource configuration of the updated backup database is updated to the minimum configuration.

[0204] In some embodiments, the processing unit 1002 is further configured to:

[0205] Update the initial primary database of the first database system to a backup database;

[0206] Periodically retrieve multiple secondary database systems running on various servers; determine whether any backup database in any secondary database system has a backup resource configuration that is not at the minimum configuration level;

[0207] If so, then for the second database system, obtain the account patterns of each account using the second database system;

[0208] Based on the account patterns, it was determined that the second database system does not have a service requirement for both the primary and backup databases to provide services simultaneously.

[0209] Set the backup resource configuration of the backup database in the second database system to the minimum configuration.

[0210] Based on the same technical concept, embodiments of this application provide a computer device, such as... Figure 11 As shown, it includes at least one processor 1101 and a memory 1102 connected to at least one processor. In this embodiment, the specific connection medium between the processor 1101 and the memory 1102 is not limited. Figure 11 Taking the connection between processor 1101 and memory 1102 via a bus as an example, the bus can be divided into address bus, data bus, control bus, etc.

[0211] In this embodiment of the application, the memory 1102 stores instructions that can be executed by at least one processor 1101. By executing the instructions stored in the memory 1102, at least one processor 1101 can perform the steps of the resource configuration method of the database server described above.

[0212] The processor 1101 is the control center of the computer device, capable of connecting various parts of the computer device via various interfaces and lines. It performs resource configuration for the database server by running or executing instructions stored in the memory 1102 and accessing data stored in the memory 1102. In some embodiments, the processor 1101 may include one or more processing units. The processor 1101 may integrate an application processor and a modem processor, wherein the application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1101. In some embodiments, the processor 1101 and the memory 1102 may be implemented on the same chip; in some embodiments, they may also be implemented on separate chips.

[0213] Processor 1101 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0214] Memory 1102, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 1102 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 1102 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 1102 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.

[0215] Based on the same technical concept, embodiments of the present invention also provide a computer-readable storage medium storing a computer-executable program, the computer-executable program being used to cause a computer to perform a method for configuring the resources of a database server as listed in any of the above methods.

[0216] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0217] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.

[0218] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.

[0219] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.

[0220] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A resource configuration method for a database server, characterized in that, include: In response to a master-slave switchover command for any first database system, the master resource configuration of the master database in the first database system is obtained; the master-slave switchover command is used to instruct the standby database of the first database system to replace the master database in providing services; the resource configuration is the number of CPU cores of the central processing unit configured for the database on the host server of the database. The backup resource configuration of the backup database in the first database system is updated to the primary resource configuration; the backup resource configuration is set to the minimum configuration when the backup database in the first database system has no service requirements; the shared resource configuration of the host server of the backup database in the first database system is greater than or equal to the primary resource configuration; the shared resource configuration is shared by each backup database deployed in the host server; The backup database of the first database system is updated to become the primary database of the first database system, so that the updated primary database provides services based on the updated primary resource configuration.

2. The method as described in claim 1, characterized in that, The backup resource configuration of the backup database of the first database system is set to the minimum configuration amount in the following ways: Based on the shared triggering behavior of the first database system, the account patterns of each account using the first database system are obtained; the shared triggering behavior is the user's application behavior to the first database system or the behavior of adding a new account in the first database system. Based on the account patterns, it is determined that the first database system does not have a service requirement for both the primary database and the backup database to provide services simultaneously. Set the backup resource configuration of the backup database of the first database system to the minimum configuration.

3. The method as described in claim 2, characterized in that, Set the backup resource configuration of the backup database of the first database system to the minimum configuration, including: Obtain the backup resource requirements of the first database system requested by the user; Select any database server and determine whether the shared resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then deploy the backup database of the first database system in the database server and set the backup resource configuration of the backup database of the first database system to the minimum configuration. If the remaining resource configuration of the database server is not greater than or equal to the backup resource requirement, then it is determined whether the remaining resource configuration of the database server is greater than or equal to the backup resource requirement. If it is greater than or equal to the backup resource requirement, then the backup database of the first database system is deployed in the database server, and the backup resource configuration of the backup database of the first database system is set to the minimum configuration. The shared resource configuration of the database server is updated to the backup resource requirement. If the remaining resource configuration is not greater than or equal to the backup resource requirement, then the backup database of the first database system is not deployed in the database server.

4. The method as described in claim 2, characterized in that, Also includes: If, based on the account patterns, it is determined that the first database system has a service requirement where both the primary and backup databases provide services simultaneously, then the backup resource configuration of the backup database in the first database system is set to the primary resource configuration.

5. The method as described in claim 2, characterized in that, Based on the account patterns, it was determined that the first database system does not have a service requirement where the primary and backup databases operate simultaneously, including: If there are no read-write separation and read-only backup database account modes in each account mode, then it is determined that the first database system does not have a service requirement for the primary database and backup database to provide services simultaneously.

6. The method as described in claim 1, characterized in that, After updating the backup database of the first database system to the primary database of the first database system, the process also includes: The initial primary database of the first database system is updated to a backup database, and the backup resource configuration of the updated backup database is updated to the minimum configuration.

7. The method as described in claim 1, characterized in that, After updating the backup database of the first database system to the primary database of the first database system, the process also includes: Update the initial primary database of the first database system to a backup database; The method further includes: Periodically retrieve multiple secondary database systems running on various servers; determine whether any backup database in any secondary database system has a backup resource configuration that is not at the minimum configuration level; If so, then for the second database system, obtain the account patterns of each account using the second database system; Based on the account patterns, it was determined that the second database system does not have a service requirement for both the primary and backup databases to provide services simultaneously. Set the backup resource configuration of the backup database in the second database system to the minimum configuration.

8. A resource configuration device for a database server, characterized in that, include: The acquisition unit is configured to acquire the primary resource configuration of the primary database in the first database system in response to a primary / standby switchover instruction for any first database system; the primary / standby switchover instruction is used to instruct the standby database of the first database system to replace the primary database in providing services; the resource configuration is the number of CPU cores configured for the central processing unit of the database's host server. Processing unit, used for: The backup resource configuration of the backup database in the first database system is updated to the primary resource configuration; the backup resource configuration is set to the minimum configuration when the backup database in the first database system has no service requirements; the shared resource configuration of the host server of the backup database in the first database system is greater than or equal to the primary resource configuration; the shared resource configuration is shared by each backup database deployed in the host server; The backup database of the first database system is updated to become the primary database of the first database system, so that the updated primary database provides services based on the updated primary resource configuration.

9. A computing device, characterized in that, include: Memory, used to store computer programs; A processor is configured to invoke a computer program stored in the memory and execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer-executable program for causing a computer to perform the method according to any one of claims 1 to 7.