A service switching method, device, electronic device and storage medium

By saving and deleting the access address within the cluster of the cluster master service in the Kubernets container cluster management system, the service switching of the highly available cluster is achieved, and environmental instability and security risks caused by traditional methods are solved, and system stability and security are improved. sex.

CN115580645BActive Publication Date: 2025-02-07BEIJING QINGYUN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211407026.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-10
Publication Date
2025-02-07
Estimated Expiration
2042-11-10

AI Technical Summary

Technical Problem

In the Kubernets container cluster management system environment, the service switching method of traditional high-availability clusters is not applicable, resulting in unstable operating environment and security risks.

Method used

Save the access address within the cluster of the cluster master service when the service cluster is started, delete the cluster master service based on the switching information, and create a new cluster master service after the master selection is successful.

Benefits of technology

It solves the service switching problem under high-availability clusters, reduces the compatibility errors between high-availability clusters and container cluster management systems, improves system stability and reduces security risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115580645B_ABST
    Figure CN115580645B_ABST
Patent Text Reader

Abstract

This invention discloses a service switching method, apparatus, electronic device, and storage medium. The method includes: saving the intra-cluster access address of the cluster master service when the service cluster starts; deleting the cluster master service in the service cluster according to the switching information of the cluster master service; and, upon determining that the service cluster has successfully elected a master, creating the cluster master service based on the saved intra-cluster access address. This invention solves the service switching problem in high-availability clusters, reduces compatibility errors between high-availability clusters and container cluster management systems, improves system stability, and reduces system security risks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field, and in particular to a service switching method, device, electronic device and storage medium. Background Art

[0002] With the development of cloud native technology based on Kubernetes (K8S for short), containerized database high availability clusters are also imperative. At present, the industry needs to move the high availability solution to the Kubernetes container cluster management system environment, and needs to consider the problem that the traditional high availability machine's operation on the virtual Internet Protocol (Internet Protocol) address cannot be directly used in the Kubernetes environment. At present, the traditional high availability cluster samples the virtual IP as the cluster access address, but K8S can automatically assign the virtual address through the cluster access address (ClusterIP) of the service (Services). The combination of high availability cluster and K8S will cause the manual setting of the virtual IP to cause address conflicts. In addition, the traditional high availability cluster switching requires running the IP command to delete the virtual IP from the network card, thereby blocking the existing database session, and then using the VRRP protocol to switch the virtual IP offset to the new node. This service switching method is not suitable for the K8S container cluster management system environment, resulting in an unstable operating environment and potential security risks. Summary of the invention

[0003] The present invention provides a service switching method, device, electronic device and storage medium to solve the service switching problem in a high-availability cluster, reduce the compatibility errors between the high-availability cluster and the container cluster management system, improve system stability and reduce system security risks.

[0004] According to one aspect of the present invention, a service switching method is provided, wherein the method comprises:

[0005] Save the in-cluster access address of the cluster master service when the service cluster is started;

[0006] Deleting the cluster master service in the service cluster according to the switching information of the cluster master service;

[0007] If it is determined that the service cluster has successfully elected a master, the cluster master service is created according to the saved access address within the cluster.

[0008] According to another aspect of the present invention, a service switching device is provided, wherein the device comprises:

[0009] The address saving module is used to save the in-cluster access address of the cluster master service when the service cluster is started;

[0010] A service deletion module, configured to delete the cluster master service in the service cluster according to the switching information of the cluster master service;

[0011] The switching service module is used to determine that the service cluster has successfully elected a master, and then create the cluster master service according to the saved access address within the cluster.

[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the service switching method described in any embodiment of the present invention.

[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the service switching method described in any embodiment of the present invention when executed.

[0017] The technical solution of the embodiment of the present invention saves the cluster master service's intra-cluster access address when starting the service cluster, obtains the cluster master service's switching information and deletes the cluster master service from the service cluster, and creates a new cluster master service according to the cluster master service's intra-cluster access address when the master is successfully elected in the service cluster. This solves the service switching problem under the high-availability cluster, reduces the compatibility errors between the high-availability cluster and the container cluster management system, improves system stability, and reduces system security risks.

[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0020] Figure 1 is a flow chart of a service switching method provided according to Embodiment 1 of the present invention;

[0021] Figure 2 is a flow chart of another service switching method provided according to Embodiment 2 of the present invention;

[0022] Figure 3 is a flowchart of a service switching method provided according to Embodiment 3 of the present invention;

[0023] Figure 4 is an example diagram of a service switching architecture provided according to Embodiment 3 of the present invention;

[0024] Figure 5 This is an example diagram before a service switching provided according to Embodiment 3 of the present invention;

[0025] Figure 6 This is an example diagram of a successful service switching provided by Embodiment 3 of the present invention;

[0026] Figure 7 is a structural diagram of a service switching device provided according to Embodiment 4 of the present invention;

[0027] Figure 8 It is a schematic diagram of the structure of an electronic device provided according to Embodiment 5 of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] Embodiment 1

[0031] Figure 1This is a flow chart of a service switching method provided according to the first embodiment of the present invention. This embodiment is applicable to the case of service switching when a high-availability cluster is integrated with a K8S container management system. The method can be executed by a service switching device, which can be implemented in the form of hardware and / or software and can be configured in a server cluster. Figure 1 As shown, the method includes:

[0032] Step 110: When the service cluster is started, the in-cluster access address of the cluster master service is saved.

[0033] The service cluster may be a cluster that carries a high-availability database, and container management in the service cluster may be implemented by a container cluster management system. The cluster master service may be an object instance of a server cluster node as a master node in the container management system. The access address within the cluster may be a cluster IP address allocated to the cluster master service, which may be used to link to a database of a high-availability storage cluster.

[0034] In an embodiment of the present invention, when starting a service cluster, it can be understood that starting the service cluster can include starting a container management system and a high-availability storage system, creating a cluster master service and configuring an intra-cluster access address for the cluster master service. The intra-cluster access address of the cluster master service can be saved to facilitate subsequent service switching.

[0035] Step 120: Delete the cluster master service in the service cluster according to the switching information of the cluster master service.

[0036] The switching information may be information about an explicit cluster master service switching host node, and may include information about the cluster master service being unresponsive, information about the cluster master service being unable to connect to a database, active switching instruction information, and the like.

[0037] In an embodiment of the present invention, the switching information of the cluster master service can be monitored. When switching information such as no response information of the cluster master service, failure information that cannot be linked to the database, and active switching instruction information is received, the cluster master service in the service cluster can be deleted.

[0038] Step 130: If it is determined that the service cluster has successfully elected a master, a cluster master service is created according to the saved access address within the cluster.

[0039] The successful election of the service cluster master may be a successful reselection of the host node of the primary container, and the cluster master service may be switched from the original host node to the reselected host node.

[0040] In the embodiment of the present invention, the service cluster may perform a master election operation. When the master election is successful, a cluster master service may be created for the new host node, and the saved intra-cluster access address may be assigned to the cluster master service, thereby implementing service switching.

[0041] The embodiments of the present invention save the intra-cluster access address of the cluster master service when starting the service cluster, delete the cluster master service from the service cluster when the switching information of the cluster master service is obtained, and create a new cluster master service according to the intra-cluster access address when the master is successfully elected in the service cluster. This solves the service switching problem under the high-availability cluster, reduces the compatibility errors between the high-availability cluster and the container cluster management system, improves the system stability, and reduces the system security risks.

[0042] Embodiment 2

[0043] Figure 2 is a flowchart of another service switching method provided according to the second embodiment of the present invention. The embodiment of the present invention is a specific embodiment of the above invention. Figure 2 The method provided in the embodiment of the present invention specifically includes the following steps:

[0044] Step 210: Call the preset operation mode of the container cluster management system to start the service cluster and create a cluster master service.

[0045] Among them, the preset container cluster management system can be a software and hardware system for container management in the service cluster. The preset container cluster management system can specifically include the Kubernets container management system, which can support automated deployment, large-scale scalability, and application container management. Multiple containers can be created in the Kubernets container management system, each container can run an application instance, and each application instance can have its own corresponding access address in the cluster. The operation mode can be the Operator mode in the Kubernetes container management system, or it can be an extended form of the K8S container management system, and the declarative API style of K8S can be customized to manage applications and services.

[0046] In an embodiment of the present invention, the container management system of the service cluster can be started by calling the operation mode of the preset container cluster management system. Different container services can be created for each host node in the service cluster. A cluster master service can be created for the main host node, that is, the write node, and the cluster master service is assigned its corresponding cluster access address, which can be a Cluster IP.

[0047] Step 220: Save the in-cluster access address assigned by the preset container cluster management system to the cluster master service into the custom resource metadata of the preset container cluster management system.

[0048] The custom resource metadata may be a resource type custom created in a preset container management system according to business requirements, and the preset container management system may perform operations such as adding, deleting, modifying, and querying data resources according to the custom resource data.

[0049] In an embodiment of the present invention, the intra-cluster access address allocated by the cluster master service can be extracted, and the intra-cluster access address can be stored in the custom resource metadata of the preset container cluster management system, so that the intra-cluster access address can be used for subsequent service switching, thereby preventing the problem of virtual IP conflict caused by manual configuration of the virtual IP.

[0050] Step 230: When the switching information is received, a preset high-availability component is called in the service cluster.

[0051] Among them, the high availability component can be a functional component of a high availability storage cluster carried in the service cluster, which can realize the execution of script files. The high availability component can be pre-installed in the service cluster. The high availability group can specifically be a Xenon component, a Percona XtraDB Cluster component, a Master High Avaliable component, etc.

[0052] In the embodiment of the present invention, when the switching information such as the non-responsive information of the cluster master service, the failure information that cannot be linked to the database, and the active switching instruction information can be detected, the preset high-availability component can be called in the service cluster.

[0053] Step 240: Control the preset high-availability component to execute a preset deletion script to delete the cluster master service.

[0054] Among them, the preset deletion script can be an executable script file for deleting the cluster master service. The preset deletion script file can include one or more executable commands for deleting the cluster master service. The preset deletion script can specifically be a hook script, and the preset deletion script can be automatically triggered by the switching information.

[0055] In an embodiment of the present invention, the preset deletion script can be run through the preset high-availability component to realize the deletion of the cluster master service. The effect can be consistent with the effect of deleting the virtual IP in the traditional high-availability storage cluster, so that the original host node of the cluster master service is in a dormant state and new data cannot be written to the original host node. The sessions that are not in the committed state will not enter the committed state. The network of the master and slave nodes in the service cluster can still communicate. The transactions that have entered the committed state can still continue to wait for the response from the Pod data and can still perform unfinished log copy actions.

[0056] Further, based on the above-mentioned embodiment of the invention, the preset high-availability component includes a Xenon component.

[0057] In the embodiment of the present invention, the preset high-availability component is specifically a Xenon component, which can realize the characteristics of decentralized leader election, strong consistency of service cluster data, and second-level fault switching through the RAFT protocol.

[0058] Step 250: Block existing container session links in the service cluster and reject new container session links.

[0059] In the embodiment of the present invention, the existing container session link of the host node of the cluster master service can be blocked within the service cluster and the new container session link can be rejected.

[0060] Step 260: Determine a new cluster master service in the service cluster in the preset operation mode of the container cluster management system.

[0061] In an embodiment of the present invention, the service cluster may perform a master election operation. After discovering a newly selected master node of the service cluster through the Operator mode of the preset container cluster management system, a cluster master service may be created for the new master node.

[0062] Step 270: The control operation model reads the in-cluster access address stored in the custom resource metadata.

[0063] Specifically, the operator mode of the preset container cluster management system reads the saved in-cluster access address in the custom resource metadata.

[0064] Step 280: The control operation model allocates the cluster access address to the new cluster master service.

[0065] In the embodiment of the present invention, the Operator mode can allocate the saved cluster access address to the new cluster master service created by the new host node, thereby achieving the drift of the original cluster access address to the new cluster master service.

[0066] In an embodiment of the present invention, a service cluster is started and a cluster master service is created by calling an operation mode of a preset container cluster management system, an access address within the cluster is allocated to the cluster master service, and the access address within the cluster is saved in custom resource metadata. When switching information is received, a high-availability component is called to execute a preset deletion script to delete the cluster master service, and existing container session links within the service cluster are blocked and new container session links are rejected. When a new cluster master service is obtained in the operation mode, the access address within the cluster saved in the custom resource metadata is read, and the access address within the cluster is allocated to the new cluster master service, thereby solving the service switching problem under the high-availability cluster, reducing the compatibility errors between the high-availability cluster and the container cluster management system, improving system stability, and reducing system security risks.

[0067] Further, based on the above-mentioned embodiment of the invention, the switching information includes at least one of the following: the cluster master service is unresponsive; the communication between the master container and the database fails.

[0068] Embodiment 3

[0069] Figure 3 is a flowchart of a service switching method provided according to Embodiment 3 of the present invention, see Figure 3 To achieve safe and high-availability service switching in a high-availability storage cluster, take the following three steps:

[0070] 1. The K8S operator creates a leader service (write node) and saves the clusterIp assigned to the leader service by K8s to the cluster-to-CustomResource metadata in preparation for rebuilding the service to bind the same clusterIp.

[0071] 2. Before the pod exits or the old master is switched and after the new master is generated, the high-availability component can be called to delete the K8s service. The effect is the same as the effect of deleting the virtual IP in the traditional high-availability cluster. At the moment of deleting the service, the session connected to the old master is in a dormant state and new data cannot be written to the old master. The session that is not in the committed state will not enter the committed state. At this time, the network between the master and slave Pods can still communicate, and the transaction that has entered the committed state can still continue to wait for the response from the Pod data and can still perform the unfinished log replication action. Moreover, the process of blocking the transmission of the old session data is very fast, and the deletion of the service is almost completed instantly.

[0072] 3. When the service cluster successfully elects a master, the high-availability component can ensure that the transactions of the old master that enter the committed state can be successfully replicated. At this time, the Operator re-creates the service with the original clusterIp based on the master election situation, and the clusterIp will drift to the new master Pod. At this time, the sleeping session of the old master is disconnected, and the database rolls back these unfinished transactions. It can be understood that, unlike the restart of the database rollback, the database container can still provide services to the outside world and can still act as a slave node of the cluster.

[0073] In this embodiment of the present invention, it is assumed that the containerized database cluster adopts a three-copy mode and the cluster name is sample. Figure 4 The figure only shows the container composition of the main Pod, which are the MySQL database container, Xenon as the high-availability component container, and other function containers. sample-mysql-0 to sample-mysql-2 are the names of the Pods allocated by K8s' statefulset.

[0074] When the cluster is created, after the operator creates the leader service, it immediately reads the clusterIp of the leader service and writes it into the annotations of the CustomResource of the database cluster. When the high-availability component Xenon detects that the main Pod is unresponsive to MySQL or other failures occur, Xenon will execute the hook script. The action of the hook script is to delete the sample-leader service, such as Figure 5 The Pod named sample-mysql-0, which was the leader before the switch, has its xenon call hook script to delete the sample-leader service. At this time, the client session connected to the database is blocked and cannot transfer data (indicated by the red dotted line in the figure), and new sessions cannot be established. After that, the Xenon component uses the raft protocol to select a new leader. At this time, it is assumed that the Pod named sample-mysql-2 is selected as the new leader. Figure 6 After the switch is successful, the operator queries the status of xenon in each Pod and recreates sample-leader with the clusterIp saved in the cluster Custom Resoure. At this time, clusterIp drifts to the Pod named sample-mysql-2. The client can continue to use sample-leader to access the database, and the session with the old master sample-mysql-0 is disconnected.

[0075] Embodiment 4

[0076] Figure 7 FIG. 1 is a schematic diagram of the structure of a service switching device provided according to Embodiment 4 of the present invention. Figure 7 As shown, the device includes: an address storage module 301, a service deletion module 302 and a service switching module 303.

[0077] The address saving module 301 is used to save the in-cluster access address of the cluster master service when the service cluster is started.

[0078] The service deletion module 302 is configured to delete the cluster master service in the service cluster according to the switching information of the cluster master service.

[0079] The switching service module 303 is used to determine that the service cluster has successfully elected a master, and then create the cluster master service according to the saved access address within the cluster.

[0080] In the embodiment of the present invention, the address saving module saves the cluster access address of the cluster master service when starting the service cluster. The service deletion module obtains the switching information of the cluster master service and deletes the cluster master service from the service cluster. When the switching service module successfully selects the master in the service cluster, it creates a new cluster master service according to the cluster access address. This solves the service switching problem under the high-availability cluster, reduces the compatibility errors between the high-availability cluster and the container cluster management system, improves the system stability, and reduces the system security risks.

[0081] Further, based on the above-mentioned embodiment of the invention, the address storage module 301 includes:

[0082] The service creation unit is used to call a preset operation mode of the container cluster management system to start the service cluster and create the cluster master service.

[0083] The address storage unit is used to save the intra-cluster access address assigned by the preset container cluster management system to the cluster master service into the custom resource metadata of the preset container cluster management system.

[0084] Further, based on the above-mentioned embodiment of the invention, the service deletion module 302 includes:

[0085] A component calling unit is used to call a preset high-availability component in the service cluster when receiving the switching information.

[0086] The deletion execution unit is used to control the preset high-availability component to execute a preset deletion script to delete the cluster main service.

[0087] Further, based on the above-mentioned embodiments of the invention, the preset high-availability components at least include Xenon components.

[0088] Further, based on the above-mentioned embodiment of the invention, the switching service module 303 includes:

[0089] The container discovery unit is used to determine a new cluster master service in the service cluster in the operation mode of the preset container cluster management system.

[0090] The address reading unit is used to control the operation model to read the in-cluster access address saved in the custom resource metadata.

[0091] The address drifting unit is used to control the operation model to allocate the cluster access address to the new cluster master service.

[0092] Further, based on the above-mentioned embodiment of the invention, the service deletion module 302 further includes: a session processing unit, which is used to block the existing container session links in the service cluster and reject the creation of new container session links.

[0093] Further, based on the above-mentioned embodiment of the invention, the switching information includes at least one of the following: the cluster master service is unresponsive; the communication between the master container and the database fails.

[0094] The service switching device provided in the embodiment of the present invention can execute the service switching method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0095] Embodiment 5

[0096] Figure 8 is a schematic diagram of the structure of an electronic device provided according to Embodiment 5 of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0097] like Figure 8 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0098] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0099] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a service switching method.

[0100] In some embodiments, the service switching method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the service switching method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the service switching method in any other appropriate manner (e.g., by means of firmware).

[0101] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0102] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0103] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0104] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0105] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0106] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0107] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0108] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A service switching method, characterized in that: The method comprises: Saving the in-cluster access address of the cluster master service when the service cluster is started, including: calling the operation mode of the preset container cluster management system to start the service cluster and create the cluster master service; saving the in-cluster access address assigned to the cluster master service by the preset container cluster management system to the custom resource metadata of the preset container cluster management system; Deleting the cluster master service in the service cluster according to the switching information of the cluster master service, wherein the switching information includes at least one of the following: information that the cluster master service explicitly switches the host node, information that the cluster master service is unresponsive, fault information that the cluster master service cannot be linked to the database, or active switching instruction information; If it is determined that the service cluster has successfully elected a master, the cluster master service is created according to the saved access address within the cluster.

2. The method according to claim 1, characterized in that: The deleting the cluster master service in the service cluster according to the switching information of the cluster master service includes: Upon receiving the switching information, calling a preset high-availability component in the service cluster; The preset high-availability component is controlled to execute a preset deletion script to delete the cluster master service.

