Database directory mounting method and device, electronic equipment and storage medium

By pre-defining the storage volume configuration template for the database function directory of the K8S system, generating target resource storage requests, and specifying the host mount path, the limitations of the K8S system in local dynamic storage are solved, the diversification and flexibility of data storage are achieved, and the performance of the database cluster is improved.

CN119884069APending Publication Date: 2025-04-25CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411792096.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The existing K8S system has limitations in local dynamic storage, and it is impossible to specify different directories on hosts for different data in containers, resulting in the inability to meet users' diverse and flexible needs for data storage.

Method used

By predefining the storage volume configuration templates corresponding to the functional directories in the database system, including the host mount path, creating a target database cluster based on these templates, and generating a target resource storage request through the target database cluster, specifying the target host mount path to create a target storage volume.

Benefits of technology

It realizes point-to-point mounts for different functional directories in containers and hosts, meets users' diverse and flexible needs for data storage, optimizes data storage methods, improves the performance of database clusters, and reduces disk IO.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119884069A_ABST
    Figure CN119884069A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a database directory mounting method and device, electronic equipment and a storage medium, and the method comprises the steps: pre-defining a storage volume configuration template corresponding to a function directory for any function directory in a database system; creating a target database cluster based on the storage volume configuration template corresponding to each function directory; for any target function directory, creating a target resource storage request corresponding to the target function directory through a target database cluster; creating a target storage volume corresponding to the target function directory on a host machine corresponding to the database system based on a target host machine mounting path corresponding to the target function directory contained in the target configuration information; the target host machine mounting path is used for the target database cluster to access target data corresponding to the target function directory based on the target storage volume. Point-to-point mounting of different function directories in a container of a target database cluster and on a host machine is achieved, and the requirements of a user for diversification and flexibility of data storage are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud storage technology, and in particular to a method, device, electronic device and storage medium for mounting a database directory. Background Art

[0002] With the rapid development of cloud computing and cloud-native technology ecosystem, databases, as a key element of IT infrastructure, are also evolving in line with this trend. As the foundation of cloud-native technology, Kubernetes has become the de facto standard for container orchestration. Compared with centralized storage and distributed storage, local storage has become a better choice for database persistent storage due to its high reliability and performance advantages. Currently, database container deployment usually uses rancher / local-path-provisioner to dynamically create local persistent volumes (PVs).

[0003] However, K8S currently has some limitations in terms of local dynamic storage. Specifically, users may want to store different types of data in different directories on the host machine for better data management and backup, but the current K8S system only supports mounting based on a main directory on the host machine, and does not have the ability to specify different directories on the host machine for different data in the container, resulting in the inability to meet users' diverse and flexible needs for data storage. Summary of the invention

[0004] In order to overcome the problems existing in the related art, the present invention provides a method, device, electronic device and storage medium for mounting a database directory.

[0005] In a first aspect, the present invention provides a method for mounting a database directory, the method comprising:

[0006] For any function directory in the database system, a storage volume configuration template corresponding to the function directory is predefined; the storage volume configuration template includes a host machine mount path corresponding to the function directory, and different function directories store data of different function types;

[0007] Creating a target database cluster based on the storage volume configuration template corresponding to each of the function directories;

[0008] For any target function directory, a target resource storage request corresponding to the target function directory is created through the target database cluster based on the storage volume configuration template corresponding to the target function directory; the target resource storage request carries target configuration information;

[0009] Based on the target host machine mount path corresponding to the target function directory contained in the target configuration information, a target storage volume corresponding to the target function directory is created on the host machine corresponding to the database system; the target host machine mount path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume.

[0010] Optionally, creating a target database cluster based on the storage volume configuration template corresponding to each of the function directories includes:

[0011] Parsing each of the storage volume configuration templates through a database controller to obtain template information corresponding to each of the storage volume configuration templates;

[0012] Based on the template information corresponding to each of the storage volume configuration templates, a container group adaptation operation is performed on the preset database cluster to create the target database cluster.

[0013] Optionally, any of the template information includes specified container information, a path in the container, a host mount path, and a storage class name; the container group adaptation operation is performed on the preset database cluster based on the template information corresponding to each of the storage volume configuration templates, including:

[0014] For any of the storage volume configuration templates, a resource storage request template is generated based on the storage class name and the host mount path; the resource storage request template is used to create a resource storage request corresponding to the function directory;

[0015] Mounting and configuring a specified container corresponding to the specified container information in the container group of the preset database cluster according to the path in the container;

[0016] Generate environment variables according to the path in the container;

[0017] Based on the environment variables, a container directory corresponding to the function directory is created in the designated container, and configuration of a startup configuration file corresponding to the initial database cluster is completed.

[0018] Optionally, the creating a target storage volume corresponding to the target function directory on a host corresponding to the database system based on a target host mount path corresponding to the target function directory included in the target configuration information includes:

[0019] In a case where the target resource storage request carries a target host mount path, a target storage volume corresponding to the target function directory is created on the host corresponding to the database system based on the target host mount path corresponding to the target function directory contained in the target configuration information.

[0020] Optionally, the creating a target storage volume corresponding to the target function directory on a host corresponding to the database system based on a target host mount path corresponding to the target function directory included in the target configuration information includes:

[0021] Obtaining node information in the target resource storage request;

[0022] Determining whether a mount path of the target host satisfies a target mount condition based on a temporary container group scheduled to the first target host corresponding to the node information;

[0023] In a case where the target host mount path satisfies the target mount condition, a target storage volume corresponding to the target function directory is created on the first target host based on the target host mount path.

[0024] Optionally, the method further comprises:

[0025] When the target resource storage request does not carry a target host machine mount path, obtaining node information in the target resource storage request;

[0026] Based on a designated mount path pre-configured for a second target host corresponding to the node information, a target storage volume corresponding to the target function directory is created on the second target host; the mount path corresponding to the target storage volume belongs to the designated mount path.

[0027] Optionally, the method further comprises:

[0028] For any of the functional directories, a target disk that meets the data storage requirements corresponding to the functional directory is mounted to the functional directory.

[0029] In a second aspect, the present invention provides a database directory mounting device, the device comprising:

[0030] A first definition module is used to predefine a storage volume configuration template corresponding to any function directory in the database system; the storage volume configuration template includes a host machine mount path corresponding to the function directory, and different function directories store data of different function types;

[0031] A first creation module, configured to create a target database cluster based on the storage volume configuration template corresponding to each of the function directories;

[0032] A second creation module is used to create, for any target function directory, a target resource storage request corresponding to the target function directory through the target database cluster based on the storage volume configuration template corresponding to the target function directory; the target resource storage request carries target configuration information;

[0033] The third creation module is used to create a target storage volume corresponding to the target function directory on the host machine corresponding to the database system based on the target host machine mount path corresponding to the target function directory contained in the target configuration information; the target host machine mount path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume.

[0034] Optionally, the first creation module includes:

[0035] A first parsing module, configured to parse each of the storage volume configuration templates through a database controller to obtain template information corresponding to each of the storage volume configuration templates;

[0036] The first adaptation module is used to perform a container group adaptation operation on a preset database cluster based on the template information corresponding to each of the storage volume configuration templates to create the target database cluster.

[0037] Optionally, any of the template information includes specified container information, a path in the container, a host mount path, and a storage class name; and the first adaptation module includes:

[0038] A first generating module is used to generate a resource storage request template for any of the storage volume configuration templates based on the storage class name and the host mount path; the resource storage request template is used to create a resource storage request corresponding to the function directory;

[0039] A first configuration module, configured to mount and configure a specified container corresponding to the specified container information in the container group of the preset database cluster according to the path in the container;

[0040] A second generating module is used to generate environment variables according to the path in the container;

[0041] The second configuration module is used to create a container directory corresponding to the function directory in the designated container based on the environment variable, and complete the configuration of the startup configuration file corresponding to the initial database cluster.

[0042] Optionally, the third creation module includes:

[0043] The first creation submodule is used to create a target storage volume corresponding to the target function directory on the host machine corresponding to the database system based on the target host machine mount path corresponding to the target function directory contained in the target configuration information when the target resource storage request carries the target host machine mount path.

[0044] Optionally, the third creation module includes:

[0045] A first acquisition module, used to acquire node information in the target resource storage request;

[0046] A first determination module, configured to determine whether a mount path of the target host machine satisfies a target mount condition based on a temporary container group scheduled to the first target host machine corresponding to the node information;

[0047] The second creation submodule is used to create a target storage volume corresponding to the target function directory on the first target host based on the target host mount path when the target host mount path meets the target mount condition.

[0048] Optionally, the device further comprises:

[0049] A second acquisition module is used to acquire node information in the target resource storage request when the target resource storage request does not carry a target host machine mount path;

[0050] The third creation submodule is used to create a target storage volume corresponding to the target function directory on the second target host machine based on the designated mount path pre-configured for the second target host machine corresponding to the node information; the mount path corresponding to the target storage volume belongs to the designated mount path.

[0051] Optionally, the device further comprises:

[0052] The first mounting module is used to mount, for any of the function directories, a target disk that meets the data storage requirements corresponding to the function directory to the function directory.

[0053] In a third aspect, the present invention provides an electronic device comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for mounting a database directory described in any one of the first aspects when executing the program.

[0054] In a fourth aspect, the present invention provides a readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the steps in the method for mounting a database directory in any one of the embodiments of the first aspect above.

[0055] In an embodiment of the present invention, a storage volume configuration template corresponding to any function directory in a database system is predefined; the storage volume configuration template includes a host machine mount path corresponding to the function directory, and different function directories store data of different function types; a target database cluster is created based on the storage volume configuration template corresponding to each function directory; a target resource storage request corresponding to the target function directory is created through the target database cluster for any target function directory; the target resource storage request carries target configuration information; based on the target host machine mount path corresponding to the target function directory contained in the target configuration information, a target storage volume corresponding to the target function directory is created on the host corresponding to the database system; the target host machine mount path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume. In this way, by predefining storage volume configuration templates corresponding to different function directories, target resource storage requests and target storage volumes corresponding to different function directories are generated based on the storage volume configuration template, so that the target storage volume can be directly mounted on the target host machine mount path corresponding to different function directories. By specifying the target host mount path in the target resource storage request, point-to-point mounting of different functional directories in the container of the target database cluster and on the host can be achieved, which can meet the user's diverse and flexible needs for data storage. At the same time, by independently mounting different functional directories in the target database cluster on different host mount paths of the host, the data storage method can be optimized, thereby improving the performance of the target database cluster and reducing disk IO. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0057] Figure 1 It is a flowchart of the steps of the method for mounting a database directory in the prior art;

[0058] Figure 2 It is a flowchart of the steps of a method for mounting a database directory provided by an embodiment of the present invention;

[0059] Figure 3 is a flow chart of steps for generating a target storage volume provided by an embodiment of the present invention;

[0060] Figure 4 It is a schematic diagram of a directory mounting effect in a host machine and a container provided by an embodiment of the present invention;

[0061] Figure 5 It is a structural diagram of a database directory mounting device provided by an embodiment of the present invention;

[0062] Figure 6 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0063] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0064] In the related technology, the process of creating a database cluster by using local-path-provisioner to provide dynamic persistent volumes (PersistentVolume, PV) is as shown in the attached Figure 1 As shown:

[0065] 1. Deploy local-path-provisioner and StorageClass. StorageClass is a resource type that supports dynamic resource provisioning. To use the defined storage class, you first need an automatic configuration program provisioner, such as local-path-provisioner, to provide dynamic local storage implementation.

[0066] 2. To create a database cluster based on demand, users first need to prepare a resource instance CR for the specified database. The CR specifies the storage used by the cluster, namely, the StorageClass Name.

[0067] 3. After the database operator detects the creation of CR, it will generate a running entity statefulset, which contains multiple container groups pod, so that each node in the database cluster can exist as a pod. The field volumeClaimTemplates in statefulset defines the PVC template that needs to be applied for pod operation. The PVC template is used to generate the corresponding PVC. In dynamic mode, dynamic binding of resources is completed through StorageClass and PVC, and local-path-provisioner automatically generates PV based on PVC.

[0068] Based on the above process, in order to achieve the effect of specifying different directories on the host machine for different data in the container, you can Figure 1The central gray module is further designed to adapt to the customized mounting function of the database directory that specifies different directories on the host machine for different data in the container.

[0069] Figure 2 is a flowchart of a method for mounting a database directory provided by an embodiment of the present invention, such as Figure 2 As shown, the method may include:

[0070] Step 101: For any function directory in the database system, predefine a storage volume configuration template corresponding to the function directory; the storage volume configuration template includes a host machine mount path corresponding to the function directory, and different function directories store data of different function types.

[0071] In an embodiment of the present invention, when data is stored based on a database system deployed in a host machine, different functional directories can be divided in the database system to store data of different functional types, such as a data directory, a log directory, a snapshot directory, etc., according to the different functions and uses of data in data management, system monitoring, and backup and recovery.

[0072] For any function directory, a storage volume configuration template corresponding to the function directory is predefined. Among them, the storage volume configuration template can be a custom resource definition (CRD) file. Custom resource definition (CRD) is an extension mechanism provided by Kubernetes, allowing users to define and use non-native resource types. The storage volume configuration template is used to describe the structure, attributes and behavior of custom resources. The storage volume configuration template can define the directory name for the function directory, the specified container information, the path in the container, the host mount path and the storage class name. Among them, the directory name can include the directory name corresponding to the data directory, the log directory and the snapshot directory. The specified container information is used to specify the specified container in the container group pod. There may be multiple containers in the container group pod, such as the initialization container, the main running container, the container responsible for monitoring data collection, etc., and specify which container currently needs to be configured for persistent storage from the multiple containers in the container group pod. The path in the container is used to indicate the path in the internal file system of the container. The host mount path is used to indicate the path in the host file system of the host. The storage class name is used to specify the storage class used. StorageClass is a resource type that supports dynamic provisioning of resources. To use the defined storage class, you first need an automatic configuration program provisioner. The actual creation of storage resources, such as storage volumes (PV), is implemented by the provisioner. For example, when the storage class is local-path, the provisioner needs to be configured as local-path-provisioner. local-path-provisioner is a lightweight Kubernetes plug-in designed to automatically create and manage local storage volumes for pods within the cluster. It simplifies the process of associating database clusters in a Kubernetes cluster with physical storage resources on nodes, especially for users who want to take advantage of local disks without the need for complex distributed storage systems.

[0073] After defining the storage volume configuration template corresponding to the functional directory, you can use the mount function to establish a mapping relationship between the path in the container and the host mount path. For example, you can use the "-v" or "--volume" parameter to mount the functional directory corresponding to the host mount path to the path in the container, thereby accessing the files corresponding to the host mount path from within the container.

[0074] For example, in the case where the function directory is a data directory, the storage volume configuration template corresponding to the data directory may be:

[0075]

[0076] Step 102: Create a target database cluster based on the storage volume configuration template corresponding to each of the function directories.

[0077] In the embodiment of the present invention, based on the storage volume configuration templates defined for different functional directories, parameters of a preset database cluster are adapted to create a target database cluster.

[0078] Optionally, step 102 may include:

[0079] Step 201: parse each storage volume configuration template through a database controller to obtain template information corresponding to each storage volume configuration template.

[0080] In the embodiment of the present invention, each storage volume configuration template is parsed by the database controller of the Kubernetes cluster to obtain the template information corresponding to each storage volume configuration template. The template information may include the directory name, the specified container information, the path in the container, the host mount path, and the storage class name. The database controller operator needs to ensure that the pod can correctly mount and use the custom data volume.

[0081] Step 202: Based on the template information corresponding to each of the storage volume configuration templates, a container group adaptation operation is performed on the preset database cluster to create the target database cluster.

[0082] In the embodiment of the present invention, based on the template information corresponding to each storage volume configuration template, the database controller operator and the database underlying container image are adapted to create a target database cluster. Exemplarily, the volumes and volumeMounts fields of the Pod can be defined by the controller operator to configure the storage volume (Volume) for the container, and the configuration information can be passed to the container in the Pod through the environment variables (Environment Variables), and the database underlying image is adapted based on the environment variables to ensure that the data is written to the correct path in the container. Finally, the database instance will read these environment variables to perform corresponding configuration.

[0083] Optionally, step 202 may include the following steps:

[0084] Step 2021: For any of the storage volume configuration templates, generate a resource storage request template based on the storage class name and the host mount path; the resource storage request template is used to create a resource storage request corresponding to the function directory.

[0085] In an embodiment of the present invention, for any storage volume configuration template, a resource storage request template is generated based on the storage class name and the host mount path. Among them, the resource storage request template can be defined based on the field volumeClaimTemplates in StatefulSet, and the resource storage request template can be used to create a resource storage request corresponding to the functional directory for the container group. The resource storage request template may include the attributes required to create a resource storage request PVC, such as storage class, access mode, storage resource requirements, etc. Exemplarily, based on the storage volume configuration template corresponding to the data directory, based on the storage class name in the storage volume configuration template and the host mount path, volumeClaimTemplates is generated. Then, after the target database cluster is created, the target database cluster can create the declared resource storage request PVC based on the volumeClaimTemplates.

[0086] Step 2022: Mount and configure the designated container corresponding to the designated container information in the container group of the preset database cluster according to the path in the container.

[0087] In an embodiment of the present invention, a specified container corresponding to the specified container information is configured in a container group of a preset database cluster according to the path in the container. Based on the specified container information, a specified container corresponding to the specified container information is determined in a container group of a preset database cluster. Based on the path in the container, the specified container is mounted and configured. Exemplarily, the specified container volumeMounts can be configured according to the specified container information and the path in the container, where volumeMounts is a configuration at the container level, which is used to define how to mount a storage volume at the container level, such as defining which directory of the container the storage volume is mounted to, whether the mount mode is read-only or writable, and so on.

[0088] Step 2023: Generate environment variables according to the path in the container.

[0089] In an embodiment of the present invention, an environment variable is a parameter used to specify an operating environment. In a database cluster and containerized deployment, environment variables can be used to configure the operating environment of a container. In a database cluster, environment variables can be used to configure database connection parameters, memory allocation, etc. to ensure that the database cluster inside the container can run correctly. Environment variables are generated according to the container path in the storage volume configuration template corresponding to different functional directories, so that the environment variables match the database container logic, such as the data directory PGDATA, the log directory PGLOG, etc. After generating the environment variables, the controller can reflect the environment variables in the pod's yaml file for the database instance to configure accordingly. Exemplarily, these environment variables can be passed to the container through the env field of the pod.

[0090] By writing a yaml file, you can deploy the controller and operator. The yaml file is used to specify the image, resource limits, environment variables, etc. of the controller operator. You can use the kubectl command to apply the controller yaml and database cluster CR to the Kubernetes cluster.

[0091] Step 2024: Based on the environment variables, create a container directory corresponding to the function directory in the designated container, and complete the configuration of the startup configuration file corresponding to the initial database cluster.

[0092] In an embodiment of the present invention, based on environment variables, the database bottom image is adapted, including: creating a container directory corresponding to the function directory in a specified container, and completing the configuration of the startup configuration file corresponding to the initial database cluster to obtain the target container image. Exemplarily, creating a container directory corresponding to the function directory in the specified container can be: creating and authorizing the corresponding directory in the container based on the environment variables, for example, creating directory items corresponding to different function directories based on the path in the container in the specified container, and configuring the permission authorization of the directory items. The configuration of the startup configuration file corresponding to the initial database cluster can be: mapping the environment variables to the configuration file for starting the database, so as to reflect different function paths to the specified items in the configuration file required for database startup, for example, taking postgresql as an example, such as the data directory is specified by -D in the database startup configuration file, and the wal log directory is specified by wal_dir in the database startup configuration file. Adapting the container image based on environment variables can ensure that the container can run in the same way in different environments. Environment variables can be used to transmit configuration information, set the operating environment of the target database cluster, etc., thereby enhancing the portability and compatibility of the container.

[0093] In the embodiment of the present invention, by generating a resource storage request template, mounting and configuring a specified container, and completing the adaptation of the container image based on environment variables, the storage resources and the operating environment can be dynamically adjusted according to the requirements of the storage volume configuration template, the storage mapping of the host machine and the container can be realized, and then the adaptation of the database cluster can be completed, so as to facilitate the effect of independently mounting different functional directories on different paths of the host machine based on the target database cluster.

[0094] Step 103: For any target function directory, create a target resource storage request corresponding to the target function directory through the target database cluster based on the storage volume configuration template corresponding to the target function directory; the target resource storage request carries target configuration information.

[0095] In an embodiment of the present invention, for any target function directory, a target resource storage request corresponding to the target function directory is created through a target database cluster based on a storage volume configuration template corresponding to the target function directory. Among them, the target resource storage request corresponding to the target function directory can be determined based on the resource storage request template corresponding to the target function directory. That is, based on the storage class name in the target function directory and the resource storage request template generated by the host mount path, the target resource storage request is created according to the resource storage request template. The target resource storage request can be a persistent volume claim (Persistent Volume Claim, PVC), and the target resource storage request is a user's request for storage resources, which is used to request the Kubernetes system to provide a storage volume that meets the target resource storage request. The target resource storage request may carry target configuration information and node information. The content of the target configuration information is determined based on the content of the resource storage request template corresponding to the target function directory. The node information is used to indicate the node corresponding to the target resource storage request, and the node is a physical or virtual machine in the Kubernetes cluster, such as a host machine, which is used to run a pod.

[0096] Step 104: based on the target host machine mount path corresponding to the target function directory contained in the target configuration information, create a target storage volume corresponding to the target function directory on the host machine corresponding to the database system; the target host machine mount path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume.

[0097] In an embodiment of the present invention, when a provisioner, such as a local-path-provisioner, monitors a target resource storage request, based on the target host mount path corresponding to the target function directory contained in the target configuration information, a target storage volume corresponding to the target function directory is created on the target host mount path of the host corresponding to the database system, so as to mount the target function directory of the host as the target storage volume of the designated container corresponding to the target function directory. Then, the target database cluster can access the target data corresponding to the target function directory in the host according to the target host mount path based on the target storage volume. Among them, the host corresponding to the database system can be the host corresponding to the deployment of the database system, and the target storage volume can be a persistent volume (Persistent Volume, PV).

[0098] In a possible implementation, when there is a dynamic PV provisioner that matches the target resource storage request in the target database cluster, when the provisioner listens to the target resource storage request, the provisioner will dynamically create a target storage volume based on the description of the target resource storage request and based on the specified target host mount path to ensure that the storage resources are correctly allocated and mounted.

[0099] Optionally, step 104 may include the following steps:

[0100] Step 301: When the target resource storage request carries a target host mount path, based on the target host mount path corresponding to the target function directory contained in the target configuration information, create a target storage volume corresponding to the target function directory on the host corresponding to the database system.

[0101] In an embodiment of the present invention, when a provisioner, such as a local-path-provisioner, listens to a target resource storage request, it parses the target resource storage request, and when it is parsed that the target resource storage request carries a target host mount path, it creates a target storage volume corresponding to the target function directory on the host based on the target host mount path included in the target configuration information.

[0102] Optionally, the step of “creating a target storage volume corresponding to the target function directory on a host corresponding to the database system based on a target host mount path corresponding to the target function directory included in the target configuration information” may include the following steps:

[0103] Step 401: Obtain node information in the target resource storage request.

[0104] In the embodiment of the present invention, when it is parsed that the target resource storage request carries the target host mount path, the node information in the target resource storage request is obtained.

[0105] Step 402: Based on the temporary container group scheduled to the first target host corresponding to the node information, determine whether the target host mount path meets the target mount condition.

[0106] In an embodiment of the present invention, a temporary container group helperPod is created through a provisioner, such as a local-path-provisioner, and the temporary container group helperPod is scheduled to the first target host, and a directory check is performed based on the temporary container group helperPod in the first target host to determine whether the target host mount path meets the target mount condition. The target mount condition may include that the target host mount path exists in the first target host, and the target host mount path content is empty and a disk is mounted.

[0107] Step 403: When the target host mount path satisfies the target mount condition, a target storage volume corresponding to the target function directory is created on the first target host based on the target host mount path.

[0108] In an embodiment of the present invention, when the target host mount path satisfies the target mount condition, that is, the target host mount path exists in the first target host, and the target host mount path content is empty and a disk is mounted, indicating that the target host mount path is legal, a target storage volume corresponding to the target function directory is created on the first target host based on the target host mount path. And the target storage volume is bound to the target resource storage request. If the target storage volume is successfully bound to the target resource storage request, the target resource storage request can be used by the Pod to access the storage resources corresponding to the target storage volume.

[0109] In an embodiment of the present invention, by specifying the target host machine mount path in the target resource storage request, point-to-point mounting for different functional directories in the container of the target database cluster and on the host machine is achieved, which can meet the user's diverse and flexible needs for data storage.

[0110] Optionally, the embodiment of the present invention may further include the following steps:

[0111] Step 501: When the target resource storage request does not carry a target host machine mount path, obtain node information in the target resource storage request.

[0112] In the embodiment of the present invention, when it is parsed that the target resource storage request does not carry the target host machine mount path, the node information in the target resource storage request is obtained.

[0113] Step 502: based on the designated mount path pre-configured for the second target host corresponding to the node information, create a target storage volume corresponding to the target function directory on the second target host; the mount path corresponding to the target storage volume belongs to the designated mount path.

[0114] In an embodiment of the present invention, different designated mount paths are pre-configured for different nodes, and one node may correspond to one or more designated mount paths. The node may be a host machine. In the case of multiple host machines, the host machine may be determined based on the node information. The second target host machine is determined based on the node information. Based on the designated mount path corresponding to the second target host machine, a target storage volume corresponding to the target function directory is created on the second target host machine. Specifically, a provisioner, such as a local-path-provisioner, may create an auxiliary container group helperPod, and schedule the helperPod to the second target host machine. In the case where there are multiple designated mount paths corresponding to the second target host machine, a designated mount path is randomly selected, and a subdirectory is created under the designated mount path according to preset rules. Based on the subdirectory of the designated mount path, a target storage volume is generated, and the target storage volume is mounted under the designated mount path in the form of a subdirectory. For example, configure the specified mount path of provisioner on node node1 to be [" / opt / local-path-provisioner"," / data1"], randomly select the specified mount path data1, create a subdirectory {pvName}-{namespace}-{pvcName} under data1, and generate a target storage volume. The actual data corresponding to the target storage volume can be located in the subdirectory / data1 / {pvName}-{namespace}-{pvcName} / of node node1.

[0115] Exemplarily, an embodiment of the present invention provides a flowchart of steps for generating a target storage volume, such as Figure 3As shown, the target database cluster creates a target resource storage request corresponding to the target function directory, that is, PVC, according to the storage volume configuration template corresponding to the target function directory. When the provisioner listens to the PVC, it determines whether pvc.annotations[provision.path] (used to define the target host mount path) exists in the PVC. If so, a temporary container group helperPod is created based on the local-path-provisioner enhanced mode, and the temporary container group helperPod is scheduled to the node corresponding to the PVC, that is, the host. The provisioner executes the directory check script in the provisioner's pod to determine provision.path, that is, the target host mount path exists, is empty, and has a disk mounted, then creates a target storage volume, that is, a PV object, and binds the PVC to the PV. If it does not exist, a temporary container group helperPod is created based on the local-path-provisioner native mode, and the temporary container group helperPod is scheduled to the node corresponding to the PVC, that is, the host. A subdirectory {pvName}-{namespace}-{pvcName} is created under the specified mount path corresponding to the host as the actual mount path of the PV, and then the target storage volume, that is, the PV object, is created, and the PVC is bound to the PV.

[0116] In the embodiment of the present invention, by judging whether the target resource storage request carries the target host machine mount path, provisioner can be used to create target storage volumes based on different modes, thereby improving the flexibility of generating target storage volumes.

[0117] Optionally, the embodiment of the present invention may include the following steps:

[0118] Step 601: For any of the functional directories, mount a target disk that meets the data storage requirements corresponding to the functional directory to the functional directory.

[0119] In an embodiment of the present invention, for any functional directory, a target disk that meets the data storage requirements corresponding to the functional directory is provided for the functional directory, and the target disk is mounted to the functional directory. Exemplarily, SSD disks with different performances are selected according to the function of the data. When the functional directory is a data directory and a log directory, the data storage requirements corresponding to the functional directory require high disk performance and strong reliability. Therefore, a high IO or ultra-high IO type disk can be selected as the target disk, and the target disk is mounted in the data directory and the log directory; when the functional directory is an archive file directory or a plug-in file directory, there is no special requirement for disk performance. The data storage requirements corresponding to the functional directory can be considered from the cost aspect, and a normal IO type disk is selected as the target disk, and the target disk is mounted in the archive file directory or the plug-in file directory. It can be understood that the way to mount the disk to the specified directory complies with the general formatting partition, creating a mount directory, and using the mount command to mount the disk to the specified directory. The embodiment of the present invention will not be repeated here.

[0120] In the embodiment of the present invention, according to the data storage requirements corresponding to the function directory, the target disk mounted to the function directory is selected, which can make resource allocation more practical and comprehensive and improve the flexibility of disk mounting.

[0121] In summary, in an embodiment of the present invention, a storage volume configuration template corresponding to any function directory in a database system is predefined; the storage volume configuration template includes a host machine mount path corresponding to the function directory, and different function directories store data of different function types; a target database cluster is created based on the storage volume configuration template corresponding to each function directory; a target resource storage request corresponding to the target function directory is created through the target database cluster for any target function directory; the target resource storage request carries target configuration information; based on the target host machine mount path corresponding to the target function directory contained in the target configuration information, a target storage volume corresponding to the target function directory is created on the host corresponding to the database system; the target host machine mount path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume. In this way, by predefining storage volume configuration templates corresponding to different function directories, and then generating target resource storage requests and target storage volumes corresponding to different function directories based on the storage volume configuration template, the target storage volume can be directly mounted on the target host machine mount path corresponding to the different function directories. By specifying the target host mount path in the target resource storage request, point-to-point mounting of different functional directories in the container of the target database cluster and on the host can be achieved, which can meet the user's diverse and flexible needs for data storage. At the same time, by independently mounting different functional directories in the target database cluster on different host mount paths of the host, the data storage method can be optimized, thereby improving the performance of the target database cluster and reducing disk IO.

[0122] At the same time, by pre-defining the storage volume configuration templates corresponding to different function directories, the storage paths of the host function directory and the function directory in the container can be customized for the same function directory in the storage volume configuration template according to the needs, and then by setting the same storage path name in the host and the container, it is easier for users to identify data types. Compared with the prior art, after the database is containerized and deployed, the relevant function directories in the container and on the host are fixed format paths. For example, at the host level, the path will create subdirectories under the mount path based on the PV identifier and namespace, which makes it easier to flexibly configure the directory name according to business needs and industry specifications, improving the simplicity of data management and data use. At the same time, by customizing the storage path in the configurable database container and on the host, it helps to adapt to the business more flexibly, and at the same time facilitates the alignment of the original database deployment baseline, reduces the operation and maintenance threshold, and promotes the cloud-native transformation of the database.

[0123] For example, Figure 4 A schematic diagram showing the effect of mounting directories in a host machine and a container is shown in FIG. Figure 4As shown in the figure, first mount independent disks for N paths of the host, and then customize N storage volume configuration templates in customVolume to generate N PVCs and PVs. Each PV is directly mounted to the specified host mount path. Create a corresponding function directory in the directory in the container to complete the mapping between the function directory in the container and the host. Then, data corresponding to different function directories in the host can be accessed based on the corresponding different function directories in the container.

[0124] For example, five independent disks are mounted to the five first-level directories of the pg node, / pgdb, / pglog, / pgwal, / pgarch, and / pgextension. Assume that you need to implement: single-node pg container deployment, the pg scheduling node label is middleware=pg; the following five directories are written to the specified first-level directories in the container and on the host.

[0125]

[0126] Taking the PostgreSQL database as an example, you can implement customized independent disk mounting of the following multiple functional directories by following the steps below:

[0127] 1. Create a pg cluster and add customVolume configuration:

[0128]

[0129]

[0130]

[0131]

[0132] 2. The controller postgres operator monitors the creation of the database cluster and generates the pvc list as follows:

[0133]

[0134]

[0135] The above pps-postgresql-0 is scheduled to the node, bound to the local-pathStorageClass resource, and creates five pvc directories, namely pgdb-pps-postgresql-0 ( / pgdb), pgwal-pps-postgresql-0 ( / pgwal), pgarch-pps-postgresql-0 ( / pgarch), pglog-pps-postgresql-0 ( / pglog), and pgextension-pps-postgresql-0 ( / pgextension). At the same time, pps-postgresql-1 creates five corresponding directories.

[0136] 3. Enter the host machine and go to the specified directory to view the data (taking pgdb as an example):

[0137]

[0138] 4. Enter the container to view the specified directory (taking pgdb as an example):

[0139]

[0140] Figure 5 is a schematic diagram of the structure of a mounting device for a database directory provided by an embodiment of the present invention, such as Figure 5 As shown, the device may specifically include:

[0141] The first definition module 701 is used to predefine a storage volume configuration template corresponding to any function directory in the database system; the storage volume configuration template includes a host machine mount path corresponding to the function directory, and different function directories store data of different function types;

[0142] A first creation module 702, configured to create a target database cluster based on the storage volume configuration template corresponding to each of the function directories;

[0143] The second creation module 703 is used to create, for any target function directory, a target resource storage request corresponding to the target function directory through the target database cluster based on the storage volume configuration template corresponding to the target function directory; the target resource storage request carries target configuration information;

[0144] The third creation module 704 is used to create a target storage volume corresponding to the target function directory on the host machine corresponding to the database system based on the target host machine mount path corresponding to the target function directory contained in the target configuration information; the target host machine mount path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume.

[0145] The embodiment of the present invention provides a mounting device for a database directory, which predefines a storage volume configuration template corresponding to any function directory in a database system; the storage volume configuration template includes a host machine mounting path corresponding to the function directory, and different function directories store data of different function types; based on the storage volume configuration template corresponding to each function directory, a target database cluster is created; for any target function directory, a target resource storage request corresponding to the target function directory is created through the target database cluster; the target resource storage request carries target configuration information; based on the target host machine mounting path corresponding to the target function directory contained in the target configuration information, a target storage volume corresponding to the target function directory is created on the host machine corresponding to the database system; the target host machine mounting path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume. In this way, by predefining storage volume configuration templates corresponding to different function directories, and then generating target resource storage requests and target storage volumes corresponding to different function directories based on the storage volume configuration template, the target storage volume can be directly mounted on the target host machine mounting path corresponding to the different function directories. By specifying the target host mount path in the target resource storage request, point-to-point mounting of different functional directories in the container of the target database cluster and on the host can be achieved, which can meet the user's diverse and flexible needs for data storage. At the same time, by independently mounting different functional directories in the target database cluster on different host mount paths of the host, the data storage method can be optimized, thereby improving the performance of the target database cluster and reducing disk IO.

[0146] Optionally, the first creation module 702 includes:

[0147] A first parsing module, configured to parse each of the storage volume configuration templates through a database controller to obtain template information corresponding to each of the storage volume configuration templates;

[0148] The first adaptation module is used to perform a container group adaptation operation on a preset database cluster based on the template information corresponding to each of the storage volume configuration templates to create the target database cluster.

[0149] Optionally, any of the template information includes specified container information, a path in the container, a host mount path, and a storage class name; and the first adaptation module includes:

[0150] A first generating module is used to generate a resource storage request template for any of the storage volume configuration templates based on the storage class name and the host mount path; the resource storage request template is used to create a resource storage request corresponding to the function directory;

[0151] A first configuration module, configured to mount and configure a specified container corresponding to the specified container information in the container group of the preset database cluster according to the path in the container;

[0152] A second generating module is used to generate environment variables according to the path in the container;

[0153] The second configuration module is used to create a container directory corresponding to the function directory in the designated container based on the environment variable, and complete the configuration of the startup configuration file corresponding to the initial database cluster.

[0154] Optionally, the third creation module 704 includes:

[0155] The first creation submodule is used to create a target storage volume corresponding to the target function directory on the host machine corresponding to the database system based on the target host machine mount path corresponding to the target function directory contained in the target configuration information when the target resource storage request carries the target host machine mount path.

[0156] Optionally, the third creation module 704 includes:

[0157] A first acquisition module, used to acquire node information in the target resource storage request;

[0158] A first determination module, configured to determine whether a mount path of the target host machine satisfies a target mount condition based on a temporary container group scheduled to the first target host machine corresponding to the node information;

[0159] The second creation submodule is used to create a target storage volume corresponding to the target function directory on the first target host based on the target host mount path when the target host mount path meets the target mount condition.

[0160] Optionally, the device further comprises:

[0161] A second acquisition module is used to acquire node information in the target resource storage request when the target resource storage request does not carry a target host machine mount path;

[0162] The third creation submodule is used to create a target storage volume corresponding to the target function directory on the second target host machine based on the designated mount path pre-configured for the second target host machine corresponding to the node information; the mount path corresponding to the target storage volume belongs to the designated mount path.

[0163] Optionally, the device further comprises:

[0164] The first mounting module is used to mount, for any of the function directories, a target disk that meets the data storage requirements corresponding to the function directory to the function directory.

[0165] The present invention also provides an electronic device, see Figure 6 , including: a processor 801, a memory 802, and a computer program 8021 stored in the memory and executable on the processor, wherein when the processor executes the program, the method for mounting the database directory of the foregoing embodiment is implemented.

[0166] The present invention also provides a readable storage medium, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the database directory mounting method of the aforementioned embodiment.

[0167] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0168] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to realize the content of the present invention described herein, and the description of the above specific languages ​​is for disclosing the best mode of the present invention.

[0169] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0170] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.

[0171] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0172] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention may also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0173] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.

[0174] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0175] It should be noted that all actions of acquiring signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.

[0176] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

[0177] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for mounting a database directory, characterized in that: The method comprises: For any function directory in the database system, a storage volume configuration template corresponding to the function directory is predefined; the storage volume configuration template includes a host machine mount path corresponding to the function directory, and different function directories store data of different function types; Creating a target database cluster based on the storage volume configuration template corresponding to each of the function directories; For any target function directory, a target resource storage request corresponding to the target function directory is created through the target database cluster based on the storage volume configuration template corresponding to the target function directory; the target resource storage request carries target configuration information; Based on the target host machine mount path corresponding to the target function directory contained in the target configuration information, a target storage volume corresponding to the target function directory is created on the host machine corresponding to the database system; the target host machine mount path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume.

2. The method according to claim 1, characterized in that The step of creating a target database cluster based on the storage volume configuration template corresponding to each of the function directories includes: Parsing each of the storage volume configuration templates through a database controller to obtain template information corresponding to each of the storage volume configuration templates; Based on the template information corresponding to each of the storage volume configuration templates, a container group adaptation operation is performed on the preset database cluster to create the target database cluster.

3. The method according to claim 2, characterized in that Any of the template information includes specified container information, a path within the container, a host mount path, and a storage class name; The performing a container group adaptation operation on a preset database cluster based on the template information corresponding to each storage volume configuration template includes: For any of the storage volume configuration templates, a resource storage request template is generated based on the storage class name and the host mount path; the resource storage request template is used to create a resource storage request corresponding to the function directory; Mounting and configuring a specified container corresponding to the specified container information in the container group of the preset database cluster according to the path in the container; Generate environment variables according to the path in the container; Based on the environment variables, a container directory corresponding to the function directory is created in the designated container, and configuration of a startup configuration file corresponding to the initial database cluster is completed.

4. The method according to claim 1, characterized in that: The step of creating a target storage volume corresponding to the target function directory on a host corresponding to the database system based on the target host machine mount path corresponding to the target function directory included in the target configuration information includes: In a case where the target resource storage request carries a target host mount path, a target storage volume corresponding to the target function directory is created on the host corresponding to the database system based on the target host mount path corresponding to the target function directory contained in the target configuration information.

5. The method according to claim 1, characterized in that The step of creating a target storage volume corresponding to the target function directory on a host corresponding to the database system based on the target host machine mount path corresponding to the target function directory included in the target configuration information includes: Obtaining node information in the target resource storage request; Determining whether a mount path of the target host satisfies a target mount condition based on a temporary container group scheduled to the first target host corresponding to the node information; In a case where the target host mount path satisfies the target mount condition, a target storage volume corresponding to the target function directory is created on the first target host based on the target host mount path.

6. The method according to claim 4, characterized in that The method further comprises: When the target resource storage request does not carry a target host machine mount path, obtaining node information in the target resource storage request; Based on a designated mount path pre-configured for a second target host corresponding to the node information, a target storage volume corresponding to the target function directory is created on the second target host; the mount path corresponding to the target storage volume belongs to the designated mount path.

7. The method according to claim 1, characterized in that The method further comprises: For any of the functional directories, a target disk that meets the data storage requirements corresponding to the functional directory is mounted to the functional directory.

8. A database directory mounting device, characterized in that: The device comprises: A first definition module is used to predefine a storage volume configuration template corresponding to any function directory in the database system; the storage volume configuration template includes a host machine mount path corresponding to the function directory, and different function directories store data of different function types; A first creation module, configured to create a target database cluster based on the storage volume configuration template corresponding to each of the function directories; A second creation module is used to create, for any target function directory, a target resource storage request corresponding to the target function directory through the target database cluster based on the storage volume configuration template corresponding to the target function directory; the target resource storage request carries target configuration information; The third creation module is used to create a target storage volume corresponding to the target function directory on the host machine corresponding to the database system based on the target host machine mount path corresponding to the target function directory contained in the target configuration information; the target host machine mount path is used for the target database cluster to access the target data corresponding to the target function directory based on the target storage volume.

9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for mounting a database directory as described in any one of claims 1 to 7 when executing the program.

10. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the database directory mounting method described in any one of claims 1-7.

Citation Information

Cited By

  • Operation and maintenance management method and device for containerized environment, equipment and medium

    CN120653371A