Database elasticity method, database elasticity device and database elasticity service system
By using the elastic allocation method of local disk databases under the cloud native architecture, the backup database is first elastic allocation processing, the main and backup switching is performed, and the main database is elastically configured processing, which solves the problem of low elastic efficiency of local disk databases under the cloud native architecture, and achieves efficient database elasticity.
Patent Information
- Application Number
- CN202210546286.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-18
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2042-05-18
AI Technical Summary
The local disk database under the cloud native architecture is less elastic and efficient, and data migration takes time, affecting database performance and application process access.
A database elastic method is proposed. By receiving elastic requests for the target database in the local disk, the elastic allocation scheme is determined, including elastic allocation processing for the backup database, switching the main and backups, and elastic allocation processing for the main database to form the target database after elastic allocation.
By changing the main library and the backup library respectively in the elastic process, the backup library is first modified and flexible, so that the application does not affect the application access to the main library. Then, the backup library after the variable is switched to the original main library to complete the elasticity of the database, reduce the impact on the application business, and improve elastic efficiency.
Smart Images

Figure CN114996351B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to data processing technology, and more specifically, to a database elasticity method, a database elasticity device, and a database elasticity service system. Background Art
[0002] At present, elasticity in cloud-native architecture usually refers to the elastic scheduling of stateless nodes, including the expansion of running application containers. Since elasticity in cloud-native architecture does not involve data migration, the scheduling scheme of creating first and then deleting can achieve rapid elasticity based on stateless nodes or cloud disks in cloud-native architecture.
[0003] Although local disks are the database structure with the best performance and the most widely used, local disk databases are stateful nodes, and cloud-native architectures have poor support for local disks. Therefore, how to achieve rapid elasticity of local disk databases under cloud-native architectures is an urgent problem to be solved.
[0004] Since the elasticity of the local disk database involves data migration, if the create-before-delete scheduling scheme used by stateless nodes is used as the elastic scheduling scheme for the local disk database under the cloud-native architecture, data migration may take a lot of time, causing data migration to affect the performance of the original database, thereby affecting the application process's access to the corresponding business in the database, losing the advantages of the cloud-native architecture and resulting in low elasticity efficiency of the local disk database under the cloud-native architecture. Summary of the invention
[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a database elasticity method, a database elasticity device, a database elasticity service system, a service device, a storage medium and a program product, which can improve the elasticity efficiency of the local disk database under the cloud native architecture.
[0006] In a first aspect, an embodiment of the present application provides a database elasticity method, comprising: receiving an elastic request for a target database in a local disk, the target database including a first database as a standby database and a second database as a master database; determining an elastic configuration scheme for the target database; wherein the elastic configuration scheme comprises: performing elastic configuration processing on the first database to obtain a third database after configuration; performing master-slave switching on the third database and the second database, switching the third database to the master database of the target database, and switching the second database to the standby database of the target database; performing elastic configuration processing on the second database to obtain a fourth database after configuration, so as to obtain the target database after elastic configuration based on the third database as the master database and the fourth database as the standby database.
[0007] In a second aspect, the present application provides a database elasticity device, which includes: a receiving module and a determining module; the receiving module is used to receive an elastic request for a target database in a local disk, the target database including a first database as a backup database and a second database as a main database; the determining module is used to determine an elastic configuration scheme for the target database; wherein the elastic configuration scheme includes: performing elastic configuration processing on the first database to obtain a third database after configuration; performing master-slave switching on the third database and the second database, switching the third database to the main database of the target database, and switching the second database to the backup database of the target database; performing elastic configuration processing on the second database to obtain a fourth database after configuration, so as to obtain the target database after elastic configuration based on the third database as the main database and the fourth database as the backup database.
[0008] In a third aspect, the present application provides a database elastic service system, which includes: a resource management microservice module, configured to: receive a target request for a target database, the target request is an elastic request or an elastic evaluation request, the target database includes a first database as a backup database and a second database as a main database; a data service module, configured to: provide first resource information on a first host device where a target instance corresponding to the target database is located, the target instance includes at least one of the following: a first database, a second database; the first resource information includes the computing resources occupied by each instance on the first host device and the storage resources occupied by each instance, the idle computing resources of the first host device, and the computing resources of the first host device. a resource overload threshold; a resource evaluation module configured to: when the target request is a request related to capacity expansion and configuration change, based on the target request, obtain first resource information from the data service module, and determine a target evaluation result for capacity expansion and configuration change of the target instance according to the first resource information, the target evaluation result including any one of the following: a direct elastic evaluation result, an elastic first and then migration evaluation result, a migration first and then elastic evaluation result, and a direct migration evaluation result; when the target request is an elastic evaluation request, send the target evaluation result to the resource management microservice module; a resource pool data module configured to: provide second resource information corresponding to each target host device in at least one target host device in the resource pool, the second resource information corresponding to each target host device in the resource pool, and the second resource information corresponding to each target host device in the resource pool; The source information includes the idle computing resources of the corresponding target host device; the scheduling strategy determination module is configured to: obtain the target evaluation result from the resource evaluation module; when the target evaluation result includes any one of the following: an evaluation result of elastic first and then migration, an evaluation result of migration first and then elastic, and a direct migration evaluation result, based on the target evaluation result and the second resource information obtained from the resource pool data module, determine the migration scheduling strategy corresponding to the migration scheme for expanding and changing the configuration of the target instance, the scheduling strategy includes the migration instance corresponding to the migration scheme, and the target host device to which the migration instance needs to be migrated; the resource scheduling module is configured to: when the target request is an elastic request corresponding to a shrinking and changing configuration, execute the elastic The elastic scheduling policy corresponding to the scheme related to the target instance in the elastic configuration scheme; when the target request is a capacity expansion request and the target evaluation result is a direct elastic evaluation result, the elastic scheduling policy corresponding to the scheme related to the target instance in the elastic configuration scheme is executed; when the target request is a capacity expansion request and the target evaluation result includes any of the following: an evaluation result of elastic first and then migration, an evaluation result of migration first and then elastic, and a direct migration evaluation result, the elastic scheduling policy corresponding to the scheme related to the target instance in the elastic configuration scheme is executed, and the migration scheduling policy corresponding to the target evaluation result is executed; wherein, the elastic configuration scheme includes: performing elastic configuration processing on the first database to obtain a third database after configuration;Perform active / standby switching on the third database and the second database, switch the third database to the active database of the target database, and switch the second database to the standby database of the target database; perform elastic configuration change processing on the second database to obtain a fourth database after configuration change, so as to obtain the target database after elastic configuration change based on the third database as the active database and the fourth database as the standby database. ;
[0009] In a fourth aspect, the present application provides a service device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the database elasticity method as described in the first aspect.
[0010] In a fifth aspect, the present application provides a computer-readable storage medium, comprising: a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the database elasticity method shown in the second aspect is implemented.
[0011] In a sixth aspect, the present application provides a computer program product, characterized in that it includes: when the computer program product runs on a computer, it enables the computer to implement the database elasticity method shown in the second aspect.
[0012] The technical solution provided by the embodiment of the present application has the following advantages over the prior art: In the embodiment of the present application, an elastic request for a target database in a local disk is received, the target database including a first database as a standby database and a second database as a main database; an elastic configuration scheme for the target database is determined; wherein the elastic configuration scheme includes: elastic configuration processing on the first database to obtain a third database after configuration; performing master-slave switching on the third database and the second database, switching the third database to the main database of the target database, and switching the second database to the standby database of the target database; elastic configuration processing on the second database to obtain a fourth database after configuration, so as to obtain the target database after elastic configuration based on the third database as the main database and the fourth database as the standby database. Therefore, in view of the elasticity of the local disk database, the embodiment of the present application proposes to separately change the configuration of the main database and the standby database during the elasticity process, first perform elastic configuration change processing on the standby database without affecting the application program's access to the business corresponding to the application program in the main database, and then perform master-standby switching between the standby database after the configuration change and the original main database (the standby database after the configuration change is switched to the main database to obtain the main database after the configuration change, and the original main database is switched to the standby database). After the switching, the application program can continue to access the business corresponding to the application program in the main database after the configuration change, and then perform elastic configuration change processing on the switched standby database to obtain the configured database after the configuration change, thereby completing the elasticity of the database, and during the database elasticity process, the impact on the business corresponding to the application program is minimal, which can improve the elasticity efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the implementation methods in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technology descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.
[0014] Figure 1 A schematic diagram of stateless node resilience according to some embodiments is shown;
[0015] Figure 2 A schematic diagram of local disk database elasticity based on a stateless node elastic scheduling solution according to some embodiments is shown;
[0016] Figure 3 A schematic diagram of a database elasticity system according to some embodiments is shown;
[0017] Figure 4 One of the flowchart diagrams of the database elasticity method according to some embodiments is shown;
[0018] Figure 5 A second flowchart of a database elasticity method according to some embodiments is shown;
[0019] Figure 6 A third flowchart of a database elasticity method according to some embodiments is shown;
[0020] Figure 7 A fourth flowchart of a database elasticity method according to some embodiments is shown;
[0021] Figure 8 A fifth flowchart of a database elasticity method according to some embodiments is shown;
[0022] Fig. 9 A schematic diagram showing migration instance selection and destination host device selection of a migration solution according to some embodiments is shown;
[0023] Fig.10 A schematic diagram showing the results of a database elasticity device according to some embodiments;
[0024] Fig.11 A schematic diagram of a database elastic service system according to some embodiments is shown;
[0025] Fig.12 A schematic diagram of a scheduling strategy determination process according to some embodiments is shown;
[0026] Fig.13 A schematic diagram of the structure of a service device according to some embodiments is shown. DETAILED DESCRIPTION
[0027] In order to make the purpose and implementation method of the present application clearer, the exemplary implementation method of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0028] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0029] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.
[0030] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0031] The host device and service device provided in the embodiments of the present application may have a variety of implementation forms, for example, may be a television, a mobile phone, a tablet computer, a laptop computer, a PDA, a computer device, etc. The specific implementation form may be determined based on actual conditions and is not limited here.
[0032] First, some nouns or terms involved in the claims and description of the present invention are explained below.
[0033] Local disk database: a database architecture that uses local disks to store data. Usually, a database cluster includes a primary database and a backup database. The primary database and the backup database of the database cluster can be on the same host device or not.
[0034] Instance: If a host device includes a primary database and a backup database, the instances corresponding to the database on the host device are the primary database and the backup database of the database; if a host device only includes a primary database, the instance corresponding to the database on the host device is the primary database of the database; if a host device only includes a backup database of a database, the instance corresponding to the database on the host device is the backup database of the database.
[0035] Node: For local disks, a node represents a host device (physical machine), and the database data is stored on the disk of the host device. The disk of the host device includes data of multiple primary databases and / or data of multiple backup databases.
[0036] Pod: A combination of one or more containers. A container includes a primary database or a backup database.
[0037] Kubernetes, commonly known as k8s, is an open source container cluster management system for automatically deploying, scaling, and managing containerized applications. The system builds a container scheduling service based on the Container Runtime Interface (CRI) (such as the open source application container engine (Docker), container storage interface (CSI), etc.). Kubernetes can automatically select a working container in a container cluster for use. It aims to provide "a platform for automatically deploying, scaling, and running application containers across host clusters." It supports a range of container tools, including Docker, CRI-O, etc.
[0038] Because the stateless nodes in the cloud-native architecture have no special status, requests to access stateless services are processed indiscriminately by the server (stateless services can be deployed on any server without affecting the service, unlike databases that must have data on the server), and no data migration is involved. Therefore, in order to minimize the impact on application business during the elastic process, the elasticity of stateless nodes in the cloud-native architecture adopts a create-first-then-delete scheduling scheme.
[0039] like Figure 1 As shown in the figure, taking the elastic request as the capacity expansion request as an example, the capacity expansion and configuration change scheme of the stateless node under the cloud native architecture is a scheduling scheme of create first and then delete, specifically including: the service device receives a capacity expansion request for pod1 and pod2 with computing resources of 2c4g, and the capacity expansion request requires the computing resources to be expanded from 2c4g to 4c8g. The mark "1" indicates that the service device creates new pod3 and pod4 with computing resources of 4c8g according to the capacity expansion request, the mark "2" indicates that the service device forwards the capacity expansion request to the newly created pod3 and pod4, and the mark "3" indicates that the service device deletes (takes offline) the original pod1 and pod2.
[0040] With the development of cloud disk performance and network optimization, the storage and computing separation mode of cloud disk database has become more mature. The cloud native architecture supports the storage and computing separation mode of cloud disk database well, which is equivalent to sinking the stateful part to the storage layer. Therefore, the elasticity of cloud disk database under cloud native architecture can also adopt the scheduling scheme of create first and then delete. The specific process is not described here. However, the performance of cloud disk database still cannot surpass the performance of local disk database, and the local disk database form is still the mainstream today. The local disk database is a stateful node. How to achieve the elasticity of the local disk database under the cloud native architecture is an urgent problem to be solved.
[0041] like Figure 2 As shown in the figure, taking the elastic request as the expansion request, the database master and standby database are on the same host device as an example, assuming that the expansion and configuration scheme of the local disk database in the cloud native architecture is the stateless node creation-then-deletion scheduling scheme, the service device receives the expansion request for the database in node3, the mark "4" indicates that the service device creates a new master and standby database in node4, the mark "5" indicates that the service device performs data migration on the data in the database, the mark "6" indicates that the service device forwards the expansion request to the newly created master and standby databases in node4, and the mark "7" indicates that the service device takes offline the original master and standby databases. This process has the following problems: the data migration speed is slow, the migration time required for data migration is long, the larger the data volume, the longer the migration time, 1T of data needs nearly ten hours to migrate, resulting in low elastic efficiency, and data migration affects the performance of the original database, affecting the database business, and losing the advantages of the cloud native architecture.
[0042] like Figure 3 As shown, an embodiment of the present application provides a database elastic system, which includes a service device 310 and multiple host devices 321 in a resource pool 320, wherein the service device 310 is used to manage the database in each host device 321 in the resource pool 320, and provide a reasonable elastic configuration plan for each database elastic configuration, as well as an elastic scheduling strategy corresponding to the elastic configuration plan.
[0043] In order to explain this scheme in more detail, the following will be combined in an exemplary manner Figures 4 to 9 To explain, it is understandable that Figures 4 to 9 The steps involved may include more steps or fewer steps in actual implementation, and the order of these steps may also be different, so as to implement the database elasticity method provided in the embodiment of the present application.
[0044] Figure 4The flowchart of the steps of implementing the database elasticity method according to one or more embodiments of the present application, the execution subject of the database elasticity method can be a service device, or a functional module or functional entity in the service device that can implement the database elasticity method, which is not limited here. The database elasticity method may include:
[0045] 401. Receive an elastic request for a target database in a local disk.
[0046] The target database includes a first database serving as a standby database and a second database serving as a primary database.
[0047] 402. Determine an elastic configuration solution for the target database.
[0048] Among them, the elastic configuration scheme includes: performing elastic configuration processing on the first database to obtain a third database after configuration; performing master-slave switching on the third database and the second database, switching the third database to the master database of the target database, and switching the second database to the slave database of the target database; performing elastic configuration processing on the second database to obtain a fourth database after configuration, so as to obtain the target database after elastic configuration based on the third database as the master database and the fourth database as the slave database.
[0049] like Figure 5 As shown in the figure, the process of elastically changing the configuration of the target database based on the elastic configuration solution includes:
[0050] 501. Stop the application process corresponding to the first database.
[0051] 502. Call the k8s API to perform elastic configuration processing on the first data to obtain a third database.
[0052] Among them, the application programming interface is Application Programming Interface, referred to as API.
[0053] 503. Pull up the third database.
[0054] 504. Call the HA service to perform active / standby switching, switch the third database to the active database, and switch the second database to the standby database.
[0055] Among them, high availability is high availability, referred to as HA.
[0056] 505. Stop the application process corresponding to the second database.
[0057] 506. Call the k8s API to perform elastic configuration change processing on the second database to obtain a fourth database.
[0058] 507. Pull up the fourth database.
[0059] Through the above steps 501 to 507, elastic reconfiguration of the target database is achieved, and the target database with the first database as the standby database and the second database as the main database is elastically reconfigured to obtain a target database with the third database as the main database and the fourth database as the standby database.
[0060] In the embodiment of the present application, in view of the elasticity of the local disk database, it is proposed that the main database and the standby database are reconfigured separately during the elasticity process, and the standby database is first elastically reconfigured without affecting the application's access to the business corresponding to the application in the main database, and then the standby database after the configuration change and the original main database are switched between the main and standby databases (the standby database after the configuration change is switched to the main database to obtain the main database after the configuration change, and the original main database is switched to the standby database). After the switching, the application can continue to access the business corresponding to the application in the main database after the configuration change, and then the switch standby database is elastically reconfigured to obtain the configured database. In this way, the elasticity of the database is completed, and during the database elasticity process, the impact on the business corresponding to the application is minimized, which can improve the elasticity efficiency.
[0061] The first host device includes a target instance corresponding to the target database, and the target instance includes at least one of the following: a first database and a second database.
[0062] It can be understood that if the first database and the second database included in the target database are both on the first host device, the target instance is the first database and the second database; if only the first database included in the target database is on the first host device, the target instance is the first database; if only the second database included in the target database is on the first host device, the target instance is the second database.
[0063] Optionally, the elastic request is a scaling request, and the elastic configuration change is a scaling configuration change. Since the scaling configuration change is to reduce the computing resources occupied by the target instance on the first host device, the scaling configuration change can be performed directly on the first host device without involving instance migration, thereby improving the scaling efficiency of the local disk database.
[0064] Optionally, the elastic request is a capacity expansion request, and the elastic configuration change is a capacity expansion configuration change. Since the capacity expansion configuration change is to expand the computing resources occupied by the target instance on the first host device, directly performing capacity expansion configuration change on the target instance on the first host device may cause the computing resources occupied by each instance on the first host device to exceed the total computing resources on the first host device. In this case, it is necessary to consider migrating a suitable instance from the first host device so that the computing resources occupied by each instance on the first host device do not exceed the total computing resources on the first host device. Since k8s supports a certain amount of resource oversold on the host device for a short period of time, it is also possible to consider whether to migrate first and then elastic, or to elastic first and then migrate, according to actual conditions. Furthermore, it is also possible to consider whether to migrate out other instances on the first host device or to migrate out the target instance on the first host device, according to actual conditions.
[0065] For example, in combination Figure 4 ,like Figure 6 As shown, before the above step 402, the database elasticity method provided in the embodiment of the present application may also include:
[0066] 403. Based on the capacity expansion request, obtain first resource information.
[0067] The first resource information includes computing resources occupied by each instance on the first host device and storage resources occupied by each instance, as well as idle computing resources of the first host device and a computing resource overload threshold of the first host device.
[0068] 404. Determine a target evaluation result for capacity expansion and configuration change of the target instance according to the first resource information.
[0069] Among them, different target evaluation results correspond to different flexible plans.
[0070] It should be noted that the first resource information is a real-time online resource, and the target evaluation result is an online resource evaluation result for the first host device.
[0071] In an embodiment of the present application, a target evaluation result is obtained by performing a capacity expansion and configuration change evaluation on the target instance based on the first resource information. Different target evaluation results correspond to different elastic solutions. In this way, a suitable elastic solution can be determined by performing a capacity expansion and configuration change evaluation to improve the elasticity efficiency of the database.
[0072] Optionally, the target evaluation result includes any one of the following: a direct elasticity evaluation result, an elastic-first-then-migration evaluation result, a migration-first-then-elasticity evaluation result, and a direct migration evaluation result.
[0073] Among them, the direct elasticity assessment result includes: the adjusted computing resources required for the target instance to expand and reconfigure are less than or equal to the idle computing resources of the first host device (indicating that the computing resources on the first host device are sufficient), and the plan related to the target instance in the elastic configuration plan is executed on the first host device.
[0074] It can be understood that when there are sufficient idle resources on the first host device, the elastic solution is to directly execute the solution related to the target instance in the elastic configuration solution on the first host device, which can improve the elastic efficiency of the target database.
[0075] Among them, executing the solution related to the target instance in the elastic configuration solution on the first host device can be specifically understood as: if the target instance is the first database and the second database in the target database, then executing the elastic configuration solution on the first host device; if the target instance is only the first database in the target database, then executing the solution related to the first database in the elastic configuration solution on the first host device (such as elastically configuring the first database to obtain the third database, and then switching the third database from the standby database to the main database); if the target instance is only the second database in the target database, then executing the solution related to the second database in the elastic configuration solution on the first host device (such as switching the second database from the main database to the standby database, and elastically configuring the second database switched to the standby database to obtain the fourth database).
[0076] Among them, the evaluation result of "elasticity first, then migration" includes: the adjusted computing resources are greater than the idle computing resources of the first host device (indicating that the computing resources on the first host device are insufficient) and less than or equal to the target resources (indicating that the target instance is allowed to be expanded and reconfigured on the first host device when the resources of the first host device are oversold); first, the plan related to the target instance in the elastic configuration plan is executed on the first host device, and then the first migration plan is executed. The target resource is the sum of the idle computing resources of the first host device and the overload threshold of the computing resource; the first migration plan is to migrate the first instance on the first host device from the first host device to the second host device.
[0077] It can be understood that when computing resources on the first host device are insufficient but resources are oversold, the target instance is allowed to be expanded and reconfigured on the first host device. The elastic solution is to first execute the solution related to the target instance in the elastic reconfiguration solution on the first host device, and then execute the first migration solution.
[0078] Among them, the migration-then-elastic evaluation results include: the adjusted computing resources are greater than the target resources (indicating that the target instance is not allowed to be expanded or reconfigured on the first host device even if the resources of the first host device are oversold), and the storage resources occupied by the target instance are greater than or equal to the storage resources occupied by the first instance (indicating that the storage resources occupied on the first host device are less than the target instance, and expanding and reconfiguring the target instance after migration will not cause the first instance of the first host device to be overloaded), and the first migration plan is first executed on the first host device, and then the plan related to the target instance in the elastic configuration plan is executed.
[0079] The computing resources occupied by the first instance are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device.
[0080] It can be understood that when the resources of the first host device are oversold, the target instance is not allowed to be expanded or reconfigured on the first host device. When the first host device includes a suitable first instance, the first migration plan can be executed on the first instance first, and then the plan related to the target instance in the elastic configuration plan can be executed on the target instance. In this way, because the storage resources occupied by the first instance are less than the storage resources occupied by the target instance, migrating the first instance can save time compared to directly migrating the target instance, thereby improving the elastic efficiency of the target instance and the elastic efficiency of the target database.
[0081] It should be noted that, in an embodiment of the present application, the migration-first-elasticity-then-elasticity evaluation result may also include: the adjusted computing resources are greater than the target resources, and the storage resources occupied by the target instance are greater than or equal to the storage resources occupied by the first instance, the first migration plan is first executed on the first host device, and then the plan related to the target instance in the elastic configuration plan is executed, and finally the third migration plan is executed.
[0082] It can be understood that after executing the first migration plan, in the case that the first host device is oversold, the target instance can be expanded and configured, and then the third migration plan can be used to make the computing resources occupied by each instance on the first host device less than or equal to the total computing resources on the first host device.
[0083] In the embodiment of the present application, whether the migration-first-elasticity-then-elasticity evaluation result corresponds to the first migration plan and the plan related to the target instance in the elastic configuration plan, or corresponds to the first migration plan, the plan related to the target instance in the elastic configuration plan and the third migration plan, can be determined based on the specific situation and is not limited here.
[0084] Among them, the direct migration evaluation result includes: the adjusted computing resources are greater than the target resources (indicating that the target instance is not allowed to be expanded and configured on the first host device even if the resources of the first host device are oversold), and the storage resources occupied by the target instance are less than the storage resources occupied by any second instance on the first host (indicating that there is no suitable migratable instance on the first host device, and the target instance is the most suitable migratable instance on the first host device), and while executing the second migration plan, the plan related to the target instance in the elastic scheduling plan is executed, and the second migration plan is to migrate the target instance from the first host device to the third host device.
[0085] It should be noted that, in the case where the target instance includes the first database and the second database in the target database, in an embodiment of the present application, the storage resources occupied by the target instance are the storage resources occupied by the first database, and executing the second migration plan while executing the plan related to the target instance in the elastic scheduling plan specifically includes: executing elastic configuration change processing while migrating the first database from the first host device to the third host device to obtain a third database on the third host device, performing master-slave switching on the third database and the second database, and then executing elastic configuration change processing while migrating the second database from the first host device to the third host device to obtain a fourth database on the third host device.
[0086] It should be noted that, when the target assessment result is a direct migration assessment result, and the target instance includes the first database and the second database in the target database, assuming that the first database serving as the backup database is migrated out and expanded and configured, and the second database serving as the main database can be expanded and configured on the first host device, then only the first database can be migrated out and expanded and configured, and the second database can be directly expanded and configured on the first host device; or the first database can be migrated out and expanded and configured first, and then the second database can be migrated out and expanded and configured, and the first database (third database) and the second database (fourth database) after the migration and expansion and configuration are still on the same host device.
[0087] It should be noted that, when the target instance only includes the first database in the target database, in an embodiment of the present application, the storage resources occupied by the target instance are the storage resources occupied by the first database; when the target instance only includes the second database in the target database, in an embodiment of the present application, the storage resources occupied by the target instance are the storage resources occupied by the second database.
[0088] It should be noted that, taking the execution of elastic reconfiguration processing while migrating the first database from the first host device to the third host device as an example, the execution of the second migration plan and the execution of the plan related to the target instance in the elastic scheduling plan are explained. The process includes: creating an instance corresponding to the third database on the third host device, copying the data corresponding to the first database (which can be remote backup data or data stored in the storage resources of the first host device) to the idle storage resources of the third host device, mounting the data corresponding to the first database stored in the storage resources of the third host device to the container corresponding to the third data, pulling up the third database on the third host device, and deleting the first database on the first host device (deleting the container corresponding to the first database and deleting the data in the storage resources occupied by the first database).
[0089] The computing resources occupied by each second instance are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device.
[0090] It can be understood that when the resources of the first host device are oversold, the target instance is not allowed to be expanded or reconfigured on the first host device, and when the target instance is the most suitable migratable instance on the first host device, the second migration plan is executed while executing the plan related to the target instance in the elastic scheduling plan. In this way, because the storage resources occupied by the target instance are less than the storage resources occupied by any second instance on the first host, the time required to migrate the target instance is less than the time required to migrate any second instance. Therefore, migrating the target instance can save time, thereby improving the elastic efficiency of the target instance and the elastic efficiency of the target database.
[0091] For example, Figure 7 As shown in the figure, the process of evaluating the expansion and configuration change of the target instance includes:
[0092] 700. Obtain first resource information.
[0093] 701. Determine whether the adjusted computing resources are less than or equal to the idle computing resources of the first host device.
[0094] If the adjusted computing resources are less than or equal to the idle computing resources of the first host device, the following step 702 is executed, otherwise, step 703 is executed.
[0095] 702. Determine the direct elasticity assessment results.
[0096] 703. Determine whether the adjusted computing resources are less than or equal to the target resources.
[0097] If the adjusted computing resources are less than or equal to the target resources, the following step 704 is executed, otherwise, step 705 is executed.
[0098] 704. Determine the assessment results of the first-strike-then-migrate policy.
[0099] 705. Determine whether the storage resources occupied by the target instance are greater than or equal to the storage resources occupied by the first instance.
[0100] If the storage resources occupied by the target instance are greater than or equal to the storage resources occupied by the first instance, the following step 706 is executed; otherwise, step 707 is executed.
[0101] 706. Determine the assessment results of relocate first and then rebound.
[0102] 707. Determine the results of the direct migration assessment.
[0103] Optionally, in the embodiment of the present application, the elastic configuration change process may be a process of first deleting and then creating, or a process of first creating and then deleting.
[0104] Optionally, when the target evaluation result includes any of the following: direct elastic evaluation result, elastic first then migration evaluation result, and migration first then elastic evaluation result, the elastic configuration change processing is a delete first then create processing. It can be understood that in this case, the elastic configuration change processing is a delete first then create processing, which can ensure to the greatest extent that the scheduling resources of the host device where the target instance is located are sufficient, so that the target instance can execute the elastic configuration change plan on the host device, which can improve the elastic efficiency of the target database.
[0105] Optionally, when the target evaluation result includes a direct migration evaluation result, the elastic configuration change process is to create first and then delete. It can be understood that in this case, because instance migration involves data migration, data migration takes a long time. Therefore, if the backup database is deleted first, if there is an exception in the main database during the migration process, the business corresponding to the application process will be unavailable. The process of creating first and then deleting can avoid this problem, thereby improving the elastic efficiency of the database.
[0106] After determining the target evaluation results, you can determine the corresponding elastic strategy based on the target evaluation results. For details, please refer to the following Fig.12 After determining the elastic strategy, whether to migrate, which instance to migrate, and the corresponding destination host device to migrate are determined according to the corresponding elastic strategy, which can be specifically described in the following steps 405 and 406, or the related descriptions of steps 405 and 407.
[0107] Optionally, the target evaluation result includes any one of the following: an evaluation result of first launching and then migrating, an evaluation result of first migrating and then launching, and an evaluation result of direct migration; Figure 6 ,like Figure 8 As shown, the database elasticity method provided in the embodiment of the present application may also include:
[0108] 405. Based on the capacity expansion request, obtain second resource information corresponding to each target host device in at least one target host device in the resource pool.
[0109] The at least one target host device may be selected from the resource pool according to any criteria, which is not limited in the embodiments of the present application.
[0110] The second resource information includes idle computing resources of the corresponding target host device.
[0111] 406. When the target evaluation result is the first-pop-then-migrate evaluation result or the first-migrate-then-pop evaluation result, based on the first resource information and the second resource information, determine a first instance that meets the first condition from the instances on the first host device, and determine a second host device that meets the second condition from the at least one target host device.
[0112] The first condition includes: the instance where the occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device, that is, the first instance is an instance where the computing resources occupied on the first host device are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device. In this way, after the first instance is migrated to the second host device and the target instance is expanded and reconfigured, the computing resources occupied by each instance on the first host device will not exceed the total computing resources on the first host device.
[0113] Among them, the second condition includes: a target host device whose idle computing resources are greater than or equal to the computing resources occupied by the first instance, that is, the second host device is a target host device in which the idle computing resources are greater than or equal to the computing resources occupied by the first instance. In this way, after the first instance is migrated to the second host device, the computing resources occupied by each instance on the second host device will not exceed the total computing resources on the second host device.
[0114] In the embodiment of the present application, by setting appropriate first conditions and second conditions, a reasonable migration scheduling strategy corresponding to the first migration solution is determined, thereby better ensuring the elastic efficiency of the target database and reducing the impact on the business corresponding to the application process of other instances.
[0115] 407. When the target evaluation result is the direct migration evaluation result, determine a third host device that meets a third condition from the at least one target host device based on the first resource information and the second resource information.
[0116] Among them, the third condition includes: a target host device with idle computing resources greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources, that is, the third host device is a target host device in which the idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources. In this way, after the target instance is migrated to the third host device, the computing resources occupied by each instance on the third host device will not exceed the total computing resources on the second host device.
[0117] In the embodiment of the present application, a suitable third condition is set to determine a reasonable migration scheduling strategy corresponding to the second migration solution, thereby better ensuring the elastic efficiency of the target database and reducing the impact on the business corresponding to the application process of the target instance.
[0118] Optionally, the second resource information includes the idle storage resources of the corresponding target host device; when the target evaluation result is the first-populate-then-migrate evaluation result or the first-migrate-then-populate evaluation result, the first condition specifically includes any one of the following: an instance in which the occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device, and the instance in which the occupied computing resources are the smallest; an instance in which the occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device, and the occupied storage resources are the smallest.
[0119] It can be understood that the first instance is the instance with the smallest occupied computing resources among the instances in which the computing resources occupied on the first host device are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device (in this way, the most suitable first instance can be determined from the computing resource perspective), or the first instance is the instance in which the computing resources occupied on the first host device are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device, and the storage resources occupied are the smallest (in this way, the most suitable first instance can be determined from the computing resource perspective and the storage resource perspective, and the data migration time can be reduced). In this way, after the first instance is migrated to the second host device and the target instance is expanded and reconfigured, the computing resources occupied by each instance on the first host device will not exceed the total computing resources on the first host device.
[0120] Optionally, the second resource information includes free storage resources of the corresponding target host device; the second condition specifically includes any one of the following: a target host device with the largest free computing resources among target host devices whose free computing resources are greater than or equal to the computing resources occupied by the first instance; a target host device with the largest weighted value of free computing resources and free storage resources among target host devices whose free computing resources are greater than or equal to the computing resources occupied by the first instance.
[0121] It can be understood that the second host device is the target host device with the largest idle computing resources among the target host devices whose idle computing resources are greater than or equal to the computing resources occupied by the first instance among at least one target host device (in this way, the most suitable second host device can be determined from the perspective of idle computing resources), or the second host device is the target host device with the largest weighted value of idle computing resources and idle storage resources among the target host devices whose idle computing resources are greater than or equal to the computing resources occupied by the first instance among at least one target host device (in this way, the most suitable second host device can be determined by combining the perspective of idle computing resources and the perspective of idle storage resources, and the data migration speed can be increased and the data migration time can be reduced). In this way, after the first instance is migrated to the second host device, the computing resources occupied by each instance on the second host device will not exceed the total computing resources on the second host device.
[0122] In the embodiment of the present application, by setting more appropriate first conditions and second conditions, a more reasonable migration scheduling strategy corresponding to the first migration scheme is determined, thereby better ensuring the elastic efficiency of the target database and reducing the impact on the business corresponding to the application process of other instances.
[0123] Optionally, the second resource information includes free storage resources of the corresponding target host device; when the target evaluation result is the direct migration evaluation result, the third condition specifically includes any one of the following: among the target host devices whose free computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources, the target host device with the largest free computing resources; among the target host devices whose free computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources, the target host device with the largest weighted value of free computing resources and free storage resources.
[0124] It can be understood that the third host device is the target host device with the largest idle computing resources among the target host devices whose idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources in at least one target host device (in this way, the most suitable third host device can be determined from the perspective of idle computing resources), or the third host device is the target host device with the largest weighted value of idle computing resources and idle storage resources among the target host devices whose idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources in at least one target host device (in this way, the most suitable third host device can be determined in combination with the perspective of idle computing resources and the perspective of idle storage resources, and the data migration speed can be increased and the data migration time can be reduced). In this way, after the target instance is migrated to the third host device, the computing resources occupied by each instance on the third host device will not exceed the total computing resources on the second host device.
[0125] In the embodiment of the present application, a more appropriate third condition is set to determine a more reasonable migration scheduling strategy corresponding to the second migration solution, thereby better ensuring the elastic efficiency of the target database and reducing the impact on the business corresponding to the application process of the target instance.
[0126] Optionally, the first resource information also includes a fixed tag of each instance on the first host device, and the fixed tag is used to indicate the host device to which the corresponding instance is allowed to migrate; the second resource information also includes a device tag of the corresponding target host device; when the target evaluation result is the first-pop-up and then-migration evaluation result or the first-migration and then-pop-up evaluation result, the fixed tag of the first instance matches the device tag of the second host device; when the target evaluation result is the direct migration evaluation result, the fixed tag of the target instance matches the device tag of the third host device.
[0127] It can be understood that by combining fixed tags and device tags, a more reasonable first instance, second host device or third host device can be determined, so that the elastic efficiency of the target database can be better guaranteed and the impact on the business corresponding to the application process of the target instance can be reduced.
[0128] Optionally, the first migration plan includes: creating a first instance on the second host device; copying the remote backup data corresponding to the first instance to the free storage resources of the second host device at the maximum network speed and maximum read and write speed (IOPS) of the container (the container corresponding to the newly created first instance on the second host) (i.e., mounting the remote backup data corresponding to the first instance on the container of the first instance on the second host device), and the remote backup data corresponding to the first instance is data updated within a preset period of time; pulling up the first instance; deleting the first instance on the first host device.
[0129] The first instance may include a primary database and a backup database of a database, or may include only a primary database of a database, or may include only a backup database of a database. The specific example may be determined according to actual conditions and is not limited here.
[0130] It can be understood that if the first database includes a main database and a backup database, the migration of the first instance includes first migrating the backup database in the first instance, then switching the main and backup databases, and then migrating the old main database in the first instance. For the specific description of the migration of the first instance, please refer to the above-mentioned description of the migration of the target instance, which will not be repeated here.
[0131] Optionally, the second migration plan includes: creating an expanded and reconfigured instance corresponding to the target instance on a third host device; copying the remote backup data corresponding to the target instance to the idle storage resources of the third host device at the maximum network speed and maximum read and write speed of the container (the container corresponding to the newly created expanded and reconfigured instance on the third host device) (i.e., mounting the remote backup data corresponding to the target instance to the container of the expanded and reconfigured instance on the third host device), the remote backup data corresponding to the target instance is the data updated within the preset time period; pulling up the expanded and reconfigured instance; and deleting the target instance on the first host device.
[0132] Among them, the preset duration can be determined according to actual conditions and is not limited here.
[0133] In the embodiment of the present application, the remote backup data corresponding to the instance is the data updated within the preset time period, then the remote backup data can be copied at the maximum network speed and the maximum read and write speed of the container compared to the data on the host device where the original instance is located. Therefore, the data copy speed can be increased, and the instance migration efficiency can be improved. In addition, the impact on the business of each instance on the first host device (the first instance or the target instance, and other instances) can be reduced.
[0134] Optionally, the first migration plan includes: creating a first instance on the second host device; copying the data corresponding to the first instance on the first host device to the free storage resources of the second host device at a limited network speed and a limited read and write speed (i.e., migrating the data on the host device where the original instance is located); pulling up the first instance; deleting the first instance on the first host device.
[0135] Optionally, the second migration plan includes: creating an expanded and reconfigured instance corresponding to the target instance on a third host device; copying the data corresponding to the target instance on the first host device to the free storage resources of the third host device (i.e., migrating the data on the host device where the original instance is located) at a limited network speed and a limited read and write speed; pulling up the expanded and reconfigured instance; and deleting the target instance on the first host device.
[0136] The limited network speed and limited reading and writing speed can be determined according to actual conditions and are not limited here.
[0137] In an embodiment of the present application, when the remote backup data corresponding to the instance is not data updated within a preset period of time, migrating the data on the host device where the original instance is located can ensure that the data is up to date, thereby reducing the impact on the business of the first instance or the target instance.
[0138] It should be noted that, in the embodiment of the present application, the target evaluation result can be any one of a direct elasticity evaluation result, an evaluation result of elasticity before migration, an evaluation result of migration before elasticity, and a direct migration evaluation result; the target evaluation result can also be any one of a direct elasticity evaluation result and an evaluation result of migration before elasticity (in this case, the situation of overselling of the host device is not considered, nor is the situation of direct migration of the target instance); the target evaluation result can also be any one of a direct elasticity evaluation result, an evaluation result of migration before elasticity, and a direct migration evaluation result (in this case, the situation of overselling of the host device is not considered); the target evaluation result can also be other feasibility evaluation results. That is to say, under the inventive concept of the embodiment of the present application, any target evaluation result type can be set, which can be determined according to actual conditions, and the embodiment of the present application does not limit it.
[0139] For example, because it is a private cloud environment, the database resource pool is deployed in a balanced load mode. In order to achieve the fastest migration, the instance (first instance or target instance) with the smallest amount of data (occupied storage resources) on the first host device will be selected for migration. The rule for selecting the migration destination device is to select the target host device with the largest remaining free resources. The specific migration method is as follows: Fig. 9 shown.
[0140] Depend on Fig. 9 It can be seen that the service device uses the target database instance resources on the first host device as a dynamic vector, which includes N1: CPU, N2: memory size, N3: fixed label, N4: storage space, and sorts all N4 vectors on the first host device in ascending order, and then selects the first N1~N3 instance that meets the requirements as the instance to be migrated (the first instance or the target instance); the second resource information of each target host device is used as a static vector, which includes S1: CPU allocation ratio (i.e., CPU idle resource ratio), S2: memory allocation ratio (i.e., memory idle resource ratio), S3: disk allocation ratio (i.e., disk idle resource ratio), S4: device label, first filter out the host devices in the S4 vector that do not meet the anti-affinity policy of the instance to be migrated, and perform weighted processing S=(S1+S2+S3) / 3 on the S1~S3 vectors of the remaining host devices, and select the target host device with the smallest S as the destination host device (i.e., the second host device or the third host device).
[0141] Fig.10 A structural block diagram of a database elastic device shown in an embodiment of the present disclosure is shown in FIG. Fig.10As shown, the device includes: a receiving module 1001 and a determining module 1002; the receiving module 1001 is used to receive an elastic request for a target database in a local disk, the target database including a first database as a standby database and a second database as a main database; the determining module 1002 is used to determine an elastic configuration scheme for the target database; wherein the elastic configuration scheme includes: elastic configuration processing on the first database to obtain a third database after configuration; performing master-slave switching on the third database and the second database, switching the third database to the main database of the target database, and switching the second database to the standby database of the target database; elastic configuration processing on the second database to obtain a fourth database after configuration, so as to obtain the target database after elastic configuration based on the third database as the main database and the fourth database as the standby database.
[0142] Optionally, the elastic request is a capacity expansion request, the elastic configuration change is a capacity expansion configuration change, the first host device includes a target instance corresponding to the target database, and the target instance includes at least one of the following: a first database, a second database; the device also includes: an acquisition module, which is used to obtain first resource information based on the capacity expansion request before determining the elastic configuration plan for the target database, the first resource information including the computing resources occupied by each instance on the first host device and the storage resources occupied by each instance, as well as the idle computing resources of the first host device, and the computing resource overload threshold of the first host device; the determination module 1002 is also used to determine the target evaluation result of capacity expansion configuration change for the target instance based on the first resource information.
[0143] Optionally, the target evaluation result includes any one of the following: a direct elasticity evaluation result, an elastic-first-then-migration evaluation result, a migration-first-then-elasticity evaluation result, and a direct migration evaluation result; wherein the direct elasticity evaluation result includes: the adjusted computing resources required for the target instance to expand and change its configuration are less than or equal to the idle computing resources of the first host device, and the elastic configuration scheme related to the target instance is executed on the first host device; the elastic-first-then-migration evaluation result includes: the adjusted computing resources are greater than the idle computing resources of the first host device and less than or equal to the target resources, and the elastic configuration scheme related to the target instance is first executed on the first host device, and then the first migration scheme is executed, the target resource is the sum of the idle computing resources of the first host device and the overload threshold of the computing resources, and the first migration scheme is executed. The migration plan is to migrate the first instance on the first host device from the first host device to the second host device; the migration-first-then-elastic evaluation result includes: the adjusted computing resources are greater than the target resources, and the storage resources occupied by the target instance are greater than or equal to the storage resources occupied by the first instance, and the first migration plan is first executed on the first host device, and then the plan related to the target instance in the elastic configuration plan is executed; the direct migration evaluation result includes: the adjusted computing resources are greater than the target resources, and the storage resources occupied by the target instance are less than the storage resources occupied by any second instance on the first host, and the plan related to the target instance in the elastic scheduling plan is executed while the second migration plan is executed. The second migration plan is to migrate the target instance from the first host device to the third host device.
[0144] Optionally, when the target evaluation result includes any one of the following: a direct elastic evaluation result, an elastic-first-then-migrate evaluation result, or a migrate-first-then-elastic evaluation result, the elastic configuration change processing is a delete-first-then-create processing.
[0145] Optionally, when the target evaluation result includes a direct migration evaluation result, the elastic configuration change process is a create-first-then-delete process.
[0146] Optionally, the target evaluation result includes any one of the following: an evaluation result of first-populate and then-migrate, an evaluation result of first-migrate and then-populate, and an evaluation result of direct migration; the acquisition module is further used to acquire, based on the capacity expansion request, second resource information corresponding to each target host device in at least one target host device in the resource pool, the second resource information including idle computing resources of the corresponding target host device; the determination module 1002 is further used to determine, when the target evaluation result is the evaluation result of first-populate and then-migrate or the evaluation result of first-migrate and then-populate, a first instance that meets the first condition from the instances on the first host device based on the first resource information and the second resource information, and determine from the at least one target host device A second host device that satisfies the second condition; the first condition includes: an instance whose occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device; the second condition includes: a target host device whose idle computing resources are greater than or equal to the computing resources occupied by the first instance; the determination module 1002 is also used to determine, when the target evaluation result is the direct migration evaluation result, a third host device that satisfies the third condition from the at least one target host device based on the first resource information and the second resource information; the third condition includes: a target host device whose idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources.
[0147] Optionally, the second resource information includes the idle storage resources of the corresponding target host device; when the target evaluation result is the first-populate-then-migrate evaluation result or the first-migrate-then-populate evaluation result, the first condition specifically includes any one of the following: among the instances where the occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device, the instance with the smallest occupied computing resources; the instance where the occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device, and the instance with the smallest occupied storage resources; the second condition specifically includes any one of the following: among the target host devices where the idle computing resources are greater than or equal to the computing resources occupied by the first instance, the instance with the smallest idle computing resources a target host device with a larger idle computing resource; a target host device with a maximum weighted value of idle computing resources and idle storage resources among target host devices whose idle computing resources are greater than or equal to the computing resources occupied by the first instance; when the target evaluation result is the direct migration evaluation result, the third condition specifically includes any one of the following: a target host device with a maximum idle computing resource among target host devices whose idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources; a target host device with a maximum weighted value of idle computing resources and idle storage resources among target host devices whose idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources.
[0148] Optionally, the first resource information also includes a fixed tag of each instance on the first host device, and the fixed tag is used to indicate the host device to which the corresponding instance is allowed to migrate; the second resource information also includes a device tag of the corresponding target host device; when the target evaluation result is the first-pop-up and then-migration evaluation result or the first-migration and then-pop-up evaluation result, the fixed tag of the first instance matches the device tag of the second host device; when the target evaluation result is the direct migration evaluation result, the fixed tag of the target instance matches the device tag of the third host device.
[0149] Optionally, the first migration plan includes: creating a first instance on the second host device; copying the remote backup data corresponding to the first instance to the idle storage resources of the second host device at the maximum network speed and maximum read and write speed of the container, and the remote backup data corresponding to the first instance is data updated within a preset period of time; pulling up the first instance; deleting the first instance on the first host device.
[0150] Optionally, the second migration plan includes: creating an expanded and reconfigured instance corresponding to the target instance on a third host device; copying the remote backup data corresponding to the target instance to the idle storage resources of the third host device at the maximum network speed and maximum read and write speed of the container, and the remote backup data corresponding to the target instance is data updated within the preset time period; pulling up the expanded and reconfigured instance; and deleting the target instance on the first host device.
[0151] Optionally, the first migration plan includes: creating a first instance on the second host device; copying data corresponding to the first instance on the first host device to the free storage resources of the second host device at a limited network speed and a limited read and write speed; pulling up the first instance; and deleting the first instance on the first host device.
[0152] Optionally, the second migration plan includes: creating an expanded and reconfigured instance corresponding to the target instance on a third host device; copying the data corresponding to the target instance on the first host device to the idle storage resources of the third host device at a limited network speed and a limited read and write speed; pulling up the expanded and reconfigured instance; and deleting the target instance on the first host device.
[0153] In the embodiment of the present application, each module of the database elasticity device can implement the database elasticity method provided by the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0154] Fig.11 A structural block diagram of a database elastic service system shown in an embodiment of the present disclosure is shown in FIG. Fig.11As shown, the system includes: a resource management microservice module 1101, configured to: receive a target request for a target database, the target request is an elastic request or an elastic evaluation request, and the target database includes a first database as a standby database and a second database as a main database; a data service module 1102, configured to: provide first resource information on a first host device where a target instance corresponding to the target database is located, the target instance includes at least one of the following: a first database, a second database; the first resource information includes computing resources occupied by each instance on the first host device and storage resources occupied by each instance, idle computing resources of the first host device, and a computing resource overload threshold of the first host device; a resource evaluation module Block 1103 is configured to: when the target request is a request related to capacity expansion and configuration change, based on the target request, obtain first resource information from the data service module, and determine the target evaluation result of capacity expansion and configuration change for the target instance according to the first resource information, and the target evaluation result includes any one of the following: direct elastic evaluation result, elastic first and then migration evaluation result, migration first and then elastic evaluation result, direct migration evaluation result; when the target request is an elastic evaluation request, send the target evaluation result to the resource management microservice module; resource pool data module 1104 is configured to: provide second resource information corresponding to each target host device in at least one target host device in the resource pool, and the second resource information includes The idle computing resources of the corresponding target host device; the scheduling strategy determination module 1105 is configured to: obtain the target evaluation result from the resource evaluation module; when the target evaluation result includes any one of the following: an evaluation result of first elastic and then migration, an evaluation result of first migration and then elastic, and a direct migration evaluation result, based on the target evaluation result and the second resource information obtained from the resource pool data module, determine the migration scheduling strategy corresponding to the migration scheme for expanding and changing the configuration of the target instance, the scheduling strategy includes the migration instance corresponding to the migration scheme, and the target host device to which the migration instance needs to be migrated; the resource scheduling module 1106 is configured to: when the target request is an elastic request corresponding to the shrinking and changing the configuration, execute The elastic scheduling policy corresponding to the scheme related to the target instance in the elastic configuration scheme; when the target request is a capacity expansion request and the target evaluation result is a direct elastic evaluation result, the elastic scheduling policy corresponding to the scheme related to the target instance in the elastic configuration scheme is executed; when the target request is a capacity expansion request and the target evaluation result includes any one of the following: an evaluation result of elastic first and then migration, an evaluation result of migration first and then elastic, and a direct migration evaluation result, the elastic scheduling policy corresponding to the scheme related to the target instance in the elastic configuration scheme is executed, and the migration scheduling policy corresponding to the target evaluation result is executed; wherein, the elastic configuration scheme includes: performing elastic configuration processing on the first database to obtain a third database after configuration;Perform active / standby switching on the third database and the second database, switch the third database to the active database of the target database, and switch the second database to the standby database of the target database; perform elastic configuration change processing on the second database to obtain a fourth database after configuration change, so as to obtain the target database after elastic configuration change based on the third database as the active database and the fourth database as the standby database. ;
[0155] In the embodiment of the present application, each module of the database elastic service system can implement the database elastic method provided by the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0156] In the embodiment of the present application, the rapid elasticity of the local disk form of the database under the cloud native architecture is mainly optimized, and a database elastic service system is introduced to be responsible for resource evaluation and output scheduling strategies. The scheduling strategy system will evaluate the best elastic plan based on the current resource usage and expected resource volume, and divide it into four scenarios, namely, the host resources where the cloud database is located are sufficient, the resources are insufficient but do not exceed the overload threshold, the resources are insufficient but there are better options, and the resources are insufficient but there are no better options. Different rapid elastic scheduling plans are made for different scenarios, and resource evaluation strategies, resource scheduling strategies, and resource scheduling methods are proposed.
[0157] like Fig.11 As shown, the database elastic service system request entry is in the resource management microservice module. After receiving the target request (capacity expansion assessment request or capacity expansion request) for the target database, the target request will be sent to the resource assessment module. After receiving the target request, the resource assessment module interacts with the data microservice module to obtain the instance resource information on the host device where the target database is located (for example, the first resource information on the first host device). The resource assessment module will make detailed resource assessment information based on the instance resource information on the host device where the target database is located (obtain the target assessment result. If the target request is a capacity expansion assessment request, the target assessment result will be returned to the resource management microservice module), and obtain the second resource information of each target host device in at least one target host device in the resource pool from the resource pool data module, and submit the target assessment result and at least one second resource information to the scheduling policy module. The scheduling policy module will submit the target assessment result and at least one second resource information to the scheduling policy module, decide on an optimal scheduling policy, and send the optimal scheduling policy to the resource scheduling module. The resource scheduling module performs corresponding resource scheduling according to the optimal scheduling policy.
[0158] Among them, the resource evaluation module mainly performs multi-dimensional resource evaluation according to relevant data, which is divided into host computing resource evaluation, storage resource evaluation, and resource pool resource evaluation. The resource evaluation of the local device (such as the first host device where the target instance is located) is an online evaluation. The local computing resources (CPU and memory) will be evaluated each time according to the evaluation request parameters. The resources occupied by the local instance will be subtracted during the evaluation. In order to maximize the local elasticity, all elastic operations of the local elasticity will follow the strategy of first deleting and then creating to maximize the utilization of local resources. Storage resource evaluation is an offline combination method. The local storage will calculate the real-time amount online, and non-local storage will use offline data. Resource pool resources all use offline data, and this part of the data is imported by the monitoring and collection module in time. The entire evaluation process is as follows Figure 7 As shown, there are four types of evaluation results.
[0159] Among them, the scheduling strategy module mainly executes the decision of scheduling strategy. The core of scheduling is to try not to move data, and to move as little as possible when it is necessary, so as to achieve elasticity in the most efficient way. This part mainly optimizes the scheduling strategy for the local machine that cannot complete the elasticity conditions, which is divided into three optimization strategies: the first is the strategy of first elasticity and then migration. For the scenario where the host does not exceed the load threshold, it will give priority to completing the elasticity of the local instance requirements, and then issue the offline migration scheduling task to achieve the final reachability; the second is the strategy of first migration and then elasticity. If the local machine cannot meet the elasticity conditions, it will evaluate all database instances on the local machine, find the most suitable instance for migration, perform data migration, and then perform local elasticity on the local instance; the third is the migration strategy for this instance. This instance is the most suitable instance for migration, and data migration scheduling and elastic scheduling will be performed for this instance.
[0160] For example, Fig.12 As shown, the decision-making process of the scheduling strategy module to execute the scheduling strategy includes:
[0161] 1201. Obtain target evaluation results.
[0162] 1202. Determine whether the target evaluation result is a direct elastic evaluation result.
[0163] If the target evaluation result is a direct elastic evaluation result, execute the following step 1203 , otherwise execute the following step 1204 .
[0164] 1203. Determine direct local resilience strategy.
[0165] 1204. Determine whether the target assessment result is a first-launch-then-migration assessment result.
[0166] If the target evaluation result is a first-populate-then-migrate evaluation result, execute the following step 1205; otherwise, execute the following step 1206.
[0167] 1205. Determine the elastic strategy of first rebound and then migrate.
[0168] 1206. Determine whether the target assessment result is a migration-before-redirection assessment result.
[0169] If the target evaluation result is a migration-before-rebound evaluation result, execute the following step 1207; otherwise, execute the following step 1208.
[0170] 1207. Determine the relocation-first-then-rebound strategy.
[0171] 1208. Determine the direct migration resilience strategy.
[0172] Among them, the resource scheduling module is an executor. It schedules instances according to the scheduling strategy generated by the scheduling strategy module. It is divided into local scheduling and migration scheduling. Local scheduling adopts the method of first deleting and then creating to ensure that local scheduling resources are sufficient to the greatest extent; migration scheduling adopts the method of backing up data first. After mounting the remote backup data locally, it quickly copies the data and pulls up the instance with the maximum network and IOPS of the container.
[0173] For example, if the standby database is 2c4g before and needs to be elastic to 4c8g, the direct elastic strategy, if the host device where the standby database is located has 2c4g of idle resources, then elasticity is performed directly on the first host device, first the standby database is changed to 4c8g, and the master-slave switch is performed. The original master database is elasticized in the same way, so there is no need to migrate data, and the overall time is about 1 minute; the elastic first and then migrate strategy, if the host device where the standby database is located has no 2c4g of idle resources, it is determined whether the host device exceeds the elastic strategy if the elastic strategy is performed on the host device. The pre-set overload threshold is exceeded. For example, if the resources of this host device are set to exceed 4c8g, the direct elastic policy is used to expand the capacity in the same way. After the expansion, a suitable instance is found on the host to migrate out. The migration-first-then-elastic solution is used. If the elastic policy is used on the host device and the host device exceeds the overload threshold and is not enough for expansion, first find an instance that is most suitable for migration and migrate it. After the migration, the direct elastic policy is used to expand the capacity of the standby database to be expanded in the same way. In the direct migration solution, the current standby database is the most suitable for migration, so the standby database is directly migrated out.
[0174] Fig.13 A structural diagram of a service device provided in an embodiment of the present disclosure is used to exemplarily illustrate a service device for implementing any database elasticity method in an embodiment of the present disclosure, and should not be understood as a specific limitation on the embodiment of the present disclosure.
[0175] like Fig.13As shown, the service device 1300 may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 1301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1302 or a program loaded from a storage device 1308 to a random access memory (RAM) 1303. Various programs and data required for the operation of the service device 1300 are also stored in the RAM 1303. The processor 1301, the ROM 1302, and the RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.
[0176] Typically, the following devices may be connected to the I / O interface 1305: input devices 1306 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 1307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1308 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1309. The communication devices 1309 may allow the service device 1300 to communicate wirelessly or wired with other devices to exchange data. Although the service device 1300 is shown with various devices, it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have instead.
[0177] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 1309, or installed from a storage device 1308, or installed from a ROM 1302. When the computer program is executed by the processor 1301, the functions defined in any method provided in the embodiment of the present disclosure can be executed.
[0178] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
Claims
1. A database elasticity method, characterized in that: include: Receiving an elastic request for a target database in a local disk, wherein the target database includes a first database as a standby database and a second database as a primary database; Determining a flexible configuration scheme for the target database; The elastic configuration scheme includes: performing elastic configuration processing on the first database to obtain a third database after configuration; Performing a master-slave switch on the third database and the second database, switching the third database to be the master database of the target database, and switching the second database to be the slave database of the target database; Performing elastic configuration change processing on the second database to obtain a fourth database after the configuration change, so as to obtain the target database after the elastic configuration change based on the third database as the main database and the fourth database as the standby database; Among them, in the case that the elastic request is a capacity expansion request and the elastic configuration change is a capacity expansion configuration change, the elastic configuration change plan is determined based on a target evaluation result of capacity expansion configuration change for the target instance, the target evaluation result is determined based on idle computing resources of a first host where the target instance is located, and adjustment computing resources required for capacity expansion configuration change for the target instance, the target evaluation result is used to indicate whether the target instance is elastically configured on the first host, and the target instance includes at least one of the following: the first database, the second database.
2. The method according to claim 1, characterized in that Before determining the elastic configuration scheme for the target database, the method further includes: Based on the capacity expansion request, first resource information is obtained, where the first resource information includes computing resources occupied by each instance on the first host device and storage resources occupied by each instance, as well as idle computing resources of the first host device, and a computing resource overload threshold of the first host device; A target evaluation result for expanding and reconfiguring the target instance is determined according to the first resource information.
3. The method according to claim 2, characterized in that The target assessment result includes any of the following: direct elasticity assessment result, elastic-first-then-migration assessment result, migration-first-then-elasticity assessment result, and direct migration assessment result; The direct elasticity assessment result includes: the adjusted computing resources required for the target instance to perform capacity expansion and configuration change are less than or equal to the idle computing resources of the first host device, and the solution related to the target instance in the elastic configuration change solution is executed on the first host device; The elastic-first-migration-later evaluation result includes: the adjusted computing resource is greater than the idle computing resource of the first host device and less than or equal to the target resource, the elastic configuration scheme related to the target instance is first executed on the first host device, and then the first migration scheme is executed, the target resource is the sum of the idle computing resource of the first host device and the computing resource overload threshold, and the first migration scheme is to migrate the first instance on the first host device from the first host device to the second host device; The migration-before-elasticity evaluation result includes: the adjusted computing resources are greater than the target resources, and the storage resources occupied by the target instance are greater than or equal to the storage resources occupied by the first instance, and the first migration solution is first executed on the first host device, and then the solution related to the target instance in the elastic configuration solution is executed; The direct migration evaluation result includes: the adjusted computing resources are greater than the target resources, and the storage resources occupied by the target instance are less than the storage resources occupied by any second instance on the first host, and while executing the second migration plan, the plan related to the target instance in the elastic configuration plan is executed, and the second migration plan is to migrate the target instance from the first host device to the third host device.
4. The method according to claim 3, characterized in that: In the case where the target evaluation result includes any of the following: a direct elastic evaluation result, an elastic first then migrate evaluation result, or a migrate first then elastic evaluation result, the elastic configuration change process is a delete first then create process; In the case where the target evaluation result includes a direct migration evaluation result, the elastic configuration change process is a create-before-delete process.
5. The method according to claim 3, characterized in that: The target assessment result includes any of the following: assessment result of first launching and then relocating, assessment result of first relocating and then launching, and assessment result of direct migration; The method further comprises: Based on the capacity expansion request, obtaining second resource information corresponding to each target host device in at least one target host device in the resource pool, wherein the second resource information includes idle computing resources of the corresponding target host device; In the case where the target evaluation result is the first-elasticity-then-migration evaluation result or the first-migration-then-elasticity evaluation result, based on the first resource information and the second resource information, the first instance satisfying the first condition is determined from the instances on the first host device, and the second host device satisfying the second condition is determined from the at least one target host device; the first condition includes: an instance whose occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device; the second condition includes: a target host device whose idle computing resources are greater than or equal to the computing resources occupied by the first instance; When the target evaluation result is the direct migration evaluation result, based on the first resource information and the second resource information, the third host device that meets the third condition is determined from the at least one target host device; the third condition includes: a target host device whose idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources.
6. The method according to claim 5, characterized in that The second resource information includes free storage resources of the corresponding target host device; When the target evaluation result is the first-strike-then-migration evaluation result or the first-migration-then-strike evaluation result, the first condition specifically includes any one of the following: Among the instances where the occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device, the instance where the occupied computing resources are the smallest; An instance whose occupied computing resources are greater than or equal to the difference between the adjusted computing resources and the idle computing resources of the first host device, and whose occupied storage resources are minimal; The second condition specifically includes any one of the following: Among the target host devices whose idle computing resources are greater than or equal to the computing resources occupied by the first instance, the target host device with the largest idle computing resources; a target host device having a maximum weighted value of idle computing resources and idle storage resources among target host devices whose idle computing resources are greater than or equal to the computing resources occupied by the first instance; When the target evaluation result is the direct migration evaluation result, the third condition specifically includes any one of the following: Among the target host devices whose idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources, the target host device with the largest idle computing resources; The target host device whose idle computing resources are greater than or equal to the sum of the computing resources occupied by the target instance and the adjusted computing resources is the target host device with the largest weighted value of idle computing resources and idle storage resources.
7. The method according to claim 6, characterized in that The first resource information further includes a fixed tag for each instance on the first host device, the fixed tag being used to indicate a host device to which the corresponding instance is allowed to migrate; The second resource information also includes a device tag of a corresponding target host device; In a case where the target evaluation result is the first-bounce-then-migrate evaluation result or the first-migrate-then-bounce evaluation result, the fixed tag of the first instance matches the device tag of the second host device; In a case where the target evaluation result is the direct migration evaluation result, the fixed tag of the target instance matches the device tag of the third host device.
8. The method according to any one of claims 3 to 7, characterized in that The first migration solution includes: creating the first instance on the second host device; Copying the remote backup data corresponding to the first instance to the idle storage resources of the second host device at the maximum network speed and the maximum read and write speed of the container, wherein the remote backup data corresponding to the first instance is data updated within a preset period of time; Pull up the first instance; deleting the first instance on the first host device; The second migration solution includes: Creating an instance after expansion and configuration change corresponding to the target instance on the third host device; Copying the remote backup data corresponding to the target instance to the idle storage resources of the third host device at the maximum network speed and the maximum read and write speed of the container, wherein the remote backup data corresponding to the target instance is data updated within the preset time period; Pull up the instance after the expansion and configuration change; The target instance on the first host device is deleted.
9. A database elastic device, characterized in that: The device comprises: a receiving module and a determining module; The receiving module is used to receive an elastic request for a target database in a local disk, wherein the target database includes a first database as a standby database and a second database as a master database; The determination module is used to determine the elastic configuration scheme for the target database; The elastic configuration scheme includes: performing elastic configuration processing on the first database to obtain a third database after configuration; Performing a master-slave switch on the third database and the second database, switching the third database to be the master database of the target database, and switching the second database to be the slave database of the target database; Performing elastic configuration change processing on the second database to obtain a fourth database after the configuration change, so as to obtain the target database after the elastic configuration change based on the third database as the main database and the fourth database as the standby database; Among them, in the case that the elastic request is a capacity expansion request and the elastic configuration change is a capacity expansion configuration change, the elastic configuration change plan is determined based on a target evaluation result of capacity expansion configuration change for the target instance, the target evaluation result is determined based on idle computing resources of a first host where the target instance is located, and adjustment computing resources required for capacity expansion configuration change for the target instance, the target evaluation result is used to indicate whether the target instance is elastically configured on the first host, and the target instance includes at least one of the following: the first database, the second database.
10. A database elastic service system, characterized in that: The system comprises: The resource management microservice module is configured to: receive a target request for a target database, the target request being an elasticity request or an elasticity assessment request, the target database including a first database as a standby database and a second database as a primary database; The data service module is configured to: provide first resource information on a first host device where a target instance corresponding to the target database is located, the target instance including at least one of the following: the first database, the second database; the first resource information includes computing resources occupied by each instance on the first host device and storage resources occupied by each instance, idle computing resources of the first host device, and a computing resource overload threshold of the first host device; The resource evaluation module is configured to: when the target request is a request related to capacity expansion and configuration change, based on the target request, obtain the first resource information from the data service module, and determine a target evaluation result for capacity expansion and configuration change of the target instance according to the first resource information, wherein the target evaluation result includes any one of the following: a direct elastic evaluation result, an elastic-first-then-migration evaluation result, a migration-first-then-elastic evaluation result, and a direct migration evaluation result; In the case where the target request is an elastic evaluation request, sending the target evaluation result to the resource management microservice module; The resource pool data module is configured to: provide second resource information corresponding to each target host device in at least one target host device in the resource pool, wherein the second resource information includes idle computing resources of the corresponding target host device; The scheduling strategy determination module is configured to: obtain the target evaluation result from the resource evaluation module; In the case where the target evaluation result includes any one of the following: an evaluation result of first-elasticity and then-migration, an evaluation result of first-migration and then-elasticity, and an evaluation result of direct migration, based on the target evaluation result and the second resource information obtained from the resource pool data module, determining a migration scheduling strategy corresponding to a migration scheme for expanding and changing the configuration of the target instance, the scheduling strategy including a migration instance corresponding to the migration scheme, and a target host device to which the migration instance needs to be migrated; The resource scheduling module is configured to: when the target request is an elastic request corresponding to the scaling-down configuration change, execute an elastic scheduling strategy corresponding to the solution related to the target instance in the elastic configuration change solution; When the target request is a capacity expansion request and the target evaluation result is a direct elastic evaluation result, executing an elastic scheduling strategy corresponding to a solution related to the target instance in the elastic configuration change solution; When the target request is a capacity expansion request, and the target evaluation result includes any one of the following: an evaluation result of elastic first and then migrate, an evaluation result of migrate first and then elastic, and an evaluation result of direct migration, the elastic scheduling strategy corresponding to the scheme related to the target instance in the elastic configuration scheme is executed, and the migration scheduling strategy corresponding to the target evaluation result is executed; The elastic configuration scheme includes: performing elastic configuration processing on the first database to obtain a third database after configuration; Performing a master-slave switch on the third database and the second database, switching the third database to be the master database of the target database, and switching the second database to be the slave database of the target database; The second database is elastically reconfigured to obtain a fourth database after the reconfiguration, so as to obtain the target database after the elastic reconfiguration based on the third database as the primary database and the fourth database as the standby database.
Citation Information
Patent Citations
Server capacity expanding method and device
CN109586952A
Elastic capacity expansion and shrinkage method and device for graph database, equipment and storage medium
CN112115311A