3. The method according to claim 2, characterized in that: The preset high-availability components include at least Xenon components.

4. The method according to claim 1, characterized in that: The step of determining that the service cluster has successfully elected a master, and then creating the cluster master service according to the saved access address within the cluster, includes: Determining a new cluster master service in the service cluster in the operation mode of the preset container cluster management system; The control operation model reads the in-cluster access address stored in the custom resource metadata; The operation model is controlled to allocate the cluster access address to the new cluster master service.

5. The method according to any one of claims 1 to 4, characterized in that: The deleting the cluster master service in the service cluster according to the switching information of the cluster master service also includes: Block existing container session links within the service cluster and reject new container session links.

6. A service switching device, characterized in that: The device comprises: The address saving module is used to save the in-cluster access address of the cluster master service when the service cluster is started; A service deletion module, configured to delete the cluster master service in the service cluster according to the switching information of the cluster master service, wherein the switching information includes at least one of the following: information of explicit cluster master service switching host node, information of cluster master service no response, fault information of cluster master service unable to link to database, or active switching instruction information; A switching service module is used to determine that the service cluster has successfully selected a master, and then create the cluster master service according to the saved access address in the cluster; Wherein, the address storage module includes: A service creation unit, configured to call a preset operation mode of a container cluster management system to start the service cluster and create the cluster master service; The address storage unit is used to save the intra-cluster access address assigned by the preset container cluster management system to the cluster master service into the custom resource metadata of the preset container cluster management system.

7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the service switching method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the service switching method according to any one of claims 1 to 5 when executed.

Citation Information

Patent Citations

  • Server cluster system

    CN106331098A

  • Load balancing method and device applied to service cluster

    CN113452767A