Database creation method and apparatus, storage medium

By establishing multiple storage containers in multiple container service clusters, the problem of limited storage capacity within Kubernetes was solved, enabling the expansion of database storage capacity and high availability management across clusters.

CN116467282BActive Publication Date: 2026-02-13XIAN TONGXING HENGYAO INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310396333.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-12
Publication Date
2026-02-13
Estimated Expiration
2043-04-12

AI Technical Summary

Technical Problem

In existing technologies, Kubernetes custom extended resources and operator methods can only manage databases within a single cluster, resulting in limited storage capacity for the created databases.

Method used

By establishing multiple storage containers in multiple container service clusters, and utilizing management services to build the target database according to database creation parameters, storage capacity can be expanded.

Benefits of technology

It increases the storage capacity of the target database, enables cross-cluster storage expansion, and supports high availability and lifecycle management of the database across multiple clusters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116467282B_ABST
    Figure CN116467282B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a database creation method and device, and a storage medium, comprising the following steps: in the case that a creation instruction of a target database is received, determining a plurality of container service clusters and database creation parameters corresponding to the target database from the creation instruction; using a management and control service, establishing at least one storage container in each of the plurality of container service clusters according to the database creation parameters, to obtain a plurality of storage containers; and constructing the target database by using the plurality of storage containers.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database creation, and particularly relates to a database creation method and device and a storage medium. BACKGROUND

[0002] With the advent of the cloud native era, the application of a container orchestration management platform (Kubernetes, K8s) is more and more widespread, such as application in the field of databases, specifically, database containerization in the data field and database clouding.

[0003] In the related art, a CustomResourceDefinitions (CRD) is defined by using a K8s self-defined extension resource, a high-availability life cycle management of a database in a K8s environment is implemented by using an operator in compliance with a running mechanism of the K8s and a requirement of the database itself, since the K8s CRD is only for resources in a K8s cluster, and the operator can also only manage CRD resources in the cluster, so that a database can only be established in a certain K8s cluster, and thus the storage capacity of the created database is reduced, that is, the storage capacity of the created target database is reduced. SUMMARY

[0004] To solve the above technical problems, the embodiments of the present application expect to provide a database creation method and device and a storage medium, which can improve the storage capacity of a created target database.

[0005] The technical scheme of the present application is implemented as follows:

[0006] The embodiments of the present application provide a database creation method, which comprises the following steps:

[0007] In a case where a creation instruction of a target database is received, a plurality of container service clusters corresponding to the target database and database creation parameters are determined from the creation instruction;

[0008] At least one storage container is established in each of the plurality of container service clusters according to the database creation parameters by using a management and control service, to obtain a plurality of storage containers;

[0009] The target database is constructed by using the plurality of storage containers.

[0010] The embodiments of the present application provide a database creation device, which comprises the following units:

[0011] An acquisition unit is configured to, in a case where a creation instruction of a target database is received, determine a plurality of container service clusters corresponding to the target database and database creation parameters from the creation instruction;

[0012] establishing unit, configured to establish at least one storage container in each of the plurality of container service clusters according to the database creation parameters by using the management and control service, to obtain a plurality of storage containers; and construct the target database by using the plurality of storage containers.

[0013] The embodiment of the present application provides a database creation device, and the device comprises:

[0014] a memory, a processor and a communication bus, the memory communicates with the processor through the communication bus, the memory stores a database creation program executable by the processor, and when the database creation program is executed, the database creation method described above is executed by the processor.

[0015] The embodiment of the present application provides a storage medium, and the storage medium stores a computer program, and is applied to a database creation device, and the computer program is executed by a processor to implement the database creation method described above.

[0016] The embodiment of the present application provides a database creation method and device and a storage medium, and the database creation method comprises the following steps: in the case that a creation instruction of a target database is received, determining a plurality of container service clusters corresponding to the target database and database creation parameters from the creation instruction; establishing at least one storage container in each of the plurality of container service clusters according to the database creation parameters by using a management and control service, to obtain a plurality of storage containers; and constructing the target database by using the plurality of storage containers. By using the method, in the case that the creation instruction of the target database is received, the management and control service determines the plurality of container service clusters corresponding to the target database and the database creation parameters from the creation instruction, that is, determines in which container service clusters the target database is established and the creation parameters when the target database is established; the management and control service can create a storage container meeting the database creation parameters in each of the plurality of service clusters according to the database creation parameters, thereby obtaining the plurality of storage containers, and the plurality of storage containers are established in the plurality of container service clusters, so that the storage space is expanded by using the plurality of container service clusters in the case that the storage space provided by each container service cluster is limited; the plurality of storage containers are used to construct the target database, and the expanded target database is obtained, that is, the storage capacity of the created target database is improved. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 A database creation method flowchart is provided for the embodiment of the present application.

[0018] Figure 2An exemplary schematic diagram of a database creation method provided by an embodiment of the present application is shown in FIG. 1. The database creation method can include the following steps.

[0019] Figure 3 An exemplary schematic diagram of a database creation method provided by an embodiment of the present application is shown in FIG. 1. The database creation method can include the following steps.

[0020] Figure 4 An exemplary schematic diagram of a database creation method provided by an embodiment of the present application is shown in FIG. 1. The database creation method can include the following steps.

[0021] Figure 5 An exemplary schematic diagram of a database creation method provided by an embodiment of the present application is shown in FIG. 1. The database creation method can include the following steps. Figure 1 ;

[0022] Figure 6 An exemplary schematic diagram of a database creation method provided by an embodiment of the present application is shown in FIG. 1. The database creation method can include the following steps. Figure 2 . DETAILED DESCRIPTION

[0023] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0024] The present application provides a database creation method, and the database creation method is applied to a database creation apparatus, Figure 1 An exemplary schematic diagram of a database creation method provided by an embodiment of the present application is shown in FIG. 1. The database creation method can include the following steps. Figure 1

[0025] S101, in the case of receiving a creation instruction of a target database, determining a plurality of container service clusters corresponding to the target database and database creation parameters from the creation instruction.

[0026] The database creation method provided by the embodiment of the present application is suitable for the scenario of creating a target database in a container service cluster.

[0027] In the embodiments of the present application, the database creation apparatus can be implemented in various forms. For example, the database creation apparatus described in the present application can include devices such as mobile phones, cameras, tablets, laptops, palmtop computers, personal digital assistants (PDAs), portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, and the like, as well as devices such as digital TVs, desktop computers, servers, and the like.

[0028] ​In the embodiment of the present application, the database creation device includes a management service. In the case of receiving the creation instruction of the target database, the management service determines the plurality of container service clusters corresponding to the target database and the database creation parameters from the creation instruction.

[0029] In the embodiment of the present application, the plurality of container service clusters can be a plurality of K8s clusters, or other clusters that can provide storage space. The specific determination can be made according to actual conditions, and the embodiment of the present application does not limit this.

[0030] In the embodiment of the present application, the creation instruction carries the information of the plurality of container service clusters and the data creation parameters, and the database creation device can directly determine the plurality of container service clusters and the data creation parameters from the creation instruction.

[0031] In the embodiment of the present application, the database creation parameters include the number of storage containers created in each container service cluster in the plurality of container service clusters, which container service clusters in the plurality of container service clusters create storage containers including master storage blocks and slave storage blocks, the number of storage containers of the master storage blocks, the number of storage containers of the slave storage blocks, and the like.

[0032] In the embodiment of the present application, the database creation device includes an information acquisition interface of the target server, and can receive the creation instruction of the target server transmitted by the user through the information acquisition interface, or can obtain the creation instruction of the target server transmitted by other devices through the information transmission interface. The specific way in which the database creation device receives the creation instruction of the target database can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0033] S102, using the management service, establishing at least one storage container in each container service cluster in the plurality of container service clusters according to the database creation parameters, to obtain a plurality of storage containers.

[0034] In the embodiment of the present application, after the database creation device determines the plurality of container service clusters corresponding to the target database and the database creation parameters from the creation instruction, the management service can be used to establish at least one storage container in each container service cluster in the plurality of container service clusters according to the database creation parameters, to obtain a plurality of storage containers.

[0035] In the embodiment of the present application, in the case of the container service cluster being a K8s cluster, the storage container can be a pod.

[0036] In the embodiment of the present application, the process of establishing at least one storage container in each of the plurality of container service clusters according to the database creation parameters by using the management and control service includes: obtaining the first number of master storage blocks, the second number of slave storage blocks, the first container service cluster corresponding to the master storage blocks and the second container service cluster corresponding to the slave storage blocks from the database creation parameters; establishing the first number of first storage containers in the first container service cluster by using the management and control service, wherein the first storage containers include the master storage blocks; establishing the second number of second storage containers in the second container service cluster by using the management and control service, wherein the second storage containers include the slave storage blocks; and obtaining the plurality of storage containers according to the first storage containers and the second storage containers.

[0037] In the embodiment of the present application, the number value of the first number can be 1 or other numerical values, which can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0038] In the embodiment of the present application, in the case that the container service cluster is a K8s cluster and the storage container is a pod, the storage block can be a DoggaByte (DB).

[0039] It should be noted that one pod includes one DB.

[0040] In the embodiment of the present application, the pod (including the first storage container and the second storage container) can be created by calling the kubernetes APIServer or through helm, or the pod can be created in K8s by other ways, and the specific way of creating the pod in K8s can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0041] It should be noted that the first storage container is a storage container provided with a master storage block, and the second storage container is a storage container provided with a slave storage block.

[0042] In the embodiment of the present application, the first storage container and the second storage container form the plurality of storage containers. After obtaining the plurality of storage containers, the failure restart parameter of the plurality of storage blocks in the plurality of storage containers can be obtained as no restart (i.e. restartPolicy: Nerver) from the database creation parameters, and the failure restart parameter of the plurality of storage blocks can be set as no restart.

[0043] In the embodiment of the present application, each of the plurality of storage containers further includes a master thread; and the database creation device can use the plurality of master threads to set the association between the master storage blocks and the slave storage blocks.

[0044] In the embodiments of the present application, the association relationship between the master storage blocks and the slave storage blocks is set by using multiple master threads, which can set the slave storage blocks corresponding to each master storage block, and in the case where one master storage block corresponds to multiple slave storage blocks, which of the slave storage blocks has a strong consistent association relationship with the master storage block.

[0045] It should be noted that the association relationship parameters between the master storage blocks and the slave storage blocks are included in the database creation parameters, and the association relationship between the master storage blocks and the slave storage blocks can be set by using multiple master threads according to the association relationship parameters.

[0046] For example, two master storage blocks (DB0, DB2) correspond to six slave storage blocks (DB3, DB4, DB5, DB6, DB7, DB8), wherein the association relationship parameters between the master storage blocks and the slave storage blocks are that the slave storage blocks corresponding to the master storage block DB0 are DB3 and DB4, the slave storage blocks corresponding to the master storage block DB1 are DB5, DB6, DB7 and DB8, the association relationship between DB0 and DB3 is strong consistent, and the association relationship between DB1 and DB7 is strong consistent, then the slave storage blocks corresponding to the master storage block DB0 are set by using the master thread according to the association relationship, and the slave storage blocks are DB3 and DB4, wherein the association relationship between DB0 and DB3 is strong consistent; the slave storage blocks corresponding to the master storage block DB1 are set by using the master thread according to the association relationship, and the slave storage blocks are DB5, DB6, DB7 and DB8, wherein the association relationship between DB1 and DB7 is strong consistent.

[0047] In the embodiments of the present application, in the case where the container service cluster is a K8s cluster and the storage container is a pod, the master thread can be an agent in the pod.

[0048] It should be noted that the pod includes an agent and a storage block (DB), and the agent is used to communicate with the management end (management service). Through the agent, the management service controls the deployment of the database instance and the establishment of the master-slave relationship state, such as Figure 2As shown: in the case of receiving the creation instruction of the target database, the management and control service determines the plurality of container service clusters corresponding to the target database and the database creation parameters from the creation instruction; from the database creation parameters, the first number of master storage blocks, the second number of slave storage blocks, the first container service cluster corresponding to the master storage blocks and the second container service cluster corresponding to the slave storage blocks are obtained; using the management and control service, in the first container service cluster (kubernetes1), the kubernetes APIServer is called or the first number of first storage containers (pod0) are established through helm, and the first storage containers include the master storage blocks (DB0); using the management and control service, in the second container service cluster (kubernetes1 and kubernetes2), the kubernetes APIServer is called or the second number of second storage containers (pod1 and pod2) are created through helm, and the second storage containers include the slave storage blocks (DB1 and DB2); according to the first storage containers and the second storage containers, the plurality of storage containers are obtained.

[0049] S103, constructing the target database by using the plurality of storage containers.

[0050] In the embodiment of the present application, the database creation device uses the management and control service to establish at least one storage container in each container service cluster in the plurality of container service clusters according to the database creation parameters, and obtains the plurality of storage containers. After obtaining the plurality of storage containers, the target database can be constructed by using the plurality of storage containers.

[0051] In the embodiment of the present application, the way in which the database creation device constructs the target database by using the plurality of storage containers can be that the target database is composed of the plurality of storage containers.

[0052] In the embodiment of the present application, after the database creation device constructs the target database by using the plurality of storage containers, in the case that the first alive detection time is reached, the high availability service is used to perform alive detection on the plurality of storage blocks in the plurality of storage containers to obtain a plurality of alive detection results; in the case that the first alive detection result in the plurality of alive detection results is not active, a first storage block corresponding to the first alive detection result is determined; in the case that the first storage block is a storage block in the at least one master storage block, a second storage block is determined from the plurality of slave storage blocks in the plurality of storage blocks; a third storage block is established; and the target database is updated by using the third storage block and the second storage block to obtain an updated target database.

[0053] In the embodiment of the present application, the database creation device further comprises a high availability service.

[0054] It should be noted that the first alive result is part of the plurality of alive results; the first alive result is the alive result of the first storage block, and the first storage block is part of the primary storage blocks.

[0055] It should be noted that the number of the plurality of slave storage blocks is a second number, the number of the at least one primary storage block is a first number, the plurality of slave storage blocks and the at least one primary storage block form a plurality of storage blocks, and the second storage block is any one of the plurality of slave storage blocks.

[0056] In the embodiment of the present application, the first alive detection time can be a time point configured in the database creation device, or a time point transmitted to the database creation device by other equipment; the specific way of obtaining the first alive detection time can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0057] In the embodiment of the present application, a first alive detection time can be set every preset time period, wherein the length of the preset time period can be 5 seconds, 1 second, or other lengths, which can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0058] In the embodiment of the present application, in the case that the first alive result in the plurality of alive results is active, the next first alive detection time is waited for, and the plurality of storage blocks in the plurality of storage containers are detected again by the high-availability service at the arrival of the next first alive detection time.

[0059] In the embodiment of the present application, the way of determining the second storage block from the plurality of slave storage blocks in the plurality of storage blocks can be that the management and control service preferentially selects a storage block that is in the same machine room and network segment as the first storage block and has small master-slave replication delay from the plurality of slave storage blocks as the second storage block. In the case that there is no storage block that is in the same priority as the first storage block, in the same machine room and network segment as the first storage block, and has small master-slave replication delay from the plurality of slave storage blocks, the priority can be lowered, and then a storage block that is in the same machine room and network segment as the first storage block and has small master-slave replication delay is selected from the plurality of slave storage blocks as the second storage block.

[0060] In the embodiment of the present application, the process of establishing the third storage block can be to call the kubernetesAPIServer or establish the third storage block (DB) through the helm, or other ways can be used to establish the third storage block; the specific way can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0061] In the embodiment of the present application, the process that the database creation apparatus updates the target database by using the third storage block and the second storage block to obtain the updated target database comprises: updating at least one master storage block by using the second storage block to obtain at least one updated master storage block; deleting the first storage block and obtaining the backup storage information corresponding to the first storage block; adding the backup storage information to the third storage block to obtain a fourth storage block; updating a plurality of slave storage blocks by using the fourth storage block to obtain a plurality of updated slave storage blocks; and updating the target database by using the at least one updated master storage block and the plurality of updated slave storage blocks to obtain the updated target database.

[0062] In the embodiment of the present application, the process that the database creation apparatus updates at least one master storage block by using the second storage block to obtain at least one updated master storage block can be that, in the case that the number of master storage blocks is one, the second storage block is taken as a master storage block to obtain at least one updated master storage block; and in the case that the number of master storage blocks is two or more, the second storage block is added to at least one master storage block to obtain at least one updated master storage block.

[0063] In the embodiment of the present application, the first storage block is a master storage block, and there is a target slave storage block having a strong consistent association relationship with the first storage block; and the process that the database creation apparatus obtains the backup storage information corresponding to the first storage block can be that the backup storage information corresponding to the first storage block is obtained from the target slave storage block.

[0064] In the embodiment of the present application, the process that the database creation apparatus updates a plurality of slave storage blocks by using the fourth storage block to obtain a plurality of updated slave storage blocks can be that the fourth storage block is added to the plurality of slave storage blocks to obtain a plurality of updated slave storage blocks.

[0065] In the embodiment of the present application, after the database creation apparatus determines the first storage block corresponding to the first ping result, in the case that the first storage block is a storage block in the plurality of slave storage blocks, the database creation apparatus detects the association relationship between the first storage block and at least one master storage block; in the case that the association relationship between the first storage block and a target storage block in the at least one master storage block is a non-strong consistent association relationship, the database creation apparatus deletes the first storage block and establishes a third storage block; the database creation apparatus obtains the backup storage information corresponding to the first storage block and adds the backup storage information to the third storage block to obtain a fourth storage block; and the database creation apparatus updates a plurality of slave storage blocks in the target database by using the fourth storage block to obtain an updated target database.

[0066] It should be noted that the target storage block is any one of the at least one primary storage block. In the case where the number of primary storage blocks is one, the target storage block is the first storage block. In the case where the number of primary storage blocks is two or more, the target storage block can be the same as the first storage block, or the target storage block can be two storage blocks different from the first storage block.

[0067] In the embodiment of the present application, the manner of detecting the association relationship between the first storage block and the at least one primary storage block is the prior art, that is, the association relationship between the first storage block and the at least one primary storage block can be detected by using the manner in the prior art, and the specific implementation process is not limited in the embodiment of the present application.

[0068] In the embodiment of the present application, after the database creation apparatus detects the association relationship between the first storage block and the at least one primary storage block, before the first storage block is deleted, in the case where the strong consistent association relationship exists between the first storage block and the target storage block, the read-write operation on the target storage block is downgraded to obtain a downgraded target storage block. Correspondingly, the process of updating the plurality of slave storage blocks in the target database by using the fourth storage block to obtain the updated target database includes: updating the target database by using the fourth storage block and the target storage block to obtain the updated target database.

[0069] In the embodiment of the present application, the manner of downgrading the read-write operation on the target storage block is the manner in the prior art, and the specific implementation manner is not limited in the embodiment of the present application.

[0070] In the embodiment of the present application, after the database creation apparatus constructs the target database by using the plurality of storage containers, in the case where the second alive detection time is reached, the alive detection of the target database is performed by using the high-availability service to obtain the alive detection result of the target database. In the case where the alive detection result of the target database indicates that the target database does not have the activity, the failover operation is performed on the target database, and a new target database is established according to the storage information in the target database. In the case where the alive detection result of the target database indicates that the target database has the activity, the next second alive detection time is waited for, so as to perform the alive detection of the target database again when the next second alive detection time is reached.

[0071] In the embodiment of the present application, the second alive detection time can be a time point configured in the database creation apparatus, or a time point transmitted to the database creation apparatus by another device. The specific manner of obtaining the second alive detection time can be determined according to actual conditions, and the embodiment of the present application is not limited in this regard.

[0072] In the embodiment of the present application, a third alive detection time can be set every preset time period.

[0073] In the embodiment of the present application, the alive detection of the target database by using the high-availability service can be detecting the database port of the target database by using the high-availability service, or connecting the target database, and other ways of alive detection of the target database can also be used, which can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0074] In the embodiment of the present application, the target database is executed for failover operation, and the new target database is established according to the storage information in the target database. The way can be establishing a first database; obtaining the storage information in the target database, and adding the storage information in the target database to the first database to obtain a new target database; and deleting the target database.

[0075] In the embodiment of the present application, after the database creation device constructs the target database by using a plurality of storage containers, the alive detection of the availability of the target database is performed by using the high-availability service when the third alive detection time is reached, and the alive detection result of the availability is obtained. In the case where the alive detection result of the availability indicates that the availability of the target database does not have activity, an alarm information is generated and outputted; in the case where the alive detection result indicates that the availability of the target database has activity, the next third alive detection time is waited for, and the alive detection of the availability of the target database is performed again when the next third alive detection time is reached.

[0076] In the embodiment of the present application, the alarm information can be character information, the alarm information can also be voice information, the alarm information can also be image information, and the alarm information can also be other forms of information, which can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0077] In the embodiment of the present application, the third alive detection time can be a time point configured in the database creation device, or a time point transmitted to the database creation device by other devices. The specific way of obtaining the third alive detection time can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0078] In the embodiment of the present application, a third alive detection time can be set every preset time period.

[0079] In the embodiment of the present application, the alive detection of the availability of the target database by using the high-availability service can be performing a query operation on the target database by using the high-availability service, and other ways of alive detection of the availability of the target database can also be used, which can be determined according to actual conditions, and the embodiment of the present application does not limit this.

[0080] In the embodiments of the present application, as shown in the figure: Figure 3 Using the management and control service, in the first container service cluster (kubernetes1), the first number of first storage containers (pod0) are created by calling the kubernetes APIServer or by helm, and the first storage containers include the master storage block (DB0); using the management and control service, in the second container service cluster (kubernetes1 and kubernetes2), the second number of second storage containers (pod1 and pod2) are created by calling the kubernetes APIServer or by helm, and the second storage containers include the slave storage blocks (DB1 and DB2); after obtaining the plurality of storage containers according to the first storage containers and the second storage containers, the high-availability service probes the health of the database every few seconds in multiple dimensions, such as the health of the pod, the health of the database, and the availability of the database, and reports the results to the management and control service for unified analysis. If pod0 is down, since the pod parameter restartPolicy is set to Never when creating the resource, the pod will not be automatically restored, and the management and control end judges that pod0 is down. If DB0 is the master library, the management and control service will select a new master library from other slave instances in the high-availability group, and then perform failover operation through the high-availability service to ensure the high availability of the database. After completing the failover operation, the management and control end initiates a request to destroy pod0, uses the high-availability service to perform the destruction operation, and then rebuilds pod0, deploys the database instance through the agent, then pulls the backup from the backup set of the high-availability group to restore DB0, and then adds the healthy DB0 as a slave to the high-availability group. If DB0 is a slave, it will check whether the master-slave synchronization is strongly consistent. If it is strongly consistent, first perform a degradation operation to ensure the availability of the master, then destroy pod0, rebuild pod0, deploy the database instance through the agent, then pull the backup from the backup set of the high-availability group to restore DB0, and then add the healthy DB0 as a slave to the high-availability group.

[0081] In the embodiments of the present application, after the database creation device constructs the target database using the plurality of storage containers, in the case of receiving a destruction instruction for the target database, the plurality of storage containers are deleted in the plurality of container service clusters.

[0082] In the embodiments of the present application, in the case of receiving a destruction instruction for the target database, the management and control service initiates a request to destroy the pod resource (the plurality of storage containers) through the kubernetes APIServer or helm to complete the recycling of the resource.

[0083] As shown in the examples Figure 4 In the case where the database creation device receives a creation instruction of a target database, the management and control service determines a plurality of container service clusters corresponding to the target database and database creation parameters from the creation instruction; the management and control service establishes at least one storage container in each of the plurality of container service clusters according to the database creation parameters through the kubernetes APIServer or the helm mode, to obtain a plurality of storage containers; and the plurality of storage containers are used to build the target database. Then, the high-availability service performs a live detection on a plurality of storage blocks in the plurality of storage containers, a live detection on the target database, and a live detection on the availability of the target database, so as to realize the life cycle management of the cross-kubernetes cluster database through the centralized database management and control service, enable the instances with different roles under the same high-availability group to be distributed in different kubernetes clusters and guarantee the database consistency, and realize the complete database life cycle management.

[0084] It should be noted that, in terms of database off-site disaster recovery, in the case where the bottom kubernetes cluster is not deployed across machine rooms and each set of kubernetes cluster is only deployed in the same machine room, the off-site disaster recovery at the database level can be completed, the database instances of the same high-availability group can be distributed in different machine rooms, and the life cycle management can be completed.

[0085] It can be understood that, in the case where the database creation device receives a creation instruction of a target database, the management and control service determines a plurality of container service clusters corresponding to the target database and database creation parameters from the creation instruction, that is, determines in which container service clusters to establish the target database and the creation parameters for establishing the target database; so that the management and control service can create a storage container meeting the database creation parameters in each service cluster in the plurality of service clusters according to the database creation parameters, to obtain a plurality of storage containers. Since the plurality of storage containers are established in the plurality of container service clusters, in the case where the storage space provided by each container service cluster is limited, the plurality of container service clusters are used to expand the storage space; the plurality of storage containers are used to form the target database, to obtain an expanded target database, that is, to improve the storage capacity of the created target database.

[0086] Based on the same inventive concept as the above database creation method, the embodiment of the present application provides a database creation device 1 corresponding to a database creation method; Figure 5 The composition structure of a database creation device provided by the embodiment of the present application is shown in Figure 1 The database creation device 1 can include:

[0087] The obtaining unit 11 is configured to, in response to receiving a creation instruction of a target database, determine, from the creation instruction, a plurality of container service clusters corresponding to the target database and database creation parameters;

[0088] The establishing unit 12 is configured to, by using a management service, establish at least one storage container in each of the plurality of container service clusters according to the database creation parameters, to obtain a plurality of storage containers, and construct the target database by using the plurality of storage containers.

[0089] In some embodiments of the present application, the obtaining unit 11 is configured to obtain, from the database creation parameters, a first quantity of master storage blocks, a second quantity of slave storage blocks, a first container service cluster corresponding to the master storage blocks, and a second container service cluster corresponding to the slave storage blocks.

[0090] The establishing unit 12 is configured to, by using the management service, establish a first quantity of first storage containers in the first container service cluster, wherein the first storage containers include the master storage blocks; by using the management service, establish a second quantity of second storage containers in the second container service cluster, wherein the second storage containers include the slave storage blocks; and obtain the plurality of storage containers according to the first storage containers and the second storage containers.

[0091] In some embodiments of the present application, each of the plurality of storage containers further includes a master thread; and the apparatus further includes a setting unit.

[0092] The setting unit is configured to set, by using the plurality of master threads, an association relationship between the master storage blocks and the slave storage blocks.

[0093] In some embodiments of the present application, the apparatus further includes a detecting unit, a determining unit, and an updating unit.

[0094] The detecting unit is configured to, in response to a first alive detection time being reached, perform alive detection on a plurality of storage blocks in the plurality of storage containers by using a high-availability service, to obtain a plurality of alive detection results.

[0095] The determining unit is configured to determine a first storage block corresponding to a first live detection result in a case where the first live detection result is not active, the first live detection result being part of the plurality of live detection results, and the first live detection result being a live detection result of the first storage block; in a case where the first storage block is a storage block in at least one master storage block, determine a second storage block from a plurality of slave storage blocks in the plurality of storage blocks, the number of the plurality of slave storage blocks being a second number, the number of the at least one master storage block being a first number, the plurality of slave storage blocks and the at least one master storage block constituting the plurality of storage blocks, and the second storage block being any one of the plurality of slave storage blocks.

[0096] The establishing unit 12 is configured to establish a third storage block.

[0097] The updating unit is configured to update the target database by using the third storage block and the second storage block to obtain an updated target database.

[0098] In some embodiments of the present application, the device further comprises a deleting unit and an adding unit.

[0099] The updating unit is configured to update the at least one master storage block by using the second storage block to obtain at least one updated master storage block, update the plurality of slave storage blocks by using the fourth storage block to obtain a plurality of updated slave storage blocks, and update the target database by using the at least one updated master storage block and the plurality of updated slave storage blocks to obtain an updated target database.

[0100] The deleting unit is configured to delete the first storage block.

[0101] The obtaining unit 11 is configured to obtain backup storage information corresponding to the first storage block.

[0102] The adding unit is configured to add the backup storage information into the third storage block to obtain a fourth storage block.

[0103] In some embodiments of the present application, the detecting unit is configured to detect an association relationship between the first storage block and the at least one master storage block in a case where the first storage block is a storage block in the plurality of slave storage blocks.

[0104] The deleting unit is configured to delete the first storage block in a case where an association relationship between the first storage block and a target storage block in the at least one master storage block is not strongly consistent, the target storage block being any one of the at least one master storage block.

[0105] The establishing unit 12 is configured to establish a third storage block;

[0106] The obtaining unit 11 is configured to obtain backup storage information corresponding to the first storage block, and add the backup storage information into the third storage block to obtain a fourth storage block;

[0107] The updating unit is configured to update a plurality of slave storage blocks in the target database by using the fourth storage block to obtain an updated target database.

[0108] In some embodiments of the present application, the device further comprises a processing unit;

[0109] The processing unit is configured to, in the case that the first storage block and the target storage block are in a strong consistency association relationship, perform degradation processing on read-write operations of the target storage block to obtain a degraded target storage block.

[0110] Correspondingly, the updating unit is configured to update the target database by using the fourth storage block and the target storage block to obtain the updated target database.

[0111] In some embodiments of the present application, the device further comprises an execution unit and a waiting unit;

[0112] The detection unit is configured to, in the case that a second alive detection time is reached, perform alive detection on the target database by using a high-availability service to obtain an alive result of the target database.

[0113] The execution unit is configured to, in the case that the alive result of the target database indicates that the target database does not have activity, perform a failover operation on the target database.

[0114] The establishing unit 12 is configured to establish a new target database according to storage information in the target database;

[0115] The waiting unit is configured to, in the case that the alive result of the target database indicates that the target database has activity, wait for a next second alive detection time, and perform alive detection on the target database again when the next second alive detection time is reached.

[0116] In some embodiments of the present application, the device further comprises a generation unit;

[0117] The detection unit is configured to, in the case that a third alive detection time is reached, perform alive detection on availability of the target database by using a high-availability service to obtain an alive result of the availability.

[0118] The generating unit is configured to generate alarm information and output the alarm information in a case where the availability of the target database is identified as being inactivity by the alive detection result.

[0119] The waiting unit is configured to wait for a next third alive detection time in a case where the alive detection result identifies that the target database is available, and perform alive detection on the target database again at the next third alive detection time.

[0120] In some embodiments of the present application, the deleting unit is configured to delete the plurality of storage containers in the plurality of container service clusters in a case where a destruction instruction for the target database is received.

[0121] It should be noted that in actual application, the obtaining unit 11 and the establishing unit 12 can be implemented by a processor 13 on the database creation apparatus 1, specifically, a CPU (Central Processing Unit), an MPU (Microprocessor Unit), a DSP (Digital Signal Processing), or an FPGA (Field Programmable Gate Array), etc., and the data storage can be implemented by a memory 14 on the database creation apparatus 1.

[0122] The present application also provides a database creation apparatus 1, as shown in the accompanying drawings, which comprises a processor 13, a memory 14 and a communication bus 15. Figure 6 The memory 14 communicates with the processor 13 through the communication bus 15, and the memory 14 stores programs executable by the processor 13, and when the programs are executed, the processor 13 executes the database creation method as described above.

[0123] In actual application, the memory 14 can be a volatile memory, such as a RAM (Random-Access Memory), or a non-volatile memory, such as a ROM (Read-Only Memory), a flash memory, an HDD (Hard Disk Drive) or an SSD (Solid-State Drive), or a combination of the above-mentioned memories, and provides instructions and data to the processor 13.

[0124] The embodiment of the present application provides a computer readable storage medium, which has a computer program, and the program is executed by a processor 13 to realize the database creation method.

[0125] It can be understood that the database creation apparatus determines the plurality of container service clusters and the database creation parameter corresponding to the target database from the creation instruction by using the management and control service in the case that the creation instruction of the target database is received, that is, determines in which container service clusters the target database is established and the creation parameter when the target database is established; so that the management and control service can create a storage container meeting the database creation parameter in each service cluster of the plurality of service clusters according to the database creation parameter, thereby obtaining a plurality of storage containers, and since the plurality of storage containers are established in the plurality of container service clusters, the storage space is expanded by using the plurality of container service clusters in the case that the storage space provided by each container service cluster is limited; and the plurality of storage containers are used to form the target database, and the expanded target database is obtained, that is, the storage capacity of the created target database is improved.

[0126] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage and optical storage) containing computer usable program codes.

[0127] The present application is described with reference to flowcharts and / or block diagrams according to the method, device (system), and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device implemented in the flowcharts and / or block diagrams. Figure 1 The device that implements the function specified in one flow or multiple flows and / or blocks. Figure 1 The device that implements the function specified in one flow or multiple flows and / or blocks.

[0128] These computer program instructions can also be stored in a computer readable storage medium that can guide the computer or other programmable data processing devices to work in a specific way, so that the instructions stored in the computer readable storage medium produce a manufactured product including instruction devices, which implement the flowcharts and / or block diagrams. Figure 1 The device that implements the function specified in one flow or multiple flows and / or blocks. Figure 1the function(s) specified in the block or blocks.

[0129] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operation steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide processes for implementing the flows Figure 1 the flow(s) or the block(s) in the flow(s) and / or block(s). Figure 1 the function(s) specified in the block or blocks.

[0130] The above descriptions are only the preferred embodiments of the present application, and are not used to limit the protection scope of the present application.

Claims

1. A database creation method characterized by comprising: The method comprises: In the case of receiving a creation instruction of a target database, determining a plurality of container service clusters and database creation parameters corresponding to the target database from the creation instruction; Using a management and control service, establishing at least one storage container in each of the plurality of container service clusters according to the database creation parameters to obtain a plurality of storage containers; Using the plurality of storage containers to build the target database.

2. The method of claim 1, wherein, The method further comprises: Each of the plurality of storage containers further comprises a main thread; Using a plurality of main threads to set the association between the master storage blocks and the slave storage blocks. After using the plurality of storage containers to build the target database, the method further comprises: In the case that a first alive detection time is reached, using a high availability service to perform alive detection on a plurality of storage blocks in the plurality of storage containers to obtain a plurality of alive detection results; 3. The method of claim 2, wherein, In the case that a first alive detection result in the plurality of alive detection results is not active, determining a first storage block corresponding to the first alive detection result; the first alive detection result is part of the plurality of alive detection results; the first alive detection result is the alive detection result of the first storage block; In the case that the first storage block is a storage block in at least one master storage block, determining a second storage block in a plurality of slave storage blocks in the plurality of storage blocks; the number of the plurality of slave storage blocks is a second number, the number of the at least one master storage block is a first number, the plurality of slave storage blocks and the at least one master storage block constitute a plurality of storage blocks, and the second storage block is any one of the plurality of slave storage blocks; Establishing a third storage block; and updating the target database using the third storage block and the second storage block to obtain an updated target database.

4. The method of claim 1, wherein, The method further comprises: Using the second storage block to update the at least one master storage block to obtain at least one updated master storage block; Deleting the first storage block and obtaining backup storage information corresponding to the first storage block; ​ ​ 5. The method of claim 4, wherein, ​ ​ ​ add the backup storage information to the third storage block to obtain a fourth storage block; update the plurality of slave storage blocks by using the fourth storage block to obtain a plurality of updated slave storage blocks; update the target database by using the at least one updated master storage block and the plurality of updated slave storage blocks to obtain an updated target database.

6. The method of claim 4, wherein, After the first storage block corresponding to the first alive result is determined, the method further comprises: in the case that the first storage block is a storage block in the plurality of slave storage blocks, detecting the association relationship between the first storage block and the at least one master storage block; in the case that the association relationship between the first storage block and a target storage block in the at least one master storage block is a non-strongly consistent association relationship, deleting the first storage block and establishing a third storage block; the target storage block is any one of the at least one master storage block; obtaining backup storage information corresponding to the first storage block, and adding the backup storage information to the third storage block to obtain a fourth storage block; updating the plurality of slave storage blocks in the target database by using the fourth storage block to obtain an updated target database.

7. The method of claim 6, wherein, After the association relationship between the first storage block and the at least one master storage block is detected, before the first storage block is deleted, the method further comprises: in the case that the association relationship between the first storage block and the target storage block is a strongly consistent association relationship, performing degradation processing on the read-write operation of the target storage block to obtain a degraded target storage block; correspondingly, the updating of the plurality of slave storage blocks in the target database by using the fourth storage block to obtain an updated target database comprises: updating the target database by using the fourth storage block and the target storage block to obtain the updated target database.

8. The method of claim 1, wherein, After the plurality of storage containers are used to construct the target database, the method further comprises: in the case that the second alive detection time is reached, performing alive detection on the target database by using a high-availability service to obtain an alive result of the target database; in the case that the alive result of the target database indicates that the target database does not have activity, performing a failover operation on the target database, and establishing a new target database according to the storage information in the target database; in the case that the alive result of the target database indicates that the target database has activity, waiting for the next second alive detection time, so as to perform alive detection on the target database again when the next second alive detection time is reached.

9. The method of claim 1, wherein, After the plurality of storage containers are used to construct the target database, the method further comprises: in the case that the third alive detection time is reached, performing alive detection on the availability of the target database by using a high-availability service to obtain an alive result of the availability; in the case that the alive result of the availability indicates that the availability of the target database does not have activity, generating alarm information and outputting; In a case where the alive result indicates that the target database availability is alive, a next third alive detection time is waited for, and alive detection of the target database availability is performed again when the next third alive detection time arrives.

10. The method according to any one of claims 1 to 9, characterized in that, After the target database is constructed by using the plurality of storage containers, the method further comprises: In a case where a destruction instruction of the target database is received, the plurality of storage containers are deleted in the plurality of container service clusters.

11. A database creation apparatus characterized by comprising: The apparatus comprises: An acquisition unit is configured to, in a case where a creation instruction of a target database is received, determine, from the creation instruction, a plurality of container service clusters corresponding to the target database and database creation parameters; An establishment unit is configured to, by using a management and control service, establish at least one storage container in each of the plurality of container service clusters according to the database creation parameters, to obtain a plurality of storage containers, and construct the target database by using the plurality of storage containers.

12. A database creation apparatus characterized by comprising: The apparatus comprises: A memory, a processor and a communication bus, the memory communicates with the processor through the communication bus, the memory stores a database creation program executable by the processor, and when the database creation program is executed, the method according to any one of claims 1 to 10 is executed by the processor.

13. A storage medium having stored thereon a computer program for application in a database creation apparatus, characterized by comprising: The computer program is executed by the processor to implement the method according to any one of claims 1 to 10. The computer program is executed by the processor to implement the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Method and system for establishing connection with high availability for database cluster

    CN105389371A

  • Data processing and creating method and device for distributed database and electronic equipment

    CN112395366A