[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN114138754B - Software deployment method and device based on Kubernetes platform - Google Patents

Software deployment method and device based on Kubernetes platform Download PDF

Info

Publication number
CN114138754B
CN114138754B CN202111502544.4A CN202111502544A CN114138754B CN 114138754 B CN114138754 B CN 114138754B CN 202111502544 A CN202111502544 A CN 202111502544A CN 114138754 B CN114138754 B CN 114138754B
Authority
CN
China
Prior art keywords
database
node
mha
software
master node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111502544.4A
Other languages
Chinese (zh)
Other versions
CN114138754A (en
Inventor
李瑞友
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anchao Cloud Software Co Ltd
Original Assignee
Anchao Cloud Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Anchao Cloud Software Co Ltd filed Critical Anchao Cloud Software Co Ltd
Priority to CN202111502544.4A priority Critical patent/CN114138754B/en
Publication of CN114138754A publication Critical patent/CN114138754A/en
Application granted granted Critical
Publication of CN114138754B publication Critical patent/CN114138754B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1464Management of the backup or restore process for networked environments
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/76Adapting program code to run in a different environment; Porting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/80Database-specific techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a software deployment method based on a Kubernetes platform, which comprises the following steps: deploying a MySQL cluster on a Kubernetes platform, wherein the Kubernetes platform comprises a master node and a slave node; providing MHA software, and establishing connection between a Kubernetes platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes; responding to a request of a user for accessing a database, and selecting a database master node from a plurality of database nodes; generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node; and controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform. The method transfers the MHA to the Kubernetes platform, fully containerizes the enterprise application, and improves the resource utilization rate and the operation and maintenance efficiency.

Description

Software deployment method and device based on Kubernetes platform
Technical Field
The application relates to the technical field of cloud computing, in particular to a software deployment method and device based on a Kubernetes platform, electronic equipment and a computer readable storage medium.
Background
The software development has typically been preceded by the preparation of various operating environments, IDE (integrated development en vironment), auxiliary tools, etc. The delivery process of an available software usually comprises two parts of development and maintenance, and in practice, it is difficult to ensure that the software in the software development test and operation maintenance stage can operate in the same environment. The container technology well solves the problems, effectively divides the resources of a single operating system into isolated groups, and can better balance conflicting resource use requirements among the isolated groups. Container technology has become a very popular technology that can mask infrastructure inconsistencies. The container arrangement framework is used as a system core to serially develop, test, deploy, operate and maintain the whole software life cycle, is used as a Paas (platform-as-a-service) platform for providing standardized operation and maintenance flow, and can provide one-key deployment, dynamic scheduling, expansion and contraction capacity and various daemon mechanisms for the application.
In recent years Kubernetes has gradually unified the field of container orchestration, and many companies have begun to try to build application systems using k8s as the infrastructure. However, although the application has been migrated, the data of the application is too split outside, so that unified management is not easy, two sets of systems are required to be maintained, and a communication network is also required to be set up, so that the migration of the database has become an urgent idea of many enterprises.
MHA (MASTER HIGH availability) is a relatively mature solution in MySQL high availability at present, in the MySQL failover process, the MHA can automatically complete the database failover operation within 0-30 seconds, and in the failover process, the MHA can guarantee the consistency of data to the greatest extent so as to achieve high availability in the true sense. However, in the traditional MySQL MHA installation mode, the whole installation process is troublesome and may be affected by uncontrollable network, normally, the dba (Database Administrator) is generally deployed and completed in about 2-3 hours, and many tasks need to be repeated on at least three server nodes. The Chinese patent application CN202010616118.2 discloses a system and a method for ensuring high availability and consistency of MHA clusters, which mainly avoid the problem that MySQL clusters cannot be switched normally due to simultaneous failure of MHA and MySQ L clusters, and ensure the availability of user applications. The technical scheme adopted by the method is as follows: the Redis cluster is used for providing a published lock and configuring global notification issuing capability; when disaster recovery switching is executed, the MHA module registers an exclusive lock in the Redis cluster, so that other MHA examples are prevented from executing disaster recovery switching operation at the same time, and after switching is completed, the MHA module pushes the switching and then is configured to the Redis cluster and releases the lock; the MHA module is based on an MHA native tool and realizes locking and releasing of an exclusive lock and a configuration pushing function at two custom scripts of a second_check_script and an ip_ failove r _script; the configuration manager ensures that the local configuration of the MHA node remains consistent with other MHA moments. The system formed by the scheme has dependence on an external system, for example, redis is used to increase the error probability of the system, and the system is not a cloud-native scheme. Chinese patent application CN202010805534.7 discloses a ansiable-based mysql-mha cluster one-key deployment method and system, comprising the following steps: installing a mysql database on a server; creating an account in a main library and configuring a main node; the step of configuring the main library connection for the database is used for deploying and configuring mha base nodes; deploying and configuring the MHA management node; and (5) node deployment monitoring. However, the deployment of Ansible of the non-cloud native scheme is procedural, the running process is long, each link needs to be run once, and the dependence failure easily occurs.
In summary, database containerization is imperative, but the Kub ernetes platform is not particularly well designed for the highly available solutions of database clusters. Based on this, there is a need for improvements to existing Kubernetes-based platform databases.
Disclosure of Invention
The application aims to realize the adaptation of a Kubernetes platform and a database high-availability scheme so as to realize the comprehensive containerization of enterprise applications.
The application adopts the following technical scheme:
In a first aspect, the present application provides a software deployment method based on a Kubernetes platform, including: deploying a MySQL cluster on the Kubernetes platform, wherein the Kubernetes platform comprises a master node and a slave node; providing MHA software, and establishing connection between the Kubernetes platform and the MHA software, wherein the M HA software comprises a management node and a plurality of database nodes; responding to a request of a user for accessing a database, and selecting a database master node from the database nodes; generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node; and controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kuberne tes platform. The technical scheme has the advantages that the database cluster is deployed in a Kubernetes environment, the MySQL cluster is deployed in a Kubernetes platform, a MySQL cluster with 'master-slave copy' is formed in the Kubernetes environment, and the structure can be matched with 'one master and two slaves' of MHA software; in addition, considering that MHA software can work only by VIP and the IP of Kubernetes is dynamic, the application generates the master node label and the slave node label of the Kubernetes platform according to the information of the database master node and the management node by selecting the database master node from a plurality of database nodes, the labeling mode replaces the maintenance of the VIP, the MHA software is adapted to the database of the Kubernetes environment, and the capacity of the Kubernetes to manage the stateful high-availability database is expanded. Furthermore, the embodiment of the application can meet the requirements of standardized and rapid delivery, the flexible demand containerization and service trend of resources.
In some alternative embodiments, the master node and the slave node are determined by: selecting a master node through a write server of the Kubernetes platform to expose an access interface to read and write data for service application; and selecting the rest nodes except the master node as slave nodes through a read server of the Kubernetes platform.
In some alternative embodiments, mySQL clusters are deployed by statefulset on the Kubernetes platform; and adopting a semi-synchronous mode to form a structure comprising at least one master node and two slave nodes.
In some alternative embodiments, the Kubernetes platform further comprises an Operator, the Operat or comprising a tag controller and an MHA controller, the MHA controller comprising an MHA software manager for creation of the management node and an application configurator for implementing CRD state maintenance.
In some optional embodiments, generating the master node tag and the slave node tag of the Kubernetes platform according to the information of the database master node and the management node includes:
the label controller is used for connecting the management node, reading a log printed by the management node, and acquiring master node information of the management node in real time;
The method comprises the steps that a MySQL client is connected to a database node configured by a configuration file of the MHA software manager, and a database is entered to detect master node information of the database;
And generating a master node label and/or a slave node label for the nodes of the Kubernetes platform in response to the consistency of the master node information of the management node and the master node information of the database.
In some alternative embodiments, the MHA software includes one management node and three database nodes, and the management node, the database nodes each contain sshd_ sidecar.
In some alternative embodiments, the method further comprises: detecting whether nodes of the database are down; responding to the downtime of the nodes of the database, and after the nodes of the database are restored, restoring the management mode of the MHA software.
In a second aspect, the present application provides a software deployment device based on a Kubernetes platform, including:
The system comprises a Kubernetes platform module, a MySQL cluster and a MySQL server, wherein the Kubernetes platform module comprises a Kubernetes platform, and the Kubernetes platform comprises a master node and a slave node and is used for deploying the MySQL cluster on the Kubernetes platform;
The MHA software module is used for providing MHA software and establishing connection between the Kubernetes platform and the MHA software, and the MHA software comprises a management node and a plurality of database nodes;
The label labeling module is used for responding to a request of a user for accessing the database and selecting a database master node from a plurality of database nodes; generating a master node label and a slave node label of the Kuber netes platform according to the information of the database master node and the management node;
And the service sending module is used for controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform. The technical scheme has the beneficial effects that the existing mature high-availability database scheme MHA software is transplanted to the Kubernetes platform, so that the comprehensive containerization of enterprise application is realized, and the aspects of resource utilization rate, operation and maintenance efficiency and the like are contributed; the container deployment of the MySQL cluster database saves a great amount of manual operation processes of database administrators (Database Administrator, DBA), improves the efficiency, reduces the error rate and saves the operation and maintenance cost; the containerization of the MHA software also solidifies tedious operations, and the technical requirements on DBA are reduced greatly; for stateful application and stateless application, the whole cloud protogenesis fully utilizes the ecosystem functions of Kubernetes such as resource scheduling, service discovery, load balancing and the like, and improves the IT management level of enterprises.
In a third aspect, the present application provides an electronic device comprising a memory, a processor and a hardware module for performing tasks, the memory storing a computer program, the processor implementing the steps of any of the methods described above when executing the computer program.
In a fourth aspect, the present application provides a computer readable storage medium storing a computer program which when executed by a processor performs the steps of any of the methods described above.
Drawings
The application will be further described with reference to the drawings and examples.
FIG. 1 is a flowchart of a software deployment method based on a Kubernetes platform according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for determining a master node and a slave node according to an embodiment of the present application;
FIG. 3 is a flowchart of a method for generating a master node tag and a slave node tag according to an embodiment of the present application;
FIG. 4 is a flowchart of a software deployment method based on a Kubernetes platform according to another embodiment of the present application;
FIG. 5 is a block diagram of a software system based on the Kubernetes platform according to one embodiment of the present application;
FIG. 6 is a block diagram of a software deployment device based on a Kubernetes platform according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a program product for implementing the type selection method according to an embodiment of the present application.
Detailed Description
The present application will be further described with reference to the accompanying drawings and detailed description, wherein it is to be understood that, on the premise of no conflict, the following embodiments or technical features may be arbitrarily combined to form new embodiments.
Kubernetes is a set of declarative resource orchestration frameworks that support automated deployment, large-scale scalability, and application containerization management. When an application is deployed in a production environment, multiple instances of the application are typically deployed to load balance application requests. In Kubernetes, multiple containers may be created, one application instance running in each container, and then management, discovery, and access to the set of application instances are implemented through a built-in load balancing policy, where these details do not require operation and maintenance personnel to perform complex manual configuration and processing. However, kubernetes has its own unique modes of use, such as: the IP address of the container is not fixed and changes after the handover. Traditional software and system solutions need to be transformed to a cloud native platform architecture. Database containerization is imperative, but the Kubernetes platform is not a particularly well-off-the-shelf design for highly available solutions to database clusters.
The application provides a software deployment method based on a Kubernetes platform, which can transplant the existing mature database high Availability scheme MHA (MASTER HIGH Availability) to the Kubernetes platform and make a contribution to the aspects of comprehensive containerization of enterprise application, improvement of resource utilization rate, operation and maintenance efficiency and the like.
Referring to fig. 1, the embodiment of the application provides a software deployment method based on a Kubernetes platform, which can realize migration of traditional software and system solutions to a cloud native platform architecture based on the Kubernetes. The software deployment method based on the Kubernetes platform comprises steps S101-S105.
Step S101, mySQL clusters are deployed on a Kubernetes platform, wherein the Kubernetes platform comprises a master node and a slave node.
Step S102, providing MHA software, and establishing connection between the Kubernetes platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes.
Step S103, responding to the request of the user for accessing the database, selecting a database master node from a plurality of database nodes.
Step S104, generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node.
Step S105, the MHA software is controlled to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform.
In the embodiment of the application, mySQL clusters are deployed on a Kubernetes platform, a MySQL cluster of 'master-slave replication' (Maser-Slave Replication) is formed in the Kubernetes environment, and the structure can be matched with 'one master and two slaves' of MHA software; in addition, considering that the MHA can only operate by VIP and the IP of the Kubernetes is dynamic, the application generates the master node label and the slave node label of the Kubernetes platform according to the information of the database master node and the management node by selecting the database master node from a plurality of database nodes, and the labeling mode replaces the maintenance of the VIP, so that the MHA can operate in Ku bernetes environment, and the capacity of the Kubernetes for managing the stateful high-availability database is expanded. Furthermore, the embodiment of the application can meet the requirements of standardized and rapid delivery, the flexible demand containerization and service trend of resources.
In one embodiment, the MySQL cluster is deployed by statefulset on the Kubernetes platform. Illustratively, statefulset controller starts one Pod at a time in sequence with a sequence index, and st atefulset controller waits until each Pod reports ready to restart the next Pod. statefulset the controller assigns each Pod a unique, stable name, like < statefulset name > - < ordinal index >. Pods are finally named mysql-0, mysql-1 and mysql-2. Further, considering that statefulset needs a stable access name, a header needs to be built. statefulset can be responsible for Pod-stable network identification through headless, and intra-cluster access needs to use $ (Pod name) $ (DN S domain name of the service) set by the serviceName domain of statefulset.
The Kubernetes platform may include a master node and a slave node. In this embodiment, the Kubernetes platform employs a semi-synchronous mode to form a structure containing 1 Master node (Master), multiple Slave nodes (Slave) by deploying MySQL clusters.
As shown in fig. 2, the master node and the slave node are determined by:
step S201, selecting a master node through a writing server of a Kubernetes platform to expose an access interface to read and write data for a business application;
Step S202, selecting the rest nodes except the master node as slave nodes through a read server of the Kubernetes platform. In the embodiment of the application, the related nodes can be horizontally expanded, and all write operations can be executed only on the master node; the read operation may be performed on all nodes.
In one embodiment, when MySQL statefulset first generates a database cluster, mysql-0 is m aster node, and after mysql-0 is generated, the statefulset controller of the Kubernetes platform ensures that mysql-1 and mysql-2 are regenerated through defining script logic in statefulset yaml files.
Illustratively, statefulset yaml defines an init container and an application container, each adding an initialization script. The init container may comprise an init-mysql container and a clone-mysql container, wherein: the init-mysql container can determine whether to be a master (master database) or a slave (slave database) based on pod ordinal index, thereby generating a corresponding database profile; the clone-mysql container copies database data from M aster or other Slave Pod to its own directory before the Slave Pod is started, i.e., if ordi nal index is not equal to 0, then ncat and xtrabackup are used to backup the complete data from the previous container and apply to the present Pod.
Illustratively, the application pod also contains a containers container and xtrabackup containers. Wherein for the containers: if the container has backup data, directly starting the container as SLAVE MYS QL containers, deploying conventional database examples, setting storage volumes and checking health; for xtrabackup containers: after initialization of the MySQL node, the second job of this sidecar container is to start a data transfer service, expose a transfer port with ncat, and prepare backup data for the next pod in sequence.
The MHA software may include a management node and a plurality of database nodes, and the management node, the database nodes each include SSHD SIDECAR. In one embodiment, the MHA software creates MHA MANAGER (management) node and MHA node (database) base images for the containerized MHA, respectively, and installs the pe rl-dependent package. The MHA node is provided with a MySQL database, and communication between the MHA MANAGER node and the MHA node is through ssh protocol. Alternatively, the mirror image system is to make ssh password-free type, and a unified pair of public and private keys can be used for simplicity.
Illustratively, the MHA software switching logic may include:
Firstly, checking when the MHA MANAGER node is started, checking copy configuration according to a configuration file and identifying a current master; detecting MHA configuration setting and confirming the current master when abnormality occurs;
Then, determining a new master according to the judging process, and blocking writing into the current master;
Then, wait for all slave servers to complete synchronization with the existing master, grant write rights at the new master, and switch slave libraries in parallel.
It will be appreciated that the app1.Failover. Complete file needs to be manually deleted after the MHA software switch to be restarted MHA MANAGER. And the fault database needs to be manually re-added to the MHA environment once the handoff management process is exited.
The Kubernetes platform also includes an Operator comprising MHA-controllers and labe l-controllers, wherein: the MHA-controller comprises an MHA software manager for creating the management node and an application configurator for realizing CRD state maintenance. In one embodiment, an MHA software manager (MHA-manager) is responsible for the creation of MHA-manager pods; the real-time generation of the profile piece app. Conf configmap, and state maintenance. label-c ontroller can generate master node labels and slave node labels.
In one embodiment, the logic of the MHA-controller includes:
Firstly, an Operator firstly defines a Kubernetes custom object MHAMANAGERINSTANCE ST ruct, a structure body comprises two parts of fields spec and status, the spec internally refers to pod definition and configma p definition, and pod is mainly yaml information required for defining a containerized MHA-manager instance, such as a containerized mirror image, cpu, memory specification and the like;
second, configmap generates the server segment definitions, particularly the hostname, required for the MHA-manager instance profile based on the name and copy number of MySQL statefulset. In the traditional environment, the hostname configures an IP address inside the IaaS infrastructure, while in the Kubernetes environment, the IP of the pod is used clusterIP, which is dynamically generated along with the scheduling, and as long as the pod is rescheduled for some reason, a new IP may be generated. Only the unique internal DNS name assigned to the pod by the Kubernetes controller can be configured inside configmap.
Besides the previous, a CRD state is maintained, a down machine occurs in the database, the label-controller detects an abnormality, the MHA-controller is notified, and CRD MHAMANAGERINSTANCE status states are updated to down.
In one embodiment, the label-controller can implement a labeling process: the key point of the label-controller design is that the characteristic that the original VIP is attached to a master in an IaaS environment is changed into a mode that MySQL roles are attached to the master pod in a Kubernetes environment by labels, the specific method is that the label-co ntroller is connected with the MHA-manager pod, a log printed by the MHA-manager is read, and MYSQL MASTER node information is obtained in real time. In order to ensure the safety, the database node configured by the configuration file connected to the MHA-manager through MYSQL CLIENT is accessed to detect master-slave information again, the two information are consistent, kubernetes controller objects are called, the corresponding pod is labeled with a label_M (master node label), and the other nodes are labeled with label_S (slave node labels).
In this embodiment, two controllers included in the Operator can generate a master node tag and a slave node tag according to information of the database master node and the management node:
step S301, a label controller is used for connecting the management node, a log printed by the management node is read, and master node information of the management node is obtained in real time;
Step S302, a MySQL client is connected to a database node configured by a configuration file of an MHA software manager, and the database node enters into master node information of a database detection database;
Step S303, a master node label and/or a slave node label are generated for the nodes of the Kubernetes platform in response to the consistency of the master node information of the management nodes and the master node information of the database.
Considering that MHA software does not automatically repair down nodes and restore the down nodes into a cluster, but needs intervention of DBA personnel, manually restores the down nodes, and re-makes old hosts into slave and joins the slave into a database cluster. The label-controller of the application also has the function of recovering fault nodes: after detecting that the database node is restored, deleting the failover.complex file, calling the MHA-controller, and updating CRD MHAMANAGERINST ANCE status field to be recovery-complex. The Reconcile function of the MHA-controller listens for update events, invokes the generation logic that creates MHA-manager pod and configmap, restarts the MHA-manager instance, and resumes the MHA high availability management mode.
In one embodiment, the method for deploying software based on the Kubernetes platform includes steps S401 to S407.
Step S401, a MySQL cluster is deployed on a Kubernetes platform, wherein the Kubernetes platform comprises a master node and a slave node.
Step S402, providing MHA software and establishing a connection between the Kubernetes platform and the MHA software, where the MHA software includes a management node and a plurality of database nodes.
Step S403, selecting a database master node from the plurality of database nodes in response to a request from a user to access the database.
And step S404, generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node.
Step S405, detect node downtime of database? If the detection result is yes (the node of the database is down), the step S406 is entered; if the detection result is no (the node of the database is not down), step S407 is entered.
Step S406, after the nodes of the database are restored, the management mode of the MHA software is restored, and the process proceeds to step S407.
Step S407, controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform.
In the embodiment of the application, taking into account that the MHA software can be operated only by VIP, and the Kubernetes platform needs to be dynamic by IP, the maintenance of the VIP is replaced by a labeling mode, so that the MHA software is operated on the Kubernetes platform, and the capacity of the Kubernetes to manage a stateful high-availability database is expanded; the container deployment of the MySQL cluster database saves a great amount of manual operation processes of database administrators (Database Admini strator, DBA), improves the efficiency, reduces the error rate and saves the operation and maintenance cost; the containerization of the MHA software also solidifies tedious operations, and the technical requirements on DBA are reduced greatly; for stateful application and stateless application, the whole cloud protogenesis fully utilizes the ecosystem functions of Kubernetes such as resource scheduling, service discovery, load balancing and the like, and improves the IT management level of enterprises.
It should be noted that the above description of the software deployment method flow based on the Kubernetes platform is provided for illustrative purposes only and is not intended to limit the scope of the present application. Many variations and modifications will be apparent to those of ordinary skill in the art in light of the teaching of this application. However, such changes and modifications do not depart from the scope of the present application. In some embodiments, the steps of controlling MHA software to send service requests to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform may be performed first; then detecting whether the nodes of the database are down, namely: the step of detecting whether the crash is performed after sending the service request.
Fig. 5 is a schematic structural diagram of a software system based on Kubernetes platform according to an embodiment of the present application, which includes: an application unit, statefulset unit, an Operator unit, and an MHA unit. The biz_app in the application unit is a user micro-service business application, and can select mysql-0 main node through the write_ servi ce of the Kubernetes platform to expose an access interface to read and write data for the business application; the biz_app selects the pod generated by the rest statefulset, i.e. the slave node, through the read_service of the Kub ernetes platform. The MHA software comprises a management node and three database nodes, wherein the management node and the database nodes respectively comprise sshd_ sidecar. mha-manager configuration files are provided by app configmap, mySQL clusters are deployed in statefulset units on a Kubernete S platform, and a semi-synchronous mode is adopted to form a structure of one master and two slaves (label_M and label_S in the figure). A header is also built so that statefulset has a stable access name. The application of the biz_apps user accesses the database, supports read-write separation, writes and selects a master library pod tag through a write_service object, forwards a write request to the master database, and READ SERVIC E objects select slave library pod tags, and forwards read requests to the two slave databases in a rotation mode. Load balancing or analytical SQL can be realized through the system.
For the situation that a physical node is down or the database itself is abnormal, mysql-0 master node is abnormally hung up, MHA software can select a certain s lave as a new master node according to the health condition and the degree of new and old of slave node data, so that the master node and the slave node cannot be distinguished from each other from the perspective of kubernetes statefulset at this time, an Operator unit of an embodiment of the application comprises two controllers: MHA-co ntroller and label-controller. MHA-controller custom CR resources maintain MHA-manager, app.conf configmap. And respectively marking a label_M writing node label and a label_S slave node label by the label-controller according to the MHA-manager information and monitoring the real database master nodes after the 3 database nodes are switched.
Referring to fig. 6, the embodiment of the present application further provides a software deployment device based on a Kubernetes platform, where the software deployment device based on the Kubernetes platform includes: the system comprises a Kubernetes platform module, an MHA software module, a label marking module and a service sending module. The Kubernetes platform module comprises Kubernet es platforms, wherein the Kubernetes platform comprises a master node and a slave node and is used for deploying My SQL clusters on the Kubernetes platform. And the MHA software module is used for providing MHA software and establishing connection between the Kubernetes platform and the MHA software, and the MHA software comprises a management node and a plurality of database nodes. And the label labeling module is used for responding to a request of a user for accessing the database, selecting a database master node from a plurality of database nodes, and generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node. And the service sending module is used for controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform.
In one embodiment, the Master node (Master) and Slave node (Slave) are determined by: selecting a master node through a writing server of a Kubernetes platform to expose an access interface to read and write data for service application; and selecting the rest nodes except the master node as slave nodes through a read server of the Kubernetes platform.
In one embodiment, on the Kubernetes platform, mySQL clusters are deployed by statefulset; and adopting a semi-synchronous mode to form a structure comprising at least one master node and two slave nodes. mysql st atefulset when the database cluster is generated for the first time, mysql-0 is a master node, and after mysql-0 is generated, the controller of kubernetes statefulset ensures that two slave nodes mysql-1 and mysql-2 are regenerated through defining script logic in a statefulset _ yaml file.
In one embodiment, the Kubernetes platform further comprises an Operator comprising a tag controller and an MHA controller comprising an MHA software manager for managing creation of nodes and an application configurator for implementing CRD state maintenance.
In one embodiment, generating the master node label and the slave node label of the Kubernetes platform according to the information of the database master node and the management node comprises: connecting a management node by using a label controller, reading a log printed by the management node, and acquiring main node information of the management node in real time; the method comprises the steps that a MySQL client is connected to a database node configured by a configuration file of an MHA software manager, and the database node enters main node information of a database detection database; and generating a master node label and/or a slave node label for the node of the Kuberne tes platform in response to the consistency of the master node information of the management node and the master node information of the database.
In one embodiment, the Kubernetes platform-based software deployment device is also capable of implementing: detecting whether nodes of the database are down; responding to the downtime of the nodes of the database, and after the nodes of the database are restored, restoring the management mode of the MHA software.
Referring to fig. 7, an embodiment of the present application also provides an electronic device 200, the electronic device 200 comprising at least one memory 210, at least one processor 220, and a bus 230 connecting the different platform systems.
Memory 210 may include readable media in the form of volatile memory, such as random access memory (R AM) 211 and/or cache memory 212, and may further include Read Only Memory (ROM) 213.
The memory 210 also stores a computer program executable by the processor 220 to cause the processor 220 to perform a method based on kubernetes a high-availability deployment of a platform database.
The software deployment method based on the Kubernetes platform comprises the following steps: deploying a MySQL cluster on a Kubernetes platform, wherein the Kubernetes platform comprises a master node and a slave node; providing MHA software, and establishing Kubernet es connection between a platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes; responding to a request of a user for accessing a database, and selecting a database master node from a plurality of database nodes; generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node; and controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform. The method steps are suitable for bottom technical architectures such as cloud computing, internet finance and the like, can meet the requirements of standardized quick delivery, and the flexible demand containerization and service trend of resources, and are in line with the trend of containerization and service.
The specific implementation manner of the method is consistent with the implementation manner and the achieved technical effect recorded in the embodiment of the method, and part of the contents are not repeated. Memory 210 may also include a program/utility 214 having a set (at least one) of program modules 215, such program modules 215 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
Accordingly, the processor 220 may execute the computer programs described above, as well as the program/utility 214.
Bus 230 may be a local bus representing one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or using any of a variety of bus architectures.
The electronic device 200 may also communicate with one or more external devices 240, such as a keyboard, pointing device, bluetooth device, etc., as well as one or more devices capable of interacting with the electronic device 200 and/or with any device (e.g., router, modem, etc.) that enables the electronic device 200 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 250. Also, the electronic device 200 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through a network adapter 260. Network adapter 260 may communicate with other modules of electronic device 200 via bus 230. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 200, including, but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, data backup storage platforms, and the like.
The embodiment of the application also provides a computer readable storage medium for storing a computer program, which when executed realizes:
MySQL clusters are deployed on a Kubernetes platform, which includes a master node and a slave node: providing MHA software and establishing connection between a Kubernetes platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes: in response to a request from a user to access a database, selecting a database master node from a plurality of database nodes: generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node; and controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform.
According to the embodiment of the application, through a labeling mode, the maintenance of VIP of MHA software is replaced, so that the MHA software can be operated on a Kubernetes platform, and the capacity of Kubernetes for managing a stateful high-availability database is expanded; for the whole cloud protogenesis of stateful applications and stateless applications, the functions of the ecosystem such as kubernetes resource scheduling, service discovery, load balancing and the like are fully utilized, and the IT management level of enterprises is improved. The specific implementation manner is consistent with the implementation manner and the achieved technical effect described in the embodiment of the method, and part of the detailed description is omitted.
Fig. 8 shows a program product 300 provided by the present embodiment for implementing the above method, which may employ a portable compact disc read-only memory (CD-ROM) and comprise program code, and may be run on a terminal device, such as a personal computer. However, the program product 300 of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. Program product 300 may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable storage medium may also be any readable medium that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing. Program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a wide area network (wan), or may be connected to AN external computing device (e.g., connected through the internet using AN internet service provider).
The present application has been described in terms of its practical and advantageous aspects, such as objectives, performance, improvements and novelty, which are all the functional improvements and advantages that will be emphasized by the patent laws, the above-described and accompanying drawings are merely preferred embodiments of the present application and not intended to limit the application thereto, and therefore all similar or identical structures, devices, features, etc. that are used in accordance with the application are included in the scope of the application.

Claims (8)

1. The software deployment method based on the Kubernetes platform is characterized by comprising the following steps of:
And deploying a MySQL cluster on the Kubernetes platform, wherein the Kubernetes platform comprises a master node and a slave node, and the master node and the slave node are determined by the following steps: selecting a master node through a write server of the Kubernetes platform to expose an access interface to read and write data for service application; selecting the rest nodes except the master node as slave nodes through the reading server of the Ku bernetes platform;
Providing MHA (MASTER HIGH Availability) software, and establishing connection between the Kubernetes platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes;
responding to a request of a user for accessing a database, and selecting a database master node from the database nodes;
Generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node, wherein the method specifically comprises the following steps: the label controller is used for connecting the management node, reading a log printed by the management node, and acquiring main node information of the management node in real time; the method comprises the steps that a My SQL client is connected to a database node configured by a configuration file of an MHA software manager, and the database is entered to detect master node information of the database; responding to the consistency of the master node information of the management node and the master node information of the database, and generating a master node label and/or a slave node label for the nodes of the Kubernetes platform;
And controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform.
2. The Kubernetes platform-based software deployment method of claim 1, wherein MySQL clusters are deployed on the Kubernetes platform in statefulset manner;
And adopting a semi-synchronous mode to form a structure comprising at least one master node and two slave nodes.
3. The Kubernetes platform-based software deployment method of claim 1, wherein the Kubernetes platform further comprises an Operator comprising a tag controller and an MHA controller, the MHA controller comprising an MHA software manager for creation of the management node and an application configurator for implementing CRD state maintenance.
4. The Kubernetes platform-based software deployment method of claim 1, wherein the MHA software comprises one management node and three database nodes, and the management node and the database nodes each comprise sshd_ sidecar.
5. The Kubernetes platform-based software deployment method of any of claims 1-4, wherein the method further comprises:
Detecting whether nodes of the database are down;
Responding to the downtime of the nodes of the database, and recovering the management mode of the M HA software after the nodes of the database are recovered.
6. A Kubernetes platform-based software deployment apparatus, comprising:
The system comprises a Kubernetes platform module, wherein the Kubernetes platform module comprises a master node and a slave node, the Kubernetes platform module is used for deploying a MySQL cluster on the Kubernetes platform, and the master node and the slave node are determined in the following manner: selecting a master node through a write server of the Kubernetes platform to expose an access interface to read and write data for service application; selecting the rest nodes except the master node as slave nodes through a read server of the Kubernetes platform;
The MHA software module is used for providing MHA software and establishing connection between the Kubernetes platform and the MHA software, and the MHA software comprises a management node and a plurality of database nodes;
the label labeling module is used for responding to a request of a user for accessing the database and selecting a database master node from a plurality of database nodes; generating a master node label and a slave node label of the Kuber netes platform according to the information of the database master node and the management node, wherein the method specifically comprises the following steps: the label controller is used for connecting the management node, reading a log printed by the management node, and acquiring main node information of the management node in real time; the method comprises the steps that a MySQL client is connected to a database node configured by a configuration file of an MHA software manager, and a database is entered to detect master node information of the database; responding to the consistency of the master node information of the management node and the master node information of the database, and generating a master node label and/or a slave node label for the nodes of the Kubernetes platform;
And the service sending module is used for controlling the MHA software to send a service request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform.
7. An electronic device comprising a memory, a processor and a hardware module for performing tasks, the memory storing a computer program, the processor implementing the steps of the method according to any of claims 1-5 when the computer program is executed.
8. A computer readable storage medium storing a computer program which, when executed by a processor, performs the steps of the method according to any one of claims 1-5.
CN202111502544.4A 2021-12-09 2021-12-09 Software deployment method and device based on Kubernetes platform Active CN114138754B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111502544.4A CN114138754B (en) 2021-12-09 2021-12-09 Software deployment method and device based on Kubernetes platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111502544.4A CN114138754B (en) 2021-12-09 2021-12-09 Software deployment method and device based on Kubernetes platform

Publications (2)

Publication Number Publication Date
CN114138754A CN114138754A (en) 2022-03-04
CN114138754B true CN114138754B (en) 2024-10-11

Family

ID=80385474

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111502544.4A Active CN114138754B (en) 2021-12-09 2021-12-09 Software deployment method and device based on Kubernetes platform

Country Status (1)

Country Link
CN (1) CN114138754B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114363092B (en) * 2022-03-17 2022-05-17 万商云集(成都)科技股份有限公司 Gateway and method for cloud container engine micro-service deployment
CN114666202B (en) * 2022-03-18 2024-04-26 中国建设银行股份有限公司 Monitoring method and device for master-slave switching based on cloud database
CN114661420B (en) * 2022-03-28 2023-08-11 安超云软件有限公司 Application protection method, device and system based on Kubernetes container platform
CN115348185B (en) * 2022-08-19 2023-12-05 招银云创信息技术有限公司 Control method and control device of distributed query engine
CN115695319B (en) * 2022-11-01 2024-08-16 上海金融期货信息技术有限公司 Gateway routing rule calculation method supporting multi-priority policy
CN117056132A (en) * 2023-10-11 2023-11-14 武汉吧哒科技股份有限公司 MySQL database switching method and device in Docker container, computer equipment and medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189860A (en) * 2018-10-19 2019-01-11 山东浪潮云信息技术有限公司 A kind of active and standby increment synchronization method of MySQL based on Kubernetes system
CN109918360A (en) * 2019-02-28 2019-06-21 携程旅游信息技术(上海)有限公司 Database platform system, creation method, management method, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108549580B (en) * 2018-03-30 2023-04-14 平安科技(深圳)有限公司 Method for automatically deploying Kubernets slave nodes and terminal equipment
CN111651275A (en) * 2020-06-04 2020-09-11 山东汇贸电子口岸有限公司 MySQL cluster automatic deployment system and method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189860A (en) * 2018-10-19 2019-01-11 山东浪潮云信息技术有限公司 A kind of active and standby increment synchronization method of MySQL based on Kubernetes system
CN109918360A (en) * 2019-02-28 2019-06-21 携程旅游信息技术(上海)有限公司 Database platform system, creation method, management method, equipment and storage medium

Also Published As

Publication number Publication date
CN114138754A (en) 2022-03-04

Similar Documents

Publication Publication Date Title
CN114138754B (en) Software deployment method and device based on Kubernetes platform
US11663085B2 (en) Application backup and management
CN112099918A (en) Live migration of clusters in containerized environments
US8473692B2 (en) Operating system image management
US9886260B2 (en) Managing software version upgrades in a multiple computer system environment
CN109062655A (en) A kind of containerization cloud platform and server
CN108270726B (en) Application instance deployment method and device
US9792150B1 (en) Detecting site change for migrated virtual machines
US11709743B2 (en) Methods and systems for a non-disruptive automatic unplanned failover from a primary copy of data at a primary storage system to a mirror copy of the data at a cross-site secondary storage system
CN110784350A (en) Design method of real-time available cluster management system
US10230567B2 (en) Management of a plurality of system control networks
EP3648405B1 (en) System and method to create a highly available quorum for clustered solutions
JP2011530748A (en) Realization of reliable access to non-local block data storage by executing programs
CN109918360A (en) Database platform system, creation method, management method, equipment and storage medium
CN108347339B (en) Service recovery method and device
CN111343219B (en) Computing service cloud platform
CN112083889A (en) Data migration method, device, equipment and readable storage medium
CN115292408A (en) Master-slave synchronization method, device, equipment and medium for MySQL database
CN116010111B (en) Cross-cluster resource scheduling method, system and terminal equipment
CN114996352B (en) Database management system and method
EP3884648B1 (en) Geo-replicated iot hub
US11169728B2 (en) Replication configuration for multiple heterogeneous data stores
CN114661420A (en) Application protection method, device and system based on Kubernetes container platform
CN112468349B (en) Main node suitable for FT2000+ platform to deploy Ceph
CN112783610A (en) Saltstack-based Ceph deployment host node

Legal Events

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