CN115438021A - Resource allocation method and device for database server - Google Patents

Resource allocation method and device for database server Download PDF

Info

Publication number
CN115438021A
CN115438021A CN202210942469.1A CN202210942469A CN115438021A CN 115438021 A CN115438021 A CN 115438021A CN 202210942469 A CN202210942469 A CN 202210942469A CN 115438021 A CN115438021 A CN 115438021A
Authority
CN
China
Prior art keywords
database
standby
resource allocation
main
database system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210942469.1A
Other languages
Chinese (zh)
Inventor
梁克会
朱立宏
董龙
谢增强
洪华
施跃跃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Unionpay Co Ltd
Original Assignee
China Unionpay Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Unionpay Co Ltd filed Critical China Unionpay Co Ltd
Priority to CN202210942469.1A priority Critical patent/CN115438021A/en
Publication of CN115438021A publication Critical patent/CN115438021A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/211Schema design and management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating

Abstract

The embodiment of the invention relates to a resource allocation method and device of a database server. The method comprises the following steps: responding to a main/standby switching instruction for any first database system, and acquiring a main resource allocation amount of a main database in the first database system; updating the standby resource allocation quantity of the standby database in the first database system into a main resource allocation quantity; the configuration quantity of the equipment resources is set to be the lowest configuration quantity under the condition that the equipment database of the first database system has no service requirement; and updating the standby database of the first database system into a main database of the first database system so that the updated main database provides services based on the updated main resource allocation. When the standby database does not provide service, the standby database does not occupy server resources, so that more resources are saved for the host server of the standby database to deploy other main databases, and the resource utilization rate of the server is improved.

Description

Resource allocation method and device for database server
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a resource allocation method and device of a database server, a computing device and a computer readable storage medium.
Background
In order to improve the resource utilization of the database server, a scheme of deploying a plurality of databases on a single database server is adopted at present. The database cloud platform manages a plurality of database servers, a user applies for a database system with certain resources to the database cloud platform, and the database cloud platform distributes databases with corresponding resources of any database server to the user according to the application of the user. The database system is a general term for one or more databases applied by a user, for example, the database system may include only one database, or one master database and one slave database, or one master database and a plurality of slave databases. The standby database is used for guaranteeing data safety and service continuity, for example, when a database server where the main database is located breaks down, the standby database immediately takes over services on the main database, so that the unavailable time of the database system is shortened, and the high-availability requirement is met.
Fig. 1a shows a possible application scenario, in which a database cloud platform manages a plurality of database servers (such as database server 100, database server 200, and database server 300 shown in the figure), and for convenience of description, it is assumed that each database server has 48 cores of Central Processing Unit (CPU) resources. After evaluating the CPU resource required by the user A, the user A applies for a database system from a database cloud platform, wherein the database system comprises a main database with 8 cores of CPU resources and a standby database with 8 cores of CPU resources. When the database cloud platform determines that the database server 100 can meet the request of the CPU resource of 8 cores, a main database is deployed for the user A in the database server 100; when it is determined that database server 200 can satisfy the request of the CPU resource of 8 cores, a backup database is deployed for user a in database server 200 (in order to ensure high availability, the primary database and the backup database are not generally located in the same database server). And finishing the database system deployment applied by the user A. Fig. 1b illustrates a possible database deployment scenario of the database server 100, and for simplicity of description, it is assumed that the database server 100 has 48 cores of CPU resources, and each user applies for an 8-core database of CPU resources from the database cloud platform. The database server 100 deploys a main database with 8 cores as a CPU resource for the user A; a main database with 8 cores of CPU resources is deployed for a user B; a main database with 8 cores of CPU resources is deployed for a user C; a standby database with 8 cores of CPU resources is deployed for a user D; a standby database with 8 cores of CPU resources is deployed for a user E; generally, the database server reserves about 20% of resources for capacity expansion of each database, and therefore the CPU resources of the remaining 8 cores are not allocated any more.
However, the above method inevitably results in low resource utilization of the database server. The main body is as follows: 1. the user can not accurately estimate the actual resource use requirement, and in order to ensure that the database use requirement in the peak period can be met, when applying for a database system, the user tends to apply for a database system with a higher specification, so that the resource waste of a database server is caused. For example, for the user a, the user a can use the database of the CPU resources of 4 cores most of the time to meet the demand, and the user a needs the CPU resources of 8 cores in an extreme peak time, so the user a applies for the database of the CPU resources of 8 cores from the cloud database platform. 2. Most users have high requirements on data security and service continuity guarantee, and therefore, one or more standby databases are additionally applied. When the main database fails or other conditions occur, the standby database is switched to provide external services. In order to ensure that the capability provided by switching the backup database is not degraded, even if the backup database does not provide external services, the backup database needs to be configured with the same resources as the main database, thereby further causing resource waste of the database server. For example, in fig. 1b, only 3 main databases may currently provide external services in the database server 100, and the remaining 2 standby databases do not provide external services, but still occupy a considerable amount of CPU resources.
Disclosure of Invention
The embodiment of the invention provides a resource allocation method of a database server, which is used for improving the resource utilization rate of the database server.
In a first aspect, an embodiment of the present invention provides a resource allocation method for a database server, including:
responding to a main/standby switching instruction aiming at any first database system, and acquiring the main resource allocation quantity of a main database in the first database system; the main/standby switching instruction is used for indicating a standby database of the first database system to replace a main database to provide service; the resource allocation amount is the amount of a Central Processing Unit (CPU) allocated to the database by a host server of the database;
updating the standby resource allocation quantity of the standby database in the first database system to the main resource allocation quantity; the configuration quantity of the equipment resources is set to be the lowest configuration quantity under the condition that the equipment database of the first database system has no service requirement; the shared resource allocation amount of a host server of a standby database of the first database system is greater than or equal to the main resource allocation amount; the shared resource allocation amount is shared by all backup databases deployed in the host server;
and updating the standby database of the first database system into a main database of the first database system so that the updated main database provides services based on the updated main resource allocation amount.
When the standby database in the first database system has no service requirement, setting the standby resource configuration quantity of the standby database as the lowest configuration quantity, and providing service only through the main resource configuration quantity of the main database; when the first database system needs to perform the main-standby switching, the standby resource allocation quantity of the standby database is updated to the main resource allocation quantity, so that the updated main database can provide services based on the updated main resource allocation quantity. In the scheme, the standby database does not occupy server resources when not providing services, so that more resources are saved for the host server of the standby database to deploy other main databases, and the resource utilization rate of the server is improved. Compared with methods such as a prediction method and a monitoring method, the method provided by the embodiment of the invention does not perform dynamic capacity expansion on the main database which is in service and the standby database which is not in service at the same time. And the resource configuration of the standby database is set to the minimum configuration quantity without any change of the resource configuration of the serving main database. And only after receiving the main/standby switching instruction, setting the standby resource allocation quantity of the standby database to be the same as the main resource allocation quantity of the main database. The main database provides services based on the main resource allocation quantity, and the main resource allocation quantity is enough for supporting the service operation according to the service requirement of the user, so that dynamic expansion and contraction are not needed, extreme conditions such as service sudden increase and the like can be met, the problems of inaccuracy and hysteresis caused by dynamic expansion and contraction are avoided, various types of use scenes can be met, and the applicability is high. The spare resource allocation amount of the spare database is saved for improving the resource utilization rate of the server, and the angle of improving the resource utilization rate by methods such as a prediction method and a monitoring method is different.
In some embodiments, the setting the standby resource configuration amount of the standby database of the first database system to the minimum configuration amount by the following method includes:
acquiring an account mode of each account using the first database system based on the sharing triggering behavior aiming at the first database system; the sharing triggering behavior is an application behavior of a user to the first database system or a newly added account behavior of the first database system;
determining that the first database system does not have service requirements for simultaneously providing services for a main database and a standby database according to each account mode;
and setting the standby resource configuration quantity of the standby database of the first database system as the lowest configuration quantity.
When a user newly applies for a first database system or when an account is newly added to the first database system, the account mode of each account using the first database system is obtained, and the first database system is determined to have no service requirement that a main database and a standby database simultaneously carry out service according to each account mode, so that the standby resource allocation amount of the standby database can be set as the minimum allocation amount. In this way, the judgment is carried out through the account mode, and the problem that the standby resource allocation amount of the standby database is set to be the lowest allocation amount in the case that the main database and the standby database are required to be simultaneously served is prevented from occurring.
In some embodiments, setting the standby resource configuration amount of the standby database of the first database system to a minimum configuration amount includes:
acquiring the standby resource demand of the first database system applied by a user;
selecting any database server, judging whether the shared resource allocation amount of the database server is greater than or equal to the standby resource demand amount, if so, deploying the standby database of the first database system in the database server, and setting the standby resource allocation amount of the standby database of the first database system as the lowest allocation amount;
if the spare resource demand is not more than or equal to the spare resource demand, judging whether the residual resource allocation quantity of the database server is more than or equal to the spare resource demand, if the residual resource allocation quantity of the database server is more than or equal to the spare resource demand, deploying the spare database of the first database system in the database server, setting the spare resource allocation quantity of the spare database of the first database system as the lowest allocation quantity, and updating the shared resource allocation quantity of the database server to the spare resource demand; and if the standby resource demand is not more than or equal to the standby resource demand, not deploying the standby database of the first database system in the database server.
In some embodiments, further comprising:
and if the first database system is determined to have service requirements for simultaneously performing service on the main database and the standby database according to the account modes, setting the standby resource allocation amount of the standby database of the first database system as the main resource allocation amount.
Various possible scenes are fully considered, and the applicability is stronger.
In some embodiments, determining that the first database system does not have a service requirement for simultaneous service of the primary database and the backup database according to each account mode includes:
and if the account modes of read-write separation and read-only standby database do not exist in the account modes, determining that the first database system does not have the service requirement that the main database and the standby database simultaneously perform service.
In some embodiments, after updating the standby database of the first database system to the primary database of the first database system, the method further comprises:
and updating the initial main database of the first database system into a standby database, and updating the standby resource allocation amount of the updated standby database into the lowest allocation amount.
In order to perform the main-standby switching quickly, it is set that the original main database is updated to the standby database after the main-standby switching, and the standby resource allocation amount of the updated standby database is updated to the lowest allocation amount. Therefore, the standby resource configuration quantity of the standby database without service requirements is automatically set to be the lowest configuration quantity, and server resources are occupied as little as possible. And the utilization rate of server resources is improved.
In some embodiments, after updating the standby database of the first database system to the primary database of the first database system, the method further comprises:
updating an initial main database of the first database system into a standby database;
the method further comprises the following steps:
periodically acquiring a plurality of second database systems running in each server; judging whether the standby resource allocation amount of any standby database in any second database system is not the lowest allocation amount;
if yes, acquiring an account mode of each account using the second database system aiming at the second database system;
determining that the second database system does not have the service requirement that the main database and the standby database simultaneously carry out service according to each account mode;
and setting the standby resource configuration quantity of the standby database of the second database system as the lowest configuration quantity.
In order to perform the active-standby switching quickly, the standby resource allocation of the standby database is only updated to the main resource allocation before the active-standby switching. And after the main database and the standby database are switched, updating the initial main database of the database system into the standby database. In order to set the resource allocation amount of each backup database as the lowest allocation amount in time, a plurality of second database systems running in each server are periodically acquired, any second database system is checked, and if the service requirement that the main database and the backup database simultaneously perform service does not exist, the backup resource allocation amount of the backup database of the second database system is set as the lowest allocation amount. Therefore, the resource allocation quantity of the standby database is set to be the lowest allocation quantity without updating each initial main database to the standby database, and the resource allocation quantity is discovered periodically, updated uniformly and simpler. The unified updating of the standby resource allocation quantity of the standby databases of the second database systems is realized.
In a second aspect, an embodiment of the present invention further provides a resource allocation apparatus for a database server, including:
the system comprises an acquisition unit, a switching unit and a switching unit, wherein the acquisition unit is used for responding to a main-standby switching instruction aiming at any first database system and acquiring the main resource allocation quantity of a main database in the first database system; the main/standby switching instruction is used for indicating a standby database of the first database system to replace a main database to provide service; the resource allocation amount is the amount of a Central Processing Unit (CPU) allocated to the database by a host server of the database;
a processing unit to:
updating the standby resource allocation quantity of the standby database in the first database system to the main resource allocation quantity; the configuration quantity of the equipment resources is set to be the lowest configuration quantity under the condition that the equipment database of the first database system has no service requirement; the shared resource allocation amount of a host server of a standby database of the first database system is greater than or equal to the main resource allocation amount; the shared resource allocation amount is shared by all backup databases deployed in the host server;
and updating the standby database of the first database system into a main database of the first database system so that the updated main database provides services based on the updated main resource allocation amount.
In some embodiments, the processing unit is specifically configured to:
acquiring an account mode of each account using the first database system based on the sharing triggering behavior aiming at the first database system; the sharing triggering behavior is an application behavior of a user to the first database system or a newly added account behavior of the first database system;
determining that the first database system does not have service requirements for simultaneously providing services for a main database and a standby database according to each account mode;
and setting the standby resource configuration quantity of the standby database of the first database system as the lowest configuration quantity.
In some embodiments, the processing unit is specifically configured to:
acquiring the standby resource demand of the first database system applied by a user;
selecting any database server, judging whether the shared resource allocation amount of the database server is greater than or equal to the standby resource demand amount, if so, deploying the standby database of the first database system in the database server, and setting the standby resource allocation amount of the standby database of the first database system as the lowest allocation amount;
if the spare resource demand is not more than or equal to the spare resource demand, judging whether the residual resource allocation quantity of the database server is more than or equal to the spare resource demand, if the residual resource allocation quantity of the database server is more than or equal to the spare resource demand, deploying the spare database of the first database system in the database server, setting the spare resource allocation quantity of the spare database of the first database system as the lowest allocation quantity, and updating the shared resource allocation quantity of the database server to the spare resource demand; and if the standby resource demand is not more than or equal to the standby resource demand, not deploying the standby database of the first database system in the database server.
In some embodiments, the processing unit is further to:
and if the first database system is determined to have service requirements that the main database and the standby database simultaneously carry out service according to each account mode, setting the standby resource allocation amount of the standby database of the first database system as the main resource allocation amount.
In some embodiments, the processing unit is specifically configured to:
and if the account modes of read-write separation and read-only standby database do not exist in the account modes, determining that the first database system does not have the service requirement that the main database and the standby database simultaneously perform service.
In some embodiments, the processing unit is further to:
and updating the initial main database of the first database system into a standby database, and updating the standby resource allocation amount of the updated standby database into the lowest allocation amount.
In some embodiments, the processing unit is further to:
updating an initial main database of the first database system into a standby database;
periodically acquiring a plurality of second database systems running on each server; judging whether the standby resource allocation quantity of any standby database in any second database system is not the lowest allocation quantity;
if yes, acquiring an account mode of each account using the second database system aiming at the second database system;
determining that the second database system does not have service requirements for simultaneously serving the main database and the standby database according to each account mode;
and setting the standby resource configuration quantity of the standby database of the second database system as the lowest configuration quantity.
In a third aspect, an embodiment of the present invention further provides a computing device, including:
a memory for storing a computer program;
and the processor is used for calling the computer program stored in the memory and executing the resource allocation method of the database server listed in any mode according to the obtained program.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where a computer-executable program is stored, where the computer-executable program is configured to enable a computer to execute a resource allocation method of a database server listed in any one of the above manners.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1a is a possible application scenario provided by an embodiment of the present invention;
fig. 1b is a database deployment scenario of a possible database server 100 according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a resource allocation method of a database server according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a possible deployment approach provided by an embodiment of the present invention;
fig. 4 is a schematic diagram of an amount of configured used resources, an amount of configured shared resources, and an amount of configured remaining resources of a possible database server according to an embodiment of the present invention;
fig. 5a is a schematic diagram of a database server that is not deployed by the method provided by the embodiment of the present invention;
fig. 5b is a schematic diagram of a database server deployed by using the method provided by the embodiment of the present invention;
fig. 6 is a flowchart illustrating a resource allocation method of a database server according to an embodiment of the present invention;
fig. 7 is a schematic diagram illustrating an execution flow of a sharing unit according to an embodiment of the present invention;
fig. 8 is a schematic diagram illustrating an execution flow of a number reconfiguration unit according to an embodiment of the present invention;
FIG. 9 is a flowchart illustrating an exemplary implementation of a periodic checking unit according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a resource allocation apparatus of a database server according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
To make the objects, embodiments and advantages of the present application clearer, the following description of exemplary embodiments of the present application will clearly and completely describe the exemplary embodiments of the present application with reference to the accompanying drawings in the exemplary embodiments of the present application, and it is to be understood that the described exemplary embodiments are only a part of the embodiments of the present application, and not all of the embodiments.
All other embodiments, which can be derived by a person skilled in the art from the exemplary embodiments described herein without inventive step, are intended to be within the scope of the claims appended hereto. In addition, while the disclosure herein has been presented in terms of one or more exemplary examples, it should be appreciated that aspects of the disclosure may be implemented solely as a complete embodiment.
It should be noted that the brief descriptions of the terms in the present application are only for convenience of understanding of the embodiments described below, and are not intended to limit the embodiments of the present application. These terms should be understood in their ordinary and customary meaning unless otherwise indicated.
The terms "first," "second," "third," and the like in the description and claims of this application and in the above-described drawings are used for distinguishing between similar or analogous objects or entities and are not necessarily intended to limit the order or sequence of any particular one, unless otherwise indicated. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein.
Furthermore, the terms "comprises" and "comprising," as well as any variations thereof, are intended to cover a non-exclusive inclusion, such that a product or device that comprises a list of elements is not necessarily limited to those elements explicitly listed, but may include other elements not expressly listed or inherent to such product or device.
The embodiment of the invention provides the following two resource allocation methods for a database server, which are used for improving the resource utilization rate of the database server.
Mode 1, prediction method: the use requirements of the database resources in the future time period of any user are predicted by learning the historical use rule of the database resources of the user, and the database resources of the user are dynamically expanded and contracted according to the prediction result. For example, it is predicted that the CPU resource usage requirement of user a in the next hour is 4 cores, and therefore, the CPU resource of the primary database allocated to user a in database server 100 is adjusted to 4 cores in the next hour, and the CPU resource of the secondary database allocated to user a in database server 200 is also adjusted to 4 cores.
Mode 2, monitoring method: the monitoring indexes of each database of any database server in the current time period are collected, the monitoring indexes of each database are compared with the monitoring indexes of the databases of other database servers in the same service type, and whether the resources of each database of the database server are dynamically expanded and shrunk in the next time period is determined according to the comparison result. For example, the CPU resource of the primary database allocated to user a in database server 100 in the next time period is adjusted to 4 cores according to the comparison result of the current time period, and the CPU resource of the backup database allocated to user a in database server 200 in the next time period is also adjusted to 4 cores.
The dynamic capacity expansion and reduction by adopting the prediction method has the defect that the accuracy of prediction is difficult to ensure. Especially in the scenes that marketing activities, killing every second and the like randomly occur and a large amount of resources are needed in a short time, the resource requirements are difficult to be correctly predicted according to the rule by the prediction method, and capacity expansion in advance cannot be realized. The dynamic scaling using the monitoring method has the disadvantage of poor real-time performance. The method comprises the following steps of setting up a capacity expansion and contraction scheme of the next time period by collecting monitoring indexes of the current time period, wherein hysteresis easily occurs; and cannot satisfy scenes that occur randomly and require a large amount of resources for a short time.
In summary, the above two methods have the disadvantage that the resource expansion and contraction is not timely or accurate, which results in the failure to meet the user requirement, and can only be applied in some specific service scenarios, for example, scenarios where the user requirement for resources is relatively stable.
The embodiment of the invention provides another resource allocation method for a database server, which is used for dynamically expanding and contracting only a standby database instead of a main database and the standby database at the same time. And the dynamic expansion and contraction capacity of the database is not predicted or monitored based on the resource use requirements of the users, so that the problem that the resource expansion and contraction capacity is not timely or inaccurate does not exist, the resource utilization rate of the database server is improved, various types of use scenes can be met, and the applicability is high.
Fig. 2 shows a resource allocation method of a database server according to an embodiment of the present invention, where the method is used to set a standby resource allocation amount of a standby database in a database system applied by a user to a minimum allocation amount. The method comprises the following steps:
step 201, acquiring an account mode of each account using the first database system based on a sharing trigger action aiming at the first database system; the sharing triggering behavior is an application behavior of a user to the first database system or a newly added account behavior of the first database system.
Step 202, determining that the first database system does not have service requirements for simultaneously providing services for the main database and the standby database according to each account mode.
Step 203, setting the standby resource configuration amount of the standby database of the first database system as the lowest configuration amount.
In step 201, a user applies for a database system from a database cloud platform, where the database system may include only one master database, one master database and one standby database, or one master database and multiple standby databases, which is not limited herein. If the database system does not comprise the standby database, the condition that the standby resource allocation amount of the standby database is set to be the lowest allocation amount does not exist, and the main resource allocation amount of the main database is directly set according to the requirements of users. Thus, the first database system of the embodiments of the present invention is directed to a database system that includes one or more standby databases.
According to a possible scenario, after a user applies for a first database system to a database cloud platform, the database cloud platform obtains account modes of accounts using the first database system. The account refers to an account which is inquired, modified and the like by using the first database system at a later time, so that the account can be one or more.
For example, a user a applies for a first database system including a main database with a CPU resource of 8 cores and a standby database with a CPU resource of 8 cores from a database cloud platform; and the database cloud platform acquires the account mode of each account corresponding to the first database system. Here, the account mode of each account may be submitted by the user a when applying for the first database system, may be actively called by the database cloud platform, or may be in other manners. And are not intended to be limiting herein.
In another possible scenario, the user has applied for a first database system and has one or more accounts using the first database system. When a newly added account uses the first database system, the database cloud platform also obtains an account mode of each account using the first database system, wherein the account mode of each account comprises an account mode of the newly added account.
For example, user a has applied for a first database system in which a primary database is deployed at database server 100 and a backup database is deployed at database server 200. The first database system is already in use by account zhangsan, account lisi. When a new account wangwu exists, the database cloud platform also obtains the account mode of each account using the first database system, that is, obtains the account modes of the account zhangsan, the account lisi, and the account wangwu.
In step 202, it is determined that the first database system does not have a service requirement that the primary database and the backup database provide services at the same time according to each account mode.
In each account using the first database system, there may be a service demand that requires the primary database and the secondary database to provide services simultaneously, and the account mode of each account may be used for determination. For example, if it is determined that a read-write separation mode and/or a read-only slave mode exist in each account mode, it indicates that the first database system has a service requirement that the master database and the slave database perform services simultaneously, and the spare resource allocation amount of the slave database of the first database system cannot be the minimum allocation amount, but should be consistent with the master resource allocation amount of the master database.
For example, the main resource allocation amount of the main database is determined to be 8 cores, and the standby resource allocation amount of the standby database is also determined to be 8 cores.
If it is determined that the read-write separation mode and the read-only slave mode do not exist in each account mode, the standby resource configuration amount of the standby database of the first database system can be the lowest configuration amount, and the normal service of the first database system is not affected by setting the standby resource configuration amount as the lowest configuration amount.
In step 203, the standby resource configuration amount of the standby database of the first database system is set as the lowest configuration amount.
One possible scenario is that a backup database has not been deployed in any of the database servers prior to step 203. Therefore, when the first database system is determined to have no service requirement that the main database and the standby database provide services at the same time, the standby database is deployed in any database server. Fig. 3 shows one possible deployment, comprising the following steps:
step 301, obtaining the standby resource demand of the first database system applied by the user.
For example, a user applies for a primary database with CPU resources of 8 cores and a secondary database with CPU resources of 8 cores. The database cloud platform acquires that the standby resource demand applied by the user is 8 cores.
Step 302, selecting any database server, determining whether the shared resource allocation amount of the database server is greater than or equal to the standby resource demand amount, if so, deploying the standby database of the first database system in the database server, and setting the standby resource allocation amount of the standby database of the first database system as the lowest allocation amount.
Setting two parts of used resource allocation quantity and shared resource allocation quantity for the resource of any database server, wherein the used resource allocation quantity is the sum of the resource allocation quantities distributed to the main database; the shared resource allocation amount is an amount of resources prepared for each backup database, and is used for sharing each backup database. The configuration amount of the shared resources can be fixed or dynamically adjusted. For example, if the database server 100 shares a CPU resource of 48 cores, and there are 24 cores of CPU resources allocated to the master databases, and each master database is configured with 8 cores, the used resource allocation amount of the database server 100 is 24 cores. If the shared resource configuration amount is 10 fixed cores, the standby databases deployed in the database server 100 share the CPU resources of the 10 cores, where the standby resource configuration amount of any one of the standby databases is not greater than 10 cores. When a main database with 8 cores of 2 CPU resource requirements is deployed on the database server 100 and a main database with 10 cores of 1 CPU resource requirement is deployed on the database server 100, the used resource allocation amount is 32 cores, and the shared resource allocation amount is still 10 cores. The current database server 100 may further accept a plurality of standby databases deployed thereon, as long as the standby databases have corresponding standby resource demand amounts not greater than 10 cores.
If the allocation amount of the shared resource is dynamically adjusted, the following adjustment method may be used: for example, the database server 100 shares a CPU resource of 48 cores, where the CPU resource of 24 cores is allocated to the master databases, and each master database is configured with 8 cores, then the used resource configuration amount of the database server 100 is 24 cores, and the shared resource configuration amount is 0 core. When the backup database a is deployed on the database server 100, and the corresponding backup resource demand of the backup database a applied by the user is 8 cores, the shared resource allocation amount is 8 cores. When the backup database b is deployed on the database server 100, and the backup resource demand amount corresponding to the backup database b applied by the user is 10 cores, the shared resource allocation amount is updated to be 10 cores. When the master database c is deployed on the database server 100, and the corresponding master resource demand of the master database c applied by the user is 14 cores, the used resource allocation amount is 38 cores.
For example, when the standby resource demand of the first database system is received as 8 cores, the database server 100 is selected, whether the shared resource allocation amount of the database server 100 is greater than or equal to 8 cores of the standby resource demand is judged, if the shared resource allocation amount of the database server 100 is greater than or equal to 8 cores of the standby resource demand, the standby database of the first database system is deployed in the database server 100, and the standby resource allocation amount of the standby database of the first database system is set as the lowest allocation amount. The minimum configuration amount here may be a configuration amount that can satisfy the minimum requirement, such as 0 core, 1 core, and the like. That is, the shared configuration amount is not really provided to the standby database completely.
Step 303, if not greater than or equal to the standby resource demand, determining whether the remaining resource allocation amount of the database server is greater than or equal to the standby resource demand, if so, deploying the standby database of the first database system in the database server, setting the standby resource allocation amount of the standby database of the first database system as the lowest allocation amount, and updating the shared resource allocation amount of the database server to the standby resource demand; and if the standby resource demand is not more than or equal to the standby resource demand, not deploying the standby database of the first database system in the database server.
The residual configuration quantity is the configuration quantity left after the used configuration quantity is subtracted from the total resource configuration quantity of the database server.
For example, if the shared resource allocation amount of the database server is 8 cores, the standby resource allocation amount is 10 cores, and the shared resource allocation amount is not greater than or equal to the standby resource allocation amount, it is determined whether the remaining resource allocation amount is greater than or equal to the standby resource allocation amount, and if the remaining resource allocation amount is 10 cores, the condition that the remaining resource allocation amount is greater than or equal to the standby resource allocation amount is satisfied, so that the standby database is still deployed in the database server, the standby resource allocation amount of the standby database is set to the lowest allocation amount, for example, 0 core, and the shared resource allocation amount of the database server is updated to 10 cores.
Fig. 4 shows a schematic diagram of the used resource configuration amount, the shared resource configuration amount, and the remaining resource configuration amount of a possible database server. The standby resource allocation amounts of the two standby databases are both 0 core, and the two standby databases share the shared resource allocation amount of 8 cores.
In another possible case of step 203, the primary database and the backup database of the first database system are already deployed in the database server according to respective resource requirements before step 203. For example, a user applies for a first database system including a main database of CPU resources of 8 cores and a standby database of CPU resources of 8 cores, the database cloud platform deploys the main database on the database server 100, allocates the CPU resources of 8 cores for the main database, deploys the standby database on the database server 200, and allocates the CPU resources of 8 cores for the standby database. The configuration mode does not need to change the code logic of the original deployment database, when an application request of a database system of a user is received, aiming at the main database, only the residual resource configuration quantity of any database server needs to be compared with the main resource demand quantity of the main database, and if the residual resource configuration quantity is more than or equal to the main resource demand quantity of the main database, the main database is deployed in the database server; and if the main resource demand is not more than or equal to the main resource demand of the main database, replacing the next database server for judgment until the main database is deployed in a certain database server. Aiming at the standby database, comparing the residual resource allocation amount of any database server with the standby resource demand amount of the standby database, and if the residual resource allocation amount is more than or equal to the standby resource demand amount of the standby database, deploying the standby database in the database server; and if the standby resource demand is not more than or equal to that of the standby database, replacing the next database server for judgment until the standby database is deployed in a certain database server.
After the deployment, the database cloud platform acquires the standby resource configuration quantity of the standby database again, and changes the standby resource configuration quantity to the lowest configuration quantity.
For example, the spare resource configuration amount of 8 cores is changed to the lowest configuration amount of 0 core.
The original deployment logic does not need to be changed in the mode, and the resource demand quantity does not need to be compared with the shared resource quantity and the residual resource quantity. When the standby database is deployed according to the standby resource demand, the deployed database server can be ensured to support the resource demand of the standby database when the standby database is switched later. For example, during active-standby switching, the standby resource allocation amount of the standby database is updated from 0 to 8 cores, and the remaining resource allocation amount of the host server of the standby database can meet such updating.
FIG. 5a illustrates a database server that is not deployed using the methods provided by embodiments of the invention; fig. 5b shows a database server deployed by using the method provided by the embodiment of the present invention. As shown in the figure, when the method provided by the embodiment of the present invention is not used, only 5 databases may be deployed in the database server, because each standby database also needs to allocate 8 cores of CPU resources to the standby database, even if the standby database does not provide external services. After the method provided by the embodiment of the invention is adopted, each database shares the CPU resource of 8 cores, and more than 5 databases, for example, 9 databases illustrated in the figure, can be deployed in the database server. The number of databases deployed in the database server is increased, and the resource utilization rate of the database server is further increased.
In the above deployment mode, the multiple backup databases share the remaining unallocated CPU resources of the database server, for example, the CPU resources of 8 cores are shared in fig. 5 b. Although the resource isolation between the standby databases is poor, the standby databases do not provide services to the outside, and the main database of the database system provides the services to the outside, so the normal operation of the database system is not affected by the poor resource isolation.
In the technical scheme, when a user newly applies for a first database system or when an account is newly added to the first database system, the account mode of each account using the first database system is obtained, and the first database system is determined to have no service requirement that a main database and a standby database simultaneously carry out service according to each account mode, so that the standby resource allocation amount of the standby database can be set as the minimum allocation amount. In this way, the judgment is carried out through the account mode, and the problem that the standby resource allocation amount of the standby database is set to be the lowest allocation amount in the case that the main database and the standby database are required to be simultaneously served is prevented from occurring. If the first database system needs the main database and the standby database to perform service simultaneously, and the standby resource allocation amount of the standby database is set as the minimum allocation amount, the first database service cannot provide the service required by the user to the outside.
In some embodiments, for any database server, the databases are deployed in containers. Container (DOCKER) is a virtualization technology, and is a lightweight virtualization solution based on process containers. Unlike Virtual Machine (VM) technology, container technology implements lightweight virtualization by isolating resources and processes, with performance losses that can be almost negligible. Each database is deployed in a separate container on the database server and the container is configured with a dedicated IP address, CPU and memory and a separate file system as table space and log space.
After the deployment, the resource allocation amount of the backup database is the lowest allocation amount. The following describes how to recover the resource allocation of the backup database.
Fig. 6 shows a resource allocation method of a database server according to an embodiment of the present invention, including:
601, responding to a master-slave switching instruction for any first database system, and acquiring a master resource allocation amount of a master database in the first database system; the master-slave switching instruction is used for indicating a master database of the first database system to replace a master database to provide service; the resource allocation amount is the amount of a Central Processing Unit (CPU) allocated to the database by a host server of the database;
step 602, updating the standby resource allocation amount of the standby database in the first database system to the main resource allocation amount; the configuration quantity of the equipment resources is set to be the lowest configuration quantity under the condition that the equipment database of the first database system has no service requirement; the shared resource allocation amount of a host server of a standby database of the first database system is greater than or equal to the main resource allocation amount; the shared resource allocation amount is shared by all backup databases deployed in the host server;
step 603, updating the standby database of the first database system to the main database of the first database system, so that the updated main database provides services based on the updated main resource allocation.
In step 601, the primary database of the first database system needs to be switched to the standby database for some reason. The reason for switching between the main and standby databases may be that a host server of the main database fails, or an operation and maintenance person needs to switch according to a test requirement. The embodiments of the present invention are not limited in this regard.
After receiving the main/standby switching instruction, the database cloud platform acquires the main resource allocation amount of a main database in the first database system. For example, the configuration amount of the main resource acquired by the database cloud platform to the main database is 6 cores.
In step 602, the host server of the standby database of the first database system is obtained, and the standby resource allocation amount of the standby database in the host server is updated to the main resource allocation amount, for example, from 0 core to 6 cores.
One or more standby databases are deployed in the host server, each standby database shares a part of resource allocation amount, and the shared resource allocation amount is larger than or equal to the main resource allocation amount. As shown in fig. 5b, 4 standby databases share CPU resources of 8 cores in the database server 100.
In step 603, the standby database of the first database system is updated to the master database of the first database system, and then the updated master database can provide services based on the updated master resource allocation.
When the standby database in the first database system has no service requirement, setting the standby resource configuration quantity of the standby database as the lowest configuration quantity, and providing service only through the main resource configuration quantity of the main database; when the first database system needs to perform the main-standby switching, the standby resource allocation quantity of the standby database is updated to the main resource allocation quantity, so that the updated main database can provide services based on the updated main resource allocation quantity. In the scheme, when the standby database does not provide service, the standby database does not occupy server resources, so that more resources are saved for deploying other main databases for the host server of the standby database, and the resource utilization rate of the server is improved. Compared with methods such as a prediction method and a monitoring method, the method provided by the embodiment of the invention does not perform dynamic expansion and capacity on the main database which is in service and the standby database which is not in service at the same time. And the resource configuration of the standby database is set to the minimum configuration quantity without any change of the resource configuration of the serving main database. And only after receiving the main/standby switching instruction, setting the standby resource allocation quantity of the standby database to be the same as the main resource allocation quantity of the main database. The main database provides services based on the main resource allocation quantity, and the main resource allocation quantity is enough to support the operation of the service according to the service requirement of the user, so that dynamic expansion and contraction are not needed, extreme conditions such as sudden service increase and the like can be met, the problems of inaccuracy and hysteresis caused by dynamic expansion and contraction are avoided, various types of use scenes can be met, and the applicability is high.
When a user applies for a database system, the user applies for the database system according to the maximum requirements of the user, for example, only 1 hour of the CPU with 8 cores is needed in one day, and the rest 23 hours of the CPU with 4 cores are needed, so that the user applies for a main database with 8 cores and a standby database with 8 cores. The method provided by the embodiment of the invention does not dynamically expand and contract the resource allocation quantity of the main database, and always adopts the CPU with 8 cores to provide services, so that the method can support business operation. There are no inaccuracy and hysteresis problems caused by dynamic scaling. The dynamic capacity expansion and reduction is only carried out on the resource allocation quantity of the standby database, the dynamic capacity expansion and reduction is carried out based on the switching of the main database and the standby database, and the dynamic capacity expansion and reduction is different from the scenes and methods of dynamic capacity expansion and reduction by methods such as a prediction method, a monitoring method and the like, so that the problem solving angle is different.
In some embodiments, after updating the standby database of the first database system to the primary database of the first database system, the method further includes: and updating the initial main database of the first database system into a standby database, and updating the standby resource allocation amount of the updated standby database into the lowest allocation amount.
In order to perform the main-standby switching quickly, it is set that the original main database is updated to the standby database after the main-standby switching, and the standby resource allocation amount of the updated standby database is updated to the lowest allocation amount. Therefore, the standby resource configuration quantity of the standby database without service requirements is automatically set to be the lowest configuration quantity, and server resources are occupied as little as possible. And the utilization rate of server resources is improved.
In some embodiments, after the initial primary database of the first database system is updated to the standby database, the standby resource allocation amount of the updated standby database is not directly updated to the minimum allocation amount. But the spare database which is not set as the lowest configuration quantity is checked in a periodic checking mode and is set as the lowest configuration quantity.
Specifically, a plurality of second database systems running in each server are periodically acquired; judging whether the standby resource allocation amount of any standby database in any second database system is not the lowest allocation amount; if yes, acquiring an account mode of each account using the second database system aiming at the second database system; determining that the second database system does not have service requirements for simultaneously serving the main database and the standby database according to each account mode; and setting the standby resource configuration quantity of the standby database of the second database system as the lowest configuration quantity.
In order to perform the active-standby switching quickly, the standby resource allocation of the standby database is only updated to the main resource allocation before the active-standby switching. And after the main database and the standby database are switched, updating the initial main database of the database system into the standby database. In order to set the resource allocation amount of each backup database as the lowest allocation amount in time, a plurality of second database systems running in each server are periodically acquired, any second database system is checked, and if the service requirement that the main database and the backup database simultaneously perform service does not exist, the backup resource allocation amount of the backup database of the second database system is set as the lowest allocation amount. Therefore, the resource allocation quantity of the standby database is set to be the lowest allocation quantity without updating each initial main database to the standby database, and the resource allocation quantity is discovered periodically, updated uniformly and simpler. The unified updating of the standby resource allocation quantity of the standby databases of the second database systems is realized.
Before the main-standby switching, the configuration quantity of the standby resources of the standby database is changed, the consumed time is in the millisecond level, and the influence on the externally provided service by the database system can be almost ignored.
Because the number of the servers managed by the database cloud platform is huge, the possibility that a plurality of standby databases are switched to the main database in any database server is low. For example, in fig. 5b, the primary databases corresponding to the respective backup databases are likely to be distributed on other different database servers, and the database servers are less likely to fail at the same time. If the faults happen at the same time, the standby databases are switched into main databases, and the main databases share the CPU resources of 8 cores to provide services for the outside. Thus sacrificing some resource isolation.
Therefore, in some embodiments, the number of the standby databases participating in sharing in any database server may be limited, that is, the number of the standby databases participating in sharing in any database server is greater than the first threshold and less than the second threshold, for example, greater than 2 and less than 5. The first threshold is set to improve resource utilization of the server, and the second threshold is set to reduce the probability of sacrificing resource isolation.
In order to better explain the embodiment of the present invention, the following describes a method for resource allocation of the above database server in a specific implementation scenario.
The embodiment of the invention is characterized in that a sharing unit, a reconfiguration unit and a periodic check unit are arranged in a database cloud platform.
The sharing unit may be triggered based on 3 scenarios: 1. when a user applies for a database system, the sharing unit acquires the database system; 2. if a new account exists in the database system, the sharing unit acquires the database system; 3. and the periodic checking unit checks that the standby database which is not set as the lowest configuration quantity exists, and the sharing unit acquires the database system corresponding to the standby database.
The following describes an execution flow of the sharing unit, as shown in fig. 7, including:
step 701, receiving a first database system, and determining whether a database server in which each standby database of the first database system is located allows a behavior of setting the standby resource allocation amount of the standby database to be the lowest allocation amount.
The first database system is the database system acquired after any scene in the above 3 scenes is triggered.
If not, recording the information in the log, and ending the flow.
Since there are some services, such as transaction processing, which have high requirements on processing speed, the standby databases corresponding to these services may be deployed in a specific database server, and the specific database server does not allow setting the standby resource configuration amount of any standby database deployed thereon to be the minimum configuration amount, because if so, the minimum configuration amount needs to be restored to the main resource configuration amount during the active-standby switching, and a delay of several milliseconds is also not allowed.
Step 702, acquiring deployment architecture information of a first database system.
The deployment architecture information comprises the name, the number of CPUs (central processing units), the number of memories, IP (Internet protocol) addresses, ports, states, roles and related information of the database server contained in the first database system. For example, the first database system includes 3 databases, and names, numbers of CPUs, memory numbers, IP addresses, ports, states, roles, and database servers where the 3 databases are located.
Step 703, the role of the database is parsed.
A primary database and a secondary database contained in a first database system are determined. For example, it is determined that the first database system includes a primary database and 2 secondary databases.
Step 704, obtaining the CPU resource allocation of the master database.
Step 705, account information using a first database system is obtained.
And calling a database user query interface provided by the platform to acquire account information configured in the first database service, wherein the account information comprises an account name, an account mode, a black and white list, a connection number and authority information.
Step 706, analyzing each account mode of the first database system, and judging whether there is an account mode of read-write separation and read-only slave.
The two modes are that SQL requests of partial queries are routed to the standby database, so that query pressure on the main database is reduced, and a service scene with less writing and more reading is satisfied. In this scenario, like the master database, the backup database also directly provides services to the outside, only provides query services, and does not provide data writing, updating, and deleting services.
And step 707, setting the standby resource allocation amount of each standby database as the lowest allocation amount.
Specifically, for any backup database, a command with the backup resource configuration amount set to the minimum configuration amount is executed on the host server of the backup database.
Step 708, the configuration quantity of the standby resources of each standby database is set to be the same as the configuration quantity of the main resources.
Specifically, for any backup database, a command that the backup resource configuration amount is set to be the same as the main resource configuration amount is executed on the host server of the backup database.
And if any step fails to be executed, recording the abnormal condition into a log for a manager to check.
The following describes an execution flow of the reconfiguration unit, as shown in fig. 8, including:
step 801, in response to the main/standby switching instruction for the first database system, acquiring deployment architecture information of the first database system.
The deployment architecture information comprises database names, CPU number, memory number, IP addresses, ports, states, roles and related information of a database server contained in the first database system. For example, the first database system includes 3 databases, and names, numbers of CPUs, memory numbers, IP addresses, ports, states, roles, and database servers where the 3 databases are located.
Step 802, obtaining a main resource allocation amount of a main database in a first database system.
Step 803, the name and host server information of the container in which the first database system backup database is located are obtained.
Step 804, executing a command for updating the resource allocation amount of the container in which the backup database is located to the primary resource allocation amount on the host server.
And if the backup database can not be updated to the main database, executing the updating command on each backup database. If it can be determined which backup database is to be updated as the master database, only the backup database that is to be updated as the master database is executed by the update command.
And if any step fails to be executed, recording the abnormal condition into a log for a manager to check.
The following describes an execution flow of the periodic checking unit, as shown in fig. 9, including:
step 901, determine whether to initiate periodic inspection at the current time.
Step 902, obtain each database system running on each server.
Step 903, after waiting for 1 minute, returns to step 901.
And step 904, aiming at any database system, determining the deployment architecture information of the database system.
And calling a database cloud platform interface to inquire the deployment architecture information of the database system, wherein the deployment architecture information comprises database names, CPU numbers, memory numbers, IP addresses, ports, states, roles and related information of the physical server where the deployment architecture information is located.
Step 905, determining whether the number of CPUs in any backup database in the database system is 0. If yes, go to step 907. If not, go to step 906.
Step 906, call the sharing unit.
Step 907, perform step 905 on the next standby database.
In the main-standby switching, the reconfiguration unit is only responsible for restoring the standby resource configuration quantity of the standby database to the main resource configuration quantity, so that the main-standby switching is performed as soon as possible after the standby resource configuration quantity is restored to the main resource configuration quantity in order to reduce the operation time. In the previous solution, if there are multiple backup databases, since it cannot be determined which backup database will be switched to the primary database, the backup resource allocation amount of each backup database will be recovered to the primary resource allocation amount. For example, all 3 backup databases are restored from core 0 to core 8. And then, performing main-standby switching. And the initial main database is updated to the standby database, service is not provided, but the resource allocation amount is still 8 cores.
The above conditions can be checked by the periodic checking unit, the periodic checking unit checks the initial main database which is updated to the standby database and the standby database with the restored standby resource allocation amount, and the database systems corresponding to the standby databases are sent to the sharing unit for processing.
Based on the same technical concept, fig. 10 exemplarily shows a structure of a resource configuration apparatus of a database server according to an embodiment of the present invention, where the structure can perform a flow of resource configuration of the database server.
As shown in fig. 10, the apparatus specifically includes:
an obtaining unit 1001, configured to obtain a main resource allocation amount of a main database in any first database system in response to a main/standby switching instruction for the first database system; the main/standby switching instruction is used for indicating a standby database of the first database system to replace a main database to provide service; the resource allocation amount is the amount of a Central Processing Unit (CPU) allocated to the database by a host server of the database;
a processing unit 1002 for:
updating the standby resource allocation quantity of the standby database in the first database system to the main resource allocation quantity; the configuration quantity of the equipment resources is set to be the lowest configuration quantity under the condition that the equipment database of the first database system has no service requirement; the shared resource allocation amount of a host server of a standby database of the first database system is greater than or equal to the main resource allocation amount; the shared resource allocation amount is shared by all backup databases deployed in the host server;
and updating the standby database of the first database system into a main database of the first database system so that the updated main database provides services based on the updated main resource allocation amount.
In some embodiments, the processing unit 1002 is specifically configured to:
acquiring an account mode of each account using the first database system based on the sharing triggering behavior aiming at the first database system; the sharing triggering behavior is an application behavior of a user to the first database system or a newly added account behavior of the first database system;
determining that the first database system has no service requirement for simultaneously providing services for a main database and a standby database according to each account mode;
and setting the standby resource configuration quantity of the standby database of the first database system as the lowest configuration quantity.
In some embodiments, the processing unit 1002 is specifically configured to:
acquiring the standby resource demand of the first database system applied by a user;
selecting any database server, judging whether the shared resource allocation amount of the database server is greater than or equal to the standby resource demand amount, if so, deploying the standby database of the first database system in the database server, and setting the standby resource allocation amount of the standby database of the first database system as the lowest allocation amount;
if the spare resource demand is not more than or equal to the spare resource demand, judging whether the residual resource allocation quantity of the database server is more than or equal to the spare resource demand, if the residual resource allocation quantity of the database server is more than or equal to the spare resource demand, deploying the spare database of the first database system in the database server, setting the spare resource allocation quantity of the spare database of the first database system as the lowest allocation quantity, and updating the shared resource allocation quantity of the database server to the spare resource demand; and if the standby resource demand is not more than or equal to the standby resource demand, not deploying the standby database of the first database system in the database server.
In some embodiments, the processing unit 1002 is further configured to:
and if the first database system is determined to have service requirements that the main database and the standby database simultaneously carry out service according to each account mode, setting the standby resource allocation amount of the standby database of the first database system as the main resource allocation amount.
In some embodiments, the processing unit 1002 is specifically configured to:
and if the account modes of read-write separation and read-only standby database do not exist in the account modes, determining that the first database system does not have the service requirement that the main database and the standby database simultaneously perform service.
In some embodiments, the processing unit 1002 is further configured to:
and updating the initial main database of the first database system into a standby database, and updating the standby resource allocation amount of the updated standby database into the lowest allocation amount.
In some embodiments, the processing unit 1002 is further configured to:
updating an initial main database of the first database system into a standby database;
periodically acquiring a plurality of second database systems running on each server; judging whether the standby resource allocation amount of any standby database in any second database system is not the lowest allocation amount;
if yes, acquiring an account mode of each account using the second database system aiming at the second database system;
determining that the second database system does not have service requirements for simultaneously serving the main database and the standby database according to each account mode;
and setting the standby resource configuration quantity of the standby database of the second database system as the lowest configuration quantity.
Based on the same technical concept, the embodiment of the present application provides a computer device, as shown in fig. 11, including at least one processor 1101 and a memory 1102 connected to the at least one processor, where a specific connection medium between the processor 1101 and the memory 1102 is not limited in the embodiment of the present application, and the processor 1101 and the memory 1102 are connected through a bus in fig. 11 as an example. The bus may be divided into an address bus, a data bus, a control bus, etc.
In this embodiment, the memory 1102 stores instructions executable by the at least one processor 1101, and the at least one processor 1101 may execute the steps of the resource allocation method of the database server by executing the instructions stored in the memory 1102.
The processor 1101 is a control center of the computer device, and may connect various parts of the computer device by using various interfaces and lines, and perform resource allocation of the database server by executing or executing instructions stored in the memory 1102 and calling data stored in the memory 1102. In some embodiments, processor 1101 may include one or more processing units, and processor 1101 may integrate an application processor, which primarily handles operating systems, user interfaces, application programs, and the like, and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above 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, or in some embodiments, they may be implemented separately on separate chips.
The processor 1101 may be a general purpose processor such as a Central Processing Unit (CPU), a digital signal processor, an Application Specific Integrated Circuit (ASIC), a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like, that may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present Application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in a processor.
Memory 1102, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The Memory 1102 may include at least one type of storage medium, and may include, for example, a flash Memory, a hard disk, a multimedia card, a card-type Memory, a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Programmable Read Only Memory (PROM), a Read Only Memory (ROM), a charged Erasable Programmable Read Only Memory (EEPROM), a magnetic Memory, a magnetic disk, an optical disk, and so on. The memory 1102 is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 1102 of the embodiments of the present application may also be circuitry or any other device capable of performing a storage function for storing program instructions and/or data.
Based on the same technical concept, an embodiment of the present invention further provides a computer-readable storage medium, where a computer-executable program is stored, and the computer-executable program is configured to enable a computer to perform the method for resource allocation of a database server listed in any of the above manners.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may 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, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may 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 the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
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 the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (10)

1. A resource allocation method of a database server is characterized by comprising the following steps:
responding to a main/standby switching instruction aiming at any first database system, and acquiring the main resource allocation quantity of a main database in the first database system; the master-slave switching instruction is used for indicating a master database of the first database system to replace a master database to provide service; the resource allocation amount is the amount of a Central Processing Unit (CPU) allocated to the database by a host server of the database;
updating the standby resource allocation quantity of the standby database in the first database system to the main resource allocation quantity; the configuration quantity of the equipment resources is set to be the lowest configuration quantity under the condition that the equipment database of the first database system has no service requirement; the shared resource allocation amount of a host server of a standby database of the first database system is greater than or equal to the main resource allocation amount; the shared resource allocation amount is shared by each backup database deployed in the host server;
and updating the standby database of the first database system into a main database of the first database system so that the updated main database provides services based on the updated main resource allocation amount.
2. The method of claim 1, wherein setting the standby resource configuration amount of the standby database of the first database system to a minimum configuration amount by:
acquiring an account mode of each account using the first database system based on the sharing triggering behavior aiming at the first database system; the sharing triggering behavior is an application behavior of a user to the first database system or a newly added account behavior of the first database system;
determining that the first database system does not have service requirements for simultaneously providing services for a main database and a standby database according to each account mode;
and setting the standby resource configuration quantity of the standby database of the first database system as the lowest configuration quantity.
3. The method of claim 2, wherein setting the configured amount of standby resources of the standby database of the first database system to a minimum configured amount comprises:
acquiring the standby resource demand of the first database system applied by a user;
selecting any database server, judging whether the shared resource allocation amount of the database server is greater than or equal to the standby resource demand amount, if so, deploying the standby database of the first database system in the database server, and setting the standby resource allocation amount of the standby database of the first database system as the lowest allocation amount;
if the spare resource demand is not more than or equal to the spare resource demand, judging whether the residual resource allocation quantity of the database server is more than or equal to the spare resource demand, if the residual resource allocation quantity of the database server is more than or equal to the spare resource demand, deploying the spare database of the first database system in the database server, setting the spare resource allocation quantity of the spare database of the first database system as the lowest allocation quantity, and updating the shared resource allocation quantity of the database server to the spare resource demand; and if the standby resource demand is not more than or equal to the standby resource demand, not deploying the standby database of the first database system in the database server.
4. The method of claim 2, further comprising:
and if the first database system is determined to have service requirements for simultaneously performing service on the main database and the standby database according to the account modes, setting the standby resource allocation amount of the standby database of the first database system as the main resource allocation amount.
5. The method of claim 2, wherein determining that the first database system does not have a service requirement for simultaneous servicing of a primary database and a secondary database based on the respective account schema comprises:
and if the account modes of read-write separation and read-only standby database do not exist in the account modes, determining that the first database system does not have the service requirement of simultaneously serving the main database and the standby database.
6. The method of claim 1, after updating the standby database of the first database system to the primary database of the first database system, further comprising:
and updating the initial main database of the first database system into a standby database, and updating the standby resource allocation amount of the updated standby database into the lowest allocation amount.
7. The method of claim 1, after updating the standby database of the first database system to the primary database of the first database system, further comprising:
updating an initial main database of the first database system into a standby database;
the method further comprises the following steps:
periodically acquiring a plurality of second database systems running on each server; judging whether the standby resource allocation amount of any standby database in any second database system is not the lowest allocation amount;
if yes, acquiring an account mode of each account using the second database system aiming at the second database system;
determining that the second database system does not have service requirements for simultaneously serving the main database and the standby database according to each account mode;
and setting the standby resource configuration quantity of the standby database of the second database system as the lowest configuration quantity.
8. A resource allocation apparatus of a database server, comprising:
the system comprises an acquisition unit, a processing unit and a control unit, wherein the acquisition unit is used for responding to a main/standby switching instruction aiming at any first database system and acquiring the main resource allocation quantity of a main database in the first database system; the main/standby switching instruction is used for indicating a standby database of the first database system to replace a main database to provide service; the resource allocation amount is the amount of a Central Processing Unit (CPU) allocated to the database by a host server of the database;
a processing unit to:
updating the standby resource allocation quantity of the standby database in the first database system to the main resource allocation quantity; the configuration quantity of the equipment resources is set to be the lowest configuration quantity under the condition that the equipment database of the first database system has no service requirement; the shared resource allocation amount of a host server of a standby database of the first database system is greater than or equal to the main resource allocation amount; the shared resource allocation amount is shared by all backup databases deployed in the host server;
and updating the standby database of the first database system to a main database of the first database system so that the updated main database provides services based on the updated main resource allocation amount.
9. A computing device, comprising:
a memory for storing a computer program;
a processor for calling a computer program stored in said memory, for executing the method of any one of claims 1 to 7 in accordance with the obtained program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer-executable program for causing a computer to execute the method of any one of claims 1 to 7.
CN202210942469.1A 2022-08-08 2022-08-08 Resource allocation method and device for database server Pending CN115438021A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210942469.1A CN115438021A (en) 2022-08-08 2022-08-08 Resource allocation method and device for database server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210942469.1A CN115438021A (en) 2022-08-08 2022-08-08 Resource allocation method and device for database server

Publications (1)

Publication Number Publication Date
CN115438021A true CN115438021A (en) 2022-12-06

Family

ID=84243290

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210942469.1A Pending CN115438021A (en) 2022-08-08 2022-08-08 Resource allocation method and device for database server

Country Status (1)

Country Link
CN (1) CN115438021A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115840756A (en) * 2022-12-14 2023-03-24 中国南方电网有限责任公司 Data updating method of main and standby debugging system, equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115840756A (en) * 2022-12-14 2023-03-24 中国南方电网有限责任公司 Data updating method of main and standby debugging system, equipment and medium
CN115840756B (en) * 2022-12-14 2024-03-22 中国南方电网有限责任公司 Data updating method of main and standby modulation system, equipment and medium

Similar Documents

Publication Publication Date Title
US11586673B2 (en) Data writing and reading method and apparatus, and cloud storage system
US10509680B2 (en) Methods, systems and apparatus to perform a workflow in a software defined data center
CN110096336B (en) Data monitoring method, device, equipment and medium
CN112596960B (en) Distributed storage service switching method and device
US7882223B2 (en) System and method for saving dump data of a client in a network
US20130103835A1 (en) Resource management method, resource management device, and program product
US11755369B2 (en) Techniques for container scheduling in a virtual environment
CN111124475A (en) Method for storage management, electronic device and computer-readable storage medium
CN108874549B (en) Resource multiplexing method, device, terminal and computer readable storage medium
US11301299B2 (en) Data based scheduling for horizontally scalable clusters
CN111209110A (en) Task scheduling management method, system and storage medium for realizing load balance
CN110377664B (en) Data synchronization method, device, server and storage medium
CN115438021A (en) Resource allocation method and device for database server
CN110740155A (en) Request processing method and device in distributed system
CN111538585A (en) Js-based server process scheduling method, system and device
CN113190619B (en) Data read-write method, system, equipment and medium for distributed KV database
CN113946491A (en) Microservice data processing method, microservice data processing device, computer equipment and storage medium
CN112631994A (en) Data migration method and system
CN109284169B (en) Big data platform process management method based on process virtualization and computer equipment
CN110275772B (en) Data processing method and related equipment thereof
CN114493602B (en) Block chain transaction execution method and device, electronic equipment and storage medium
CN106888244B (en) Service processing method and device
WO2018188958A1 (en) A method and a host for managing events in a network that adopts event-driven programming framework
CN106027591B (en) Service optimization computer system and method thereof
CN114443223A (en) Bare computer disk management method, device and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination