Method and device for deploying high-availability database cluster of openGauss based on dynamic IP of K8s platform

By deploying CRD and Operator on the K8s platform to monitor and update the IP changes of openGauss database nodes, the high availability problem of openGauss database nodes in dynamic IP environments is solved, enabling rapid self-healing and cluster reconstruction, and ensuring the continuity and high availability of database services.

CN120910025BActive Publication Date: 2026-11-24BEIJING VASTDATA TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511093957.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-06
Publication Date
2026-11-24
Estimated Expiration
2045-08-06

AI Technical Summary

Technical Problem

In existing technologies, when openGauss database nodes are deployed on the K8s platform, fixed IP addresses lead to high network configuration complexity and increased operation and maintenance costs. Furthermore, in a dynamic IP environment, node identity recognition becomes chaotic, master-slave failover fails, and high availability is affected.

Method used

By deploying CRD and Operator on the K8s platform, monitoring changes in the IP of database nodes, updating CM configuration and streaming replication information, dynamic IP adaptation is achieved, including updating cluster configuration files and restarting related services, and supporting nodes to automatically join the cluster after IP changes.

Benefits of technology

It enables rapid self-healing and cluster reconstruction of openGauss database nodes in dynamic IP environments, ensuring the continuity and high availability of database services and reducing manual operation and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120910025B_ABST
    Figure CN120910025B_ABST
Patent Text Reader

Abstract

The application relates to an openGauss high-availability database cluster deployment method and device based on a K8s platform dynamic IP, aiming to solve the problem that openGauss nodes conflict with cloud native dynamic IP requirements due to IP fixed limitations under a traditional K8s environment, and the problem that nodes cannot automatically return to the cluster after IP changes. The method comprises the following steps: deploying CRD to define cluster configuration parameters, creating a Pod resource containing a database, a CM and an OM component based on CR through an Operator; collecting Pod IP and writing the same into a ConfigMap to complete cluster initialization; continuously listening to Pod IP changes, triggering an automatic update process (updating CM configuration, correcting stream replication parameters replconninfo and pg_hba.conf, cleaning old data and restarting services) when changes are detected, so that the node re-joins the cluster; and supporting automatic cluster parameter reconfiguration and old data cleaning when a Pod starts under a full IP change scenario. The application realizes fast self-recovery and cluster reconstruction of nodes under dynamic IP, guarantees database service continuity and high availability, and significantly reduces manual operation and maintenance costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of database deployment technology, and specifically relates to a method and apparatus for deploying an openGauss high-availability database cluster based on dynamic IP of the K8s platform. Background Technology

[0002] With the continuous evolution of cloud-native technologies and the widespread adoption of microservice architectures, enterprise databases are accelerating their transformation towards containerization, automation, and elasticity. Kubernetes (hereinafter referred to as K8s), as the current mainstream container orchestration platform, possesses core capabilities such as automated scheduling, horizontal elastic scaling, fault self-healing, and unified management across clouds / hybrid clouds. It can significantly reduce the operational complexity of databases and improve resource utilization. Compared to traditional deployment models based on physical machines or virtual machines, K8s can better meet the stringent requirements of modern businesses for rapid iteration, elastic scaling, and high availability, making the migration of database systems to cloud-native architecture an inevitable trend in technological evolution.

[0003] openGauss is an open-source relational database designed for core enterprise applications. Its high availability capability relies on a Cluster Manager (CM) module. CM integrates distributed consistency protocols (such as Raft or Paxos) to monitor cluster node status in real time, achieving second-level failover between primary and backup nodes and ensuring strong data consistency. This meets the stringent high availability (RTO < 30s) requirements of industries such as finance and telecommunications. This mechanism effectively solves the problems of low efficiency, poor reliability, and frequent manual intervention in traditional databases during primary / backup failover, aligning with the technical demands for automated operation and maintenance in the cloud-native era.

[0004] Typically, openGauss database nodes are deployed as containers within pods on a Kubernetes platform. However, in existing Kubernetes-based openGauss high-availability clusters managed by CM, it is generally required to configure database nodes with fixed IP addresses. This model significantly conflicts with cloud-native design principles: on the one hand, fixed IP addresses require manual pre-allocation and management, significantly increasing network configuration complexity and operational costs; on the other hand, cloud-native environments emphasize dynamic IP allocation through CNI (Container Network Interface) plugins or Service abstractions to automatically adapt to the elastic scaling and cross-cluster migration of nodes, thereby improving resource utilization and operational agility. Especially in multi-cloud or hybrid cloud deployment scenarios, the node migration capability with non-fixed IPs better aligns with the stateless design principles of microservices, significantly improving cluster resource utilization and operational agility.

[0005] Furthermore, the implementation of fixed IPs typically relies on specific network plugins, and this capability is lacking in some cloud environments, causing database node IP addresses to change after a restart. CM's identification of cluster nodes depends on IP stability; IP changes directly disrupt CM's node management mechanism, leading to serious consequences such as node identification confusion, failed master-slave failover, and operational interruptions. Ultimately, this prevents nodes from rejoining the cluster, causing the entire high-availability architecture to fail.

[0006] Therefore, how to achieve stable deployment of openGauss database nodes on the K8s platform based on dynamic IP while maintaining the high availability management capabilities of CM has become a key technical problem that urgently needs to be solved. Summary of the Invention

[0007] To address the aforementioned issues, this application proposes a novel method for deploying a high-availability openGauss database cluster based on dynamic IPs on a Kubernetes platform. The purpose of this invention is to provide a method and apparatus for deploying a CM-based openGauss high-availability database cluster supporting dynamic IPs on a Kubernetes platform. This method enables openGauss database nodes on the Kubernetes platform to monitor the database node whose IP has changed after a restart, and to send the changed IP information to other database nodes to update the CM configuration and the streaming replication information configuration between database nodes, thus allowing the restarted database node to rejoin the original database cluster.

[0008] Terminology Explanation: openGauss: Huawei's open-source enterprise-grade relational database, supporting high performance, high security, and high availability, and compatible with the PostgreSQL ecosystem.

[0009] OM (Operation Manager): openGauss's operation and maintenance management tool, providing one-stop operation and maintenance capabilities such as installation, configuration, and monitoring.

[0010] CM (Cluster Manager): The cluster management component of openGauss, responsible for node status monitoring, automatic failover, and load balancing.

[0011] K8s (Kubernetes): A container orchestration platform used to automate the deployment, scaling, and management of containerized applications.

[0012] Image: A read-only template containing the application and its dependencies, used to create container instances.

[0013] Operator: A Kubernetes extended controller that enables automated operation and management of complex applications by listening to changes in the Control Controller (CR).

[0014] CRD (Custom Resource Definition): An API extension in Kubernetes used to define custom resources. It is an extension mechanism of Kubernetes that allows users to create new resource types (i.e., custom resources) and extend API capabilities without modifying the Kubernetes source code.

[0015] CR (Custom Resource): A specific instance created based on a CRD, used to store and manage custom configurations or states.

[0016] Figure 1 The deployment architecture of this invention is shown. The main implementation strategy of this invention is as follows: using containerization technology, an image is created for an integrated package containing an openGauss database (openGauss 5.0.0 is used as an example in this embodiment), CM component, and OM component. Then, the core extension mechanism of K8s, CRD (Custom Resource Definition), CR (Custom Resource) and Operator, is used to manage the openGauss database, so as to realize declaration-based operation and maintenance, full life cycle management, automatic fault repair and dynamic IP support.

[0017] In this application, the Operator adds the database node whose IP address changed after a restart to the original high-availability architecture according to the following steps: 1. First, deploy CRD and Operator on the K8s platform to monitor the creation, update, and deletion operations of CRD; 2. The Operator creates database nodes, i.e. pod resources on K8s, based on the submitted CR information. This step pulls the openGauss database package image, creates N pods according to the number of database nodes N configured in the CR, and creates a CM (ConfigMap) which is mounted inside the pod to configure the CM cluster configuration file. 3. The Operator collects the pod's IP and hostname and updates them to the ConfigMap. Then, the pod reads the information in the ConfigMap until it has read the information of all nodes and its own information. After that, it starts configuring the CM cluster configuration file and creates an openGauss high-availability database cluster based on the CM cluster configuration. 4. The Operator listens to the IP address of the pod running the openGauss database and compares it with the ConfigMap from step 3. If the IP address changes, and the database status of the pod with the changed IP address is pending, the Operator updates the IP address on all nodes. The specific steps are as follows: (1) Update the database cluster configuration file of CM and generate a static configuration using the gs_om tool to overwrite the original static configuration; (2) Update the replconninfo in the database configuration postgresql.conf and the IP information in pg_hba.conf, and execute gs_ctl reload; (3) Clean up the old dcf_data and gstor data in the CM Server; (4) Restart om_monitor, cm_agent, and cm_server. If the node has changed its IP address, the database needs to be restarted. (5) Update the / etc / hosts configuration in the pod.

[0018] Building upon the above solutions, this invention further provides a method for restoring the original high-availability architecture when all IPs on the openGauss database nodes change. This typically occurs when a power outage or other unexpected event causes all host machines to crash. The entry script in the openGauss containerized image is configured to execute the following steps on each startup: (1) Reconfigure the database cluster configuration file of CM and generate a static configuration using the gs_om tool to overwrite the original static configuration; (2) Reconfigure the database configuration files postgresql.conf, including replconninfo and pg_hba.conf; (3) Clean up the old dcf_data and gstor data in cm_server.

[0019] More specifically, this application provides the following technical solutions: The first aspect of this application provides a method for deploying an openGauss high-availability database cluster based on dynamic IP addresses on a K8s platform, the method comprising: S1: Deploy custom resource definitions (CRDs) and operators on the Kubernetes platform; S2: The Operator creates a database node Pod resource based on the CR (Custom Resource) information submitted by the user. The Pod resource includes an openGauss database instance, a CM (Cluster Management Module) component, and an OM (Operations and Maintenance Management Module) component, and mounts a cluster configuration file template through a ConfigMap. S3: The Operator collects the IP address and hostname information of each Pod and updates it to the ConfigMap; after each Pod starts, it reads the cluster node information in the ConfigMap, completes the initialization of the CM cluster configuration file, and establishes the openGauss high-availability database cluster. S4: The Operator continuously monitors changes in the IP addresses of each Pod. When it detects a change in the IP address of any Pod, it triggers the IP update process. S5: After all services have started and streaming replication has been synchronized, the Pod with the changed IP is rejoined to the original high-availability cluster to complete the dynamic IP adaptation.

[0020] Furthermore, in the method of this application, the CRD mentioned in step S1 is used to define the declarative configuration parameters of the openGauss database cluster. The configuration parameters include: the number of database nodes, the openGauss package image version, the CM cluster communication port, the streaming replication synchronization mode, and the storage volume mount path. The Operator is used to perform full lifecycle management of the cluster based on the CRD.

[0021] Furthermore, in the method of this application, the creation of database node Pod resources in step S2 includes: based on the number of nodes N specified in the CR, pulling the pre-packaged openGauss all-in-one package image, and creating N independent Pods, each Pod containing an independent database instance, CM component and OM component.

[0022] Furthermore, in the method of this application, the way the Operator collects the IP address and hostname information of each Pod in step S3 is as follows: periodically query the Pod status through the K8s API to obtain the status.podIP field and metadata.name field of each Pod as the hostname.

[0023] Furthermore, in the method of this application, the change of the IP address of the Pod in step S4 is detected in the following way: the Operator maintains a cache of old IP information, and iterates through all Pods every preset time interval (e.g., 30 seconds) to compare the current Pod IP with the old IP in the cache. If there is an inconsistency, it is determined that the IP has changed.

[0024] Furthermore, in the method of this application, the IP update process in step S4 includes the following steps: S41: Confirm that the database instance corresponding to the Pod whose IP has changed is in a pending state. S42: Update the old IP in the CM cluster configuration file to the new IP by executing a pre-set script and generate a static configuration file to overwrite the original file; S43: Modify the old IP in the streaming replication connection information (replconninfo) of the database configuration file (postgresql.conf) and the access control configuration file (pg_hba.conf) within this Pod; S44: Clean up the old stream replication data (dcf_data) and storage data (gstor) in the CM Server corresponding to this Pod. S45: Restart OM-related services (om_monitor, cm_agent, cm_server). If it is an IP-changed node, restart the database instance simultaneously.

[0025] Furthermore, in the method of this application, the pre-set script mentioned in step S42 is integrated into the entry script of the openGauss all-in-one package image, which is used to receive new IP parameters and perform the following operations: call the gs_om tool to modify the node IP list in the CM cluster configuration file (cm_server.conf), generate a new static configuration file (cm_server.conf.static) and override the runtime configuration.

[0026] Furthermore, in the method of this application, the specific operations of modifying the database configuration file within the Pod in step S43 include: Update the replconninfo parameter in postgresql.conf, replacing the old IP with the new IP while retaining the port information; Update the rules for allowed remote node IPs in pg_hba.conf, replacing the old IPs with the new ones; The specific operations for restarting OM-related services in step S45 include: automatically restarting the om_monitor process, cm_agent agent process, and cm_server main service process by killing child processes.

[0027] Furthermore, the method in this application also includes a full IP change recovery process. When all database nodes experience IP changes due to host machine failure, each Pod automatically executes the following steps upon startup: (1) Use the gs_om tool to regenerate the CM cluster configuration file and overwrite the original static configuration; (2) Reconfigure the replconninfo in postgresql.conf and the IP rules in pg_hba.conf; (3) Clean up the old stream copy data (dcf_data) and storage data (gstor) in the cm_server directory.

[0028] A second aspect of this application provides a deployment device for an openGauss high-availability database cluster based on dynamic IP on a K8s platform, the device comprising: The component management module is used to deploy custom resource definitions (CRDs) and operators on the Kubernetes platform. The Operator module is used to parse the CR information submitted by the user based on the CRD, create Pod resources containing database nodes, CM components and OM components, and manage cluster configuration files through ConfigMap; The information collection module is used to collect the IP address and hostname information of each Pod and update it in the ConfigMap; The cluster building module is used to read the cluster node information in the ConfigMap after each Pod starts, complete the initialization of the CM cluster configuration file, and establish the openGauss high-availability database cluster. The IP monitoring module is used to continuously monitor changes in the IP addresses of each Pod and trigger the IP update process. The configuration update module is used to update the CM cluster configuration file and database streaming replication configuration file (postgresql.conf, pg_hba.conf) when an IP change is detected, clean up old streaming replication data, and restart related services.

[0029] The aforementioned device implements the steps of the aforementioned openGauss high-availability database cluster deployment method based on dynamic IP of the K8s platform during operation.

[0030] A third aspect of this application provides an electronic device, including: a memory and a processor; Memory: Used to store computer programs; Processor: Used to execute the computer program to implement the steps of the aforementioned openGauss high-availability database cluster deployment method based on dynamic IP of the K8s platform.

[0031] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the aforementioned openGauss high-availability database cluster deployment method based on dynamic IP of the K8s platform.

[0032] In summary, this invention proposes a method and apparatus for deploying a high-availability openGauss database cluster based on dynamic IPs on the Kubernetes platform. It encapsulates the openGauss database, CM (Cluster Management), and OM (Operations Management) components into a single package image using containerization. Combined with Kubernetes' CRD (Custom Resource Definition), CR (Custom Resource), and Operator, it achieves declarative operations and full lifecycle management. An innovative dynamic IP adaptation mechanism is designed, which uses the Operator to monitor Pod IP changes in real time, compares the old IP cache, and triggers an automated update process (including updating the CM cluster configuration file, correcting database stream replication parameters (replconninfo) and access control configuration (pg_hba.conf), cleaning up old stream replication data, and restarting the service). It also supports automatic reconfiguration of cluster parameters and cleanup of old data when the Pod starts up in scenarios with full IP changes. This invention solves the problem that openGauss nodes in a Kubernetes environment cannot automatically return to a high-availability cluster after IP changes due to restarts or host failures. It achieves rapid self-healing and cluster reconstruction of nodes in dynamic IP scenarios, ensuring the continuity and high availability of database services and significantly reducing manual operation and maintenance costs.

[0033] Other features and advantages of this application will be set forth in detail in the following description, or will become apparent through the implementation of the relevant technical solutions of this application. The objectives and other advantages of this application can be achieved through the technical features and means explicitly pointed out in the description, claims, and drawings, and will be obtained through the implementation of these technical contents. Attached Figure Description

[0034] To more clearly illustrate the technical solution of this application, the accompanying drawings involved in the description of the embodiments will be briefly introduced below. It should be noted that the drawings only show some embodiments of this application. For those skilled in the art, other related drawings can be derived from these drawings without creative effort.

[0035] Figure 1 This is a deployment architecture diagram of the present invention.

[0036] Figure 2 This is a flowchart illustrating the overall implementation process of the openGauss high-availability database cluster deployment method based on dynamic IP on the K8s platform in this application.

[0037] Figure 3 This is a flowchart illustrating the operational framework of the method described in this application.

[0038] Figure 4 This is a structural diagram of the openGauss high-availability database cluster deployment device based on dynamic IP of the K8s platform in this application.

[0039] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0040] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be noted that the described embodiments are only some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the protection scope of this application.

[0041] In this document, the term "comprising" and any variations thereof (such as "including," "including," etc.) are open-ended expressions and should be understood as "including but not limited to," meaning that the listed content is not exhaustive and may include other content not explicitly mentioned. The term "based on" should be understood as "at least partially based on," meaning that the basis or condition referred to may not be the only factor and may involve other relevant factors. The term "one embodiment" should be understood as "at least one embodiment," meaning that the described embodiment is not the only possible implementation, and other similar embodiments may exist.

[0042] In this application, the terms "a" and "a plurality of" are used to modify related elements or features, and their expression is illustrative rather than restrictive. Unless otherwise expressly stated in the context, "a" should be understood as "at least one," and "a plurality of" should be understood as "at least two." Those skilled in the art should reasonably interpret these terms based on the semantic and logical relationships of the context to ensure that they cover the possibility of "one or more."

[0043] Figure 2 The diagram shows the overall implementation process of the openGauss high-availability database cluster deployment method based on dynamic IP of the K8s platform provided in this application, including the following steps: S1: Deploy custom resource definitions (CRDs) and operators on the Kubernetes platform; S2: The Operator creates a database node Pod resource based on the CR (Custom Resource) information submitted by the user. The Pod resource includes an openGauss database instance, a CM (Cluster Management Module) component, and an OM (Operations and Maintenance Management Module) component, and mounts a cluster configuration file template through a ConfigMap. S3: The Operator collects the IP address and hostname information of each Pod and updates it to the ConfigMap; after each Pod starts, it reads the cluster node information in the ConfigMap, completes the initialization of the CM cluster configuration file, and establishes the openGauss high-availability database cluster. S4: The Operator continuously monitors changes in the IP addresses of each Pod. When it detects a change in the IP address of any Pod, it triggers the IP update process. S5: After all services have started and streaming replication has been synchronized, the Pod with the changed IP is rejoined to the original high-availability cluster to complete the dynamic IP adaptation.

[0044] To more clearly illustrate the technical solution of this application, the following will provide further explanation through specific scenario embodiments.

[0045] This embodiment provides a method for deploying a high-availability openGauss database based on dynamic IP on the K8s platform. First, upload the Operator and openGauss package images to the image repository. Then, pre-configure the CRD on the K8s platform and install the Operator. After submitting the CRD, the openGauss high-availability database will be successfully created.

[0046] When a node in the openGauss high-availability database cluster fails or is unexpectedly restarted, such as Figure 3 As shown, the processing flow of the Operator process is as follows: After a pod is created but before the openGauss database within the pod is created, the Operator collects the pod's IP information to configure the CM cluster configuration file, thereby creating the openGauss database cluster. The Operator saves information about the old pods and queries the IP information of existing pods through a control loop, comparing the two. When it detects a change in the IP information of an existing pod, it initiates the process of adding the database node with the changed IP to the original high-availability database architecture. 1. First, confirm the database status of the node whose IP has changed. Use the gs_ctl status command to query whether the database is in the running state and needs to be in the pending state, indicating that the database has started and is in a pending state. 2. The Operator uses the before and after IP addresses as parameters and executes shell commands via `exec pod` to call the pre-defined IP change process script in the openGauss database image. The execution target is each pod. 3. Replace the old IP in the CM cluster configuration file with the new IP. Use the gs_om command to change it back to a static configuration file and replace the old file. 4. Replace the replconninfo information in the postgresql.conf configuration file in the openGauss database data directory, and replace the old IP in the pg_hba.conf configuration. This step is to add nodes with changed IPs to the database streaming replication. 5. Clean up the dcf_data and gstor data of cm_server, and restart the relevant components of OM and CM. If the node is a node whose IP has changed, the database service needs to be restarted. The purpose of this step is to clean up the old streaming replication data and restart the CM service to use the latest cluster configuration. After the above process is completed, wait for each service to start. Once streaming replication is complete, the openGauss database high availability architecture will return to normal. All of the above operations will not affect the normal use of the database service.

[0047] Figure 4 The image shows a deployment device for an openGauss high-availability database cluster based on dynamic IP on a K8s platform, as proposed in this application. The device includes: The component management module is used to deploy custom resource definitions (CRDs) and operators on the Kubernetes platform. The Operator module is used to parse the CR information submitted by the user based on the CRD, create Pod resources containing database nodes, CM components and OM components, and manage cluster configuration files through ConfigMap; The information collection module is used to collect the IP address and hostname information of each Pod and update it in the ConfigMap; The cluster building module is used to read the cluster node information in the ConfigMap after each Pod starts, complete the initialization of the CM cluster configuration file, and establish the openGauss high-availability database cluster. The IP monitoring module is used to continuously monitor changes in the IP addresses of each Pod and trigger the IP update process. The configuration update module is used to update the CM cluster configuration file and database streaming replication configuration file (postgresql.conf, pg_hba.conf) when an IP change is detected, clean up old streaming replication data, and restart related services.

[0048] The above-mentioned device implements the steps of the openGauss high-availability database cluster deployment method based on dynamic IP of the K8s platform disclosed in this application when it is running.

[0049] The flowcharts and block diagrams in the accompanying drawings illustrate possible implementations of apparatus, methods, and computer program products according to various embodiments of this application, including architecture, functionality, and operation. In these figures, each block may represent a module, program segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should be noted that each block in the block diagrams and / or flowcharts, and combinations thereof, can be implemented using either a dedicated hardware-based system or a combination of dedicated hardware and computer instructions to achieve the specified function or operation.

[0050] like Figure 5 As shown, embodiments of this application also disclose an electronic device, including: a processor 310, a communication interface 320, a memory 330 for storing processor-executable computer programs, and a communication bus 340. The processor 310, communication interface 320, and memory 330 communicate with each other via the communication bus 340. The processor 310 executes the executable computer program to implement the steps of the above-described method for deploying an openGauss high-availability database cluster based on dynamic IP on the K8s platform.

[0051] It is understood that, in addition to memory and a processor, this electronic device may also include input devices (such as a keyboard), output devices (such as a display), and other communication modules. These input devices, output devices, and other communication modules all communicate with the processor through I / O interfaces (i.e., input / output interfaces).

[0052] The operations described in this application can be implemented by writing computer program code using one or more programming languages ​​or a combination thereof. The programming languages ​​include, but are not limited to, the following types: Object-oriented programming languages, such as Java, Smalltalk, C++, etc. Conventional procedural programming languages, such as "C" or similar programming languages.

[0053] The execution methods of program code include, but are not limited to: It runs entirely on the user's computer; Part of it executes on the user's computer, and part of it executes on a remote computer; Execute as a standalone software package; It is executed entirely on a remote computer or server.

[0054] In scenarios involving remote computers, the remote computer can connect to the user's computer via any type of network, including but not limited to local area networks (LANs) or wide area networks (WANs). Furthermore, the remote computer can also connect to external computers through an internet service provider, for example, by utilizing the internet for connection.

[0055] Furthermore, this application also discloses a computer-readable storage medium, wherein when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is able to perform the various steps of the openGauss high-availability database cluster deployment method based on dynamic IP of the K8s platform disclosed in this application.

[0056] In the context of this application, a computer-readable storage medium refers to a tangible medium capable of storing computer program code and related data. Specific examples include, but are not limited to, the following: (1) Portable computer disk: such as floppy disks and other removable magnetic storage media.

[0057] (2) Hard disk: including mechanical hard disks and solid-state hard disks and other fixed storage devices.

[0058] (3) Random Access Memory (RAM): A volatile storage medium used for temporary storage of data and program code.

[0059] (4) Read-only memory (ROM): a non-volatile storage medium used to store fixed programs and data.

[0060] (5) Erasable programmable read-only memory (EPROM) or flash memory: non-volatile storage media that supports multiple erasures and reprogrammings.

[0061] (6) Fiber optic storage devices: storage media based on fiber optic technology.

[0062] (7) Portable compact disc read-only memory (CD-ROM): a read-only medium that stores data in the form of an optical disc.

[0063] (8) Optical storage devices: such as DVDs, Blu-ray discs and other storage media based on optical principles.

[0064] (9) Magnetic storage devices: such as magnetic tapes, disks and other storage media based on magnetic principles.

[0065] (10) Any suitable combination of the above: for example, combining multiple storage media to meet different storage needs.

[0066] These computer-readable storage media can be used to store the program code and related data described in this application to support program execution and persistent data storage.

[0067] Specifically, according to embodiments of this application, the processes described in the flowcharts can be implemented as computer software programs. For example, embodiments of this application relate to a computer program product comprising a computer program carried on a non-transitory computer-readable medium. This computer program contains program code for executing the openGauss high-availability database cluster deployment method based on dynamic IP of the K8s platform disclosed in this application. When the computer program is executed by a processing device, it can achieve the functions defined in the embodiments of this application.

[0068] While the foregoing discussion contains several specific implementation details, these details should not be construed as limiting the scope of this application. The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this application is not limited to technical solutions formed by specific combinations of the above-described technical features. Furthermore, this application should also cover other technical solutions formed by any combination of the above-described technical features or their equivalents without departing from the foregoing disclosed concept.

[0069] Those skilled in the art should also understand that modifications can be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features, without departing from the spirit and scope of the technical solutions of the embodiments of this application. These modifications or substitutions will not cause the essence of the corresponding technical solutions to deviate from the core spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for deploying a highly available openGauss database cluster based on dynamic IP on the Kubernetes platform, characterized in that, The method includes: S1: Deploy custom resource definitions (CRDs) and operators on the Kubernetes platform; S2: The Operator creates a database node Pod resource based on the CR information submitted by the user. The Pod resource includes an openGauss database instance, CM component and OM component, and mounts the cluster configuration file template through ConfigMap. S3: The Operator collects the IP address and hostname information of each Pod and updates it to the ConfigMap; after each Pod starts, it reads the cluster node information in the ConfigMap, completes the initialization of the CM cluster configuration file, and establishes the openGauss high-availability database cluster. S4: The Operator continuously monitors for changes in the IP addresses of each Pod. When a change in the IP address of any Pod is detected, an IP update process is triggered. The IP update process includes the following steps: S41: Confirm that the database instance status corresponding to the Pod whose IP has changed is pending. S42: Update the old IP in the CM cluster configuration file to the new IP by executing a pre-set script and generate a static configuration file to overwrite the original file; S43: Modify the streaming replication connection information and the old IP in the access control configuration file of the database configuration file within the Pod that has undergone an IP change; the specific steps for modifying the database configuration file within the Pod that has undergone an IP change include: Update the replconninfo parameter in postgresql.conf, replacing the old IP with the new IP while retaining the port information; Update the rules for allowed remote node IPs in pg_hba.conf, replacing the old IPs with the new ones; S44: Clean up old stream replication data and stored data in the CM Server corresponding to the Pod whose IP has changed; S45: Restart OM-related services. If it is an IP change node, restart the database instance simultaneously. The specific operation of restarting OM-related services includes: automatically restarting the om_monitor process, cm_agent agent process, and cm_server main service process by killing child processes. S5: After all services have started and streaming replication has been synchronized, the Pod with the changed IP is rejoined to the original high-availability cluster to complete the dynamic IP adaptation.

2. The method according to claim 1, characterized in that, The CRD mentioned in step S1 is used to define the declarative configuration parameters of the openGauss database cluster. The configuration parameters include: the number of database nodes, the openGauss package image version, the CM cluster communication port, the streaming replication synchronization mode, and the storage volume mount path. The Operator is used to perform full lifecycle management of the cluster based on the CRD.

3. The method according to claim 1, characterized in that, The creation of database node Pod resources in step S2 includes: based on the number of nodes N specified in CR, pulling the pre-packaged openGauss all-in-one package image, creating N independent Pods, each Pod containing an independent database instance, CM component and OM component.

4. The method according to claim 1, characterized in that, The method by which the Operator collects the IP address and hostname information of each Pod in step S3 is as follows: periodically query the Pod status through the K8s API to obtain the status.podIP field and metadata.name field of each Pod as the hostname.

5. The method according to claim 1, characterized in that, The IP address change of the Pod mentioned in step S4 is detected in the following way: The Operator maintains a cache of old IP information, and iterates through all Pods at a preset time interval, comparing the current Pod IP with the old IP in the cache. If there is a discrepancy, it is determined that the IP has changed.

6. The method according to claim 1, characterized in that, The pre-configured script mentioned in step S42 is integrated into the entry script of the openGauss all-in-one package image. It is used to receive new IP parameters and perform the following operations: call the gs_om tool to modify the list of node IPs in the CM cluster configuration file, generate a new static configuration file, and override the runtime configuration.

7. The method according to claim 1, characterized in that, The method also includes a full IP change recovery process. When all database nodes experience IP changes due to host machine failure, each Pod automatically executes the following steps upon startup: (1) Use the gs_om tool to regenerate the CM cluster configuration file and overwrite the original static configuration; (2) Reconfigure the replconninfo in postgresql.conf and the IP rules in pg_hba.conf; (3) Clean up the old stream copy data and stored data in the cm_server directory.

8. A deployment device for a highly available openGauss database cluster based on dynamic IP on the K8s platform, characterized in that, The device includes: The component management module is used to deploy custom resource definitions (CRDs) and operators on the Kubernetes platform. The Operator module is used to parse the CR information submitted by the user based on the CRD, create Pod resources containing database nodes, CM components and OM components, and manage cluster configuration files through ConfigMap; The information collection module is used to collect the IP address and hostname information of each Pod and update it in the ConfigMap; The cluster building module is used to read the cluster node information in the ConfigMap after each Pod starts, complete the initialization of the CM cluster configuration file, and establish the openGauss high-availability database cluster. The IP monitoring module is used to continuously monitor changes in the IP addresses of each Pod and trigger the IP update process; the IP update process includes the following steps: (1) Confirm that the database instance corresponding to the Pod whose IP has changed is in a pending state; (2) Update the old IP in the CM cluster configuration file to the new IP by executing the pre-set script to call the tool, and generate static configuration to overwrite the original file; (3) Modify the old IP in the stream replication connection information and access control configuration file of the database configuration file in the Pod where the IP has changed; the specific operations for modifying the database configuration file in the Pod where the IP has changed include: Update the replconninfo parameter in postgresql.conf, replacing the old IP with the new IP while retaining the port information; Update the rules for allowed remote node IPs in pg_hba.conf, replacing the old IPs with the new ones; (4) Clean up the old stream replication data and stored data in the CM Server corresponding to the Pod whose IP has changed; (5) Restart OM-related services. If it is an IP change node, restart the database instance synchronously. The specific operation of restarting OM-related services includes: killing child processes to automatically start the om_monitor process, cm_agent agent process and cm_server main service process by the daemon process to complete the restart. The configuration update module is used to update the CM cluster configuration file and database stream replication configuration file, clean up old stream replication data, and restart related services when an IP change is detected.

Citation Information

Patent Citations

  • Software deployment method and device based on Kubernetes platform

    CN114138754A