Fault node switching method, device, apparatus and storage medium
By monitoring the status of ActiveMQ nodes in the Kubernetes environment and switching to the target slave node, the problem of insufficient failover of ActiveMQ in the Kubernetes environment is solved, seamless failover and high availability are achieved, and the stability and user experience of the message middleware are improved.
Patent Information
- Application Number
- CN202510108319.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-01-23
AI Technical Summary
When deploying the open source messaging middleware ActiveMQ in a Kubernetes environment, the existing Operator lacks comprehensive support for failover, resulting in insufficient high availability and affecting the stability and reliability of the messaging middleware in high-concurrency, large-scale distributed systems.
A fault node switching method is provided. The master node auxiliary unit monitors the status and switches to the target slave node in case of a fault. The database cluster is used to store the master and backup status of the nodes. The node auxiliary unit is combined to achieve fault switching, simplifying the configuration of the message middleware cluster and enhancing its adaptability and scalability in the cloud native environment.
It achieves seamless failover in a cloud-native environment, making users unaware of the failures. It improves the adaptability and user experience of the message middleware cluster and ensures the consistency and reliability of master node election.
Smart Images

Figure CN119966803B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of K8s technology, and in particular to a method, apparatus, device and storage medium for switching a faulty node. Background Art
[0002] With the prevalence of cloud computing and microservices architectures, the demand for messaging middleware in enterprise applications is growing. ActiveMQ, a mature open-source messaging middleware, has been widely adopted due to its high flexibility and rich feature set. In cloud-native environments, especially Platform as a Service (PaaS) scenarios, ActiveMQ can serve as a core component for messaging, supporting asynchronous communication, event-driven architectures, and decoupling between microservices.
[0003] Driven by containerization and orchestration technologies, Kubernetes (K8s) has become the industry-standard container orchestration platform. To simplify the deployment, initialization, and management of complex applications, the Operator pattern has emerged. Operators are specialized Kubernetes controllers that extend the Kubernetes application programming interface to provide a higher level of business logic automation, making them particularly well-suited for running stateful applications and services.
[0004] Initializing ActiveMQ high availability in a Kubernetes environment remains challenging. Currently, several operators are available for deploying and managing ActiveMQ clusters. However, these operators typically only provide basic deployment capabilities, failover considerations, and lack comprehensive support for high availability.
[0005] Furthermore, existing operators are often not fully integrated into Kubernetes' lifecycle management, resulting in limitations in resource scheduling, auto-scaling, and health checks. This limits the stability and reliability of open-source message middleware in high-concurrency, large-scale distributed systems.
[0006] Therefore, in view of the shortcomings of the existing technical solutions, the present invention provides a fault node switching method. Summary of the Invention
[0007] Based on this, it is necessary to provide a fault node switching method, device, equipment and storage medium to address the above technical problems.
[0008] On the one hand, a fault node switching method is provided, which is applied to a cloud platform, wherein the cloud platform includes a message middleware cluster, a database cluster and an endpoint slice, wherein data interaction is performed between the message middleware cluster and the database cluster, and data interaction is performed between the message middleware cluster and the endpoint slice, and the message middleware cluster includes a master node, multiple slave nodes and multiple node auxiliary units, and one node corresponds to one node auxiliary unit. The method comprises: in response to receiving an access request, accessing the master node in the message middleware cluster to respond to the access request according to the address value in the endpoint slice, wherein the endpoint slice is used to store the master node address; monitoring the master node through the master node auxiliary unit; point status, when it is monitored that the master node fails, the master node indication value in the database cluster is modified from the first target value to the preset value, wherein the first target value is the value corresponding to the current master node; the master node indication value is monitored by multiple slave node auxiliary units as the preset value, and the target slave node is determined through concurrent competition; the master node indication value is modified to the second target value, wherein the second target value is the value corresponding to the target slave node; in response to the change of the master node indication value, the address value in the endpoint slice is updated to the address value corresponding to the target slave node; according to the updated address value in the endpoint slice, the target slave node in the message middleware cluster is accessed to respond to the access request.
[0009] Optionally, in response to receiving the access request, accessing the master node in the message middleware cluster to respond to the access request according to the address value in the endpoint slice, including: in response to receiving the access request, initializing the operation of the node through multiple nodes, obtaining the node with the fastest initialization, using the node with the fastest initialization as the master node, and using the remaining nodes as slave nodes; writing the address corresponding to the master node into the endpoint slice; and accessing the master node in the message middleware cluster according to the address value in the endpoint slice.
[0010] Optionally, in response to a change in the master node indication value, the address value in the endpoint slice is updated to the address value corresponding to the target slave node, including: sending an instruction to obtain the master node to the node auxiliary unit; receiving the master node obtained by the node auxiliary unit from the database cluster, and writing the address value corresponding to the master node into the endpoint slice.
[0011] Optionally, the database cluster includes multiple databases, each database includes the same master node indication value, each node corresponds to a database, each node auxiliary unit monitors the database corresponding to the node, the master node indication value monitored by multiple slave node auxiliary units is a preset value, the target slave node is determined through concurrent competition, and the master node indication value is modified to a second target value, wherein the second target value is a value corresponding to the target slave node, including: monitoring the master node indication value in the database corresponding to the slave node by the slave node auxiliary unit as a preset value, and taking the preset value as the expected value; performing a health check on the slave node corresponding to the slave node auxiliary unit; when the slave node meets the health check criteria On time, the actual value of the master node indication value in the database corresponding to the slave node is obtained through the slave node auxiliary unit; the expected value of the master node indication value and the actual value of the master node indication value are compared through the slave node auxiliary unit; when the actual value and the expected value are the same, the slave node is used as the target slave node, and the master node indication value in the database corresponding to the slave node is modified to a second target value. In response to detecting the modification of the master node indication value, the database cluster synchronizes the master node indication value in each database in the database cluster to the second target value; when the actual value and the expected value are different, the master node indication value in the database cluster is continuously monitored through the slave node auxiliary unit.
[0012] Optionally, the health check on the slave node corresponding to the slave node auxiliary unit includes: sending and receiving messages between the slave node auxiliary unit and the slave node to determine whether the operating status of the slave node is normal; when the operating status of the slave node is normal, checking through the slave node auxiliary unit whether the resource utilization and network connectivity of the slave node are within a preset range; when the resource utilization and network connectivity of the slave node are within the preset range, the slave node passes the health check.
[0013] Optionally, before responding to receiving the access request, the method further includes: creating a container corresponding to the node based on each node and the node auxiliary unit, wherein the container mounts a storage volume; and storing the message of the node in the storage volume mounted on the container.
[0014] Optionally, after updating the address value in the endpoint slice to the address value corresponding to the target slave node, the method further includes: creating a temporary container; obtaining the message of the master node from the container corresponding to the master node, and storing the message of the master node in the temporary container; associating the temporary container with the target slave node, migrating and storing the message of the master node stored in the temporary container to the container corresponding to the target slave node; and deleting the temporary container.
[0015] On the other hand, a fault node switching device is provided, which is applied to a cloud platform, wherein the cloud platform includes a message middleware cluster, a database cluster and an endpoint slice, wherein data interaction is performed between the message middleware cluster and the database cluster, and data interaction is performed between the message middleware cluster and the endpoint slice, and the message middleware cluster includes a master node, multiple slave nodes and multiple node auxiliary units, and one node corresponds to one node auxiliary unit. The device includes: a first access module, which is used to access the master node in the message middleware cluster in response to the access request in response to the access request according to the address value in the endpoint slice, wherein the endpoint slice is used to store the master node address; a monitoring module, which is used to monitor the status of the master node through the master node auxiliary unit, and when the monitoring When the master node fails, the master node indication value in the database cluster is modified from the first target value to the preset value, wherein the first target value is the value corresponding to the current master node; the first processing module is used to monitor the master node indication value to be the preset value through multiple slave node auxiliary units, and determine the target slave node through concurrent competition; the second processing module is used to modify the master node indication value to the second target value, wherein the second target value is the value corresponding to the target slave node; the switching module is used to update the address value in the endpoint slice to the address value corresponding to the target slave node in response to the change of the master node indication value; the second access module is used to access the target slave node in the message middleware cluster according to the updated address value in the endpoint slice to respond to the access request.
[0016] On the other hand, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: in response to receiving an access request, accessing a master node in a message middleware cluster in response to the access request according to an address value in an endpoint slice, wherein the endpoint slice is used to store the master node address; monitoring the status of the master node through a master node auxiliary unit, and when a failure of the master node is detected, modifying the master node indication value in the database cluster from a first target value to a preset value, wherein the first target value is a value corresponding to the current master node; monitoring the master node indication value as a preset value through multiple slave node auxiliary units, and determining a target slave node through concurrent competition; modifying the master node indication value to a second target value, wherein the second target value is a value corresponding to the target slave node; in response to a change in the master node indication value, updating the address value in the endpoint slice to an address value corresponding to the target slave node; and accessing the target slave node in the message middleware cluster in response to the access request according to the updated address value in the endpoint slice.
[0017] On the other hand, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: in response to receiving an access request, accessing the master node in the message middleware cluster to respond to the access request according to the address value in the endpoint slice, wherein the endpoint slice is used to store the master node address; monitoring the status of the master node through the master node auxiliary unit, and when it is detected that the master node fails, modifying the master node indication value in the database cluster from the first target value to the preset value, wherein the first target value is the value corresponding to the current master node; monitoring the master node indication value through multiple slave node auxiliary units to be a preset value, and determining the target slave node through concurrent competition; modifying the master node indication value to a second target value, wherein the second target value is the value corresponding to the target slave node; in response to the change of the master node indication value, updating the address value in the endpoint slice to the address value corresponding to the target slave node; and accessing the target slave node in the message middleware cluster to respond to the access request according to the updated address value in the endpoint slice.
[0018] The above-mentioned fault node switching method, device, equipment and storage medium, the method includes: in response to receiving an access request, accessing the master node in the message middleware cluster to respond to the access request according to the address value in the endpoint slice, wherein the endpoint slice is used to store the master node address; monitoring the status of the master node through the master node auxiliary unit, and when it is detected that the master node fails, modifying the master node indication value in the database cluster from the first target value to the preset value, wherein the first target value is the value corresponding to the current master node; monitoring the master node indication value to be the preset value through multiple slave node auxiliary units, and determining the target slave node through concurrent competition; modifying the master node indication value to the second target value, wherein the second target value is the value corresponding to the target slave node; in response to the change of the master node indication value, the address value in the endpoint slice is updated to the address value corresponding to the target slave node; according to the updated address value in the endpoint slice, the target slave node in the message middleware cluster is accessed to respond to the access request; in this way, the database cluster is used to store the master-slave status of the node, which can ensure the consistency and reliability of the master node election, and the node auxiliary unit is designed to achieve fault switching, which can simplify the configuration of the message middleware cluster and enhance the adaptability and scalability of the message middleware cluster in the cloud native environment. At the same time, the address value in the endpoint slice is updated and accessed, which can achieve seamless fault transfer, and the user is unaware of the fault, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 Schematic diagram of a flow chart of a method for switching a faulty node in one embodiment;
[0020] Figure 2Schematic diagram of the module architecture of a fault node switching method in one embodiment;
[0021] Figure 3 is a structural block diagram of a fault node switching device in one embodiment;
[0022] Figure 4 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0023] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0024] It should be understood that in the description of this application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like throughout the specification should be interpreted as inclusive rather than exclusive or exhaustive; that is, as "including but not limited to".
[0025] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.
[0026] It should be noted that the terms "S1", "S2", etc. are used only for the purpose of describing the steps and do not specifically refer to the order or sequence, nor are they used to limit this application. They are merely for the convenience of describing the method of this application and should not be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that ordinary technicians in this field can implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0027] In one embodiment, Figure 1 As shown, a fault node switching method is provided, which is applied to a cloud platform, characterized in that the cloud platform includes a message middleware cluster, a database cluster and an endpoint slice, wherein data is exchanged between the message middleware cluster and the database cluster, and data is exchanged between the message middleware cluster and the endpoint slice, and the message middleware cluster includes a master node, multiple slave nodes and multiple node auxiliary units, and each node corresponds to a node auxiliary unit, comprising the following steps:
[0028] S101: In response to receiving an access request, access a master node in a message middleware cluster according to an address value in an endpoint slice to respond to the access request, wherein the endpoint slice is used to store the master node address.
[0029] EndpointSlices is a new API that provides a scalable and extensible alternative to the EndpointAPI. EndpointSlices track the IP address, port, readiness, and topology of a service's pods. They are created by the controller and associated with a service. The server implements a "services-without-selectors" mechanism, with endpoint slices associated with the corresponding service using the label kubernetes.io / service-name.
[0030] Here, the message middleware cluster can be an ActiveMQ Artemis cluster, which includes multiple nodes, specifically a master node and multiple slave nodes. The message middleware cluster is a cluster running on the Kubernetes platform, an open source container-based cluster management platform.
[0031] Specifically, the server receives the access request sent by the client, determines the endpoint slice associated with the server, routes to the IP (Internet Protocol) address of the container of the node recorded in the endpoint slice, and accesses the node.
[0032] S102: Monitor the status of the master node through the master node auxiliary unit. When it is detected that the master node fails, modify the master node indication value in the database cluster from the first target value to a preset value, wherein the first target value is the value corresponding to the current master node.
[0033] Here, the database cluster is used to store the status of the master and slave nodes. The database can be an etcd database, a MySQL database, an SQLite database, a Redis database, etc.
[0034] Here, the primary node indication value may be a specific key value in the database. For example, when the database is etcd, the primary node indication value may be the value of / service / {cluster_name} / primary.
[0035] The preset value can be a null value or any value set by the user.
[0036] Among them, the failure of the master node may include: the master node is unavailable, the master node takes too long to send and receive messages or the processing capacity is insufficient, and the resources of the master node reach a critical value.
[0037] Specifically, the master node auxiliary unit monitors the status of the master node at fixed intervals. When a master node failure is detected, the specific key value in the database cluster is modified to the preset value. For example, assuming the database is an etcd database, the value of the primary node is the value of the specific key / service / {cluster_name} / primary, and the preset value is empty. When the master node fails, the corresponding master node auxiliary unit will detect it and update the value of the specific key in etcd to an empty string. The slave node auxiliary unit uses the etcd monitoring mechanism. When the value of the specific key in etcd changes, all monitoring slave node auxiliary units will be notified.
[0038] S103: The master node indication value is monitored to be a preset value by multiple slave node auxiliary units, and a target slave node is determined through concurrent competition.
[0039] Concurrency contention refers to conflicts that occur when multiple threads or processes simultaneously access and modify shared resources in a multi-threaded or multi-process environment. The slave node auxiliary unit monitors the health of the corresponding node and assists nodes in the same container in participating in the master node election.
[0040] Among them, the value change of the master node in the database cluster is monitored by the node auxiliary unit, which can be achieved by the node auxiliary unit regularly sending data acquisition instructions to the database to obtain the value of the master node, or by the database sending a notification to the node auxiliary unit after the data changes.
[0041] Specifically, each slave node auxiliary unit helps the corresponding slave node to compete for a new master node, and the slave node that successfully competes becomes the new master node.
[0042] S104: Modify the master node indication value to a second target value, wherein the second target value is a value corresponding to the target slave node.
[0043] Specifically, the master node in the database cluster is modified to a slave node that successfully competes.
[0044] S105: In response to a change in the master node indication value, the address value in the endpoint slice is updated to the address value corresponding to the target slave node.
[0045] Specifically, when a change in the master node is detected, the IP recorded in the server object is updated to the pod IP of the new master node.
[0046] S106: Access a target slave node in the message middleware cluster according to the updated address value in the endpoint slice to respond to the access request.
[0047] Specifically, the service side implements a services-without-selectors mechanism, and the endpoint slice is not automatically created, and the update of the access object is realized by updating the address value in the endpoint slice.
[0048] It should be noted that the application uses a database cluster to store the primary and backup states of the nodes, which can guarantee the consistency and reliability of the primary node election, and through the design of the node auxiliary unit to realize the fault switching, the configuration of the message middleware cluster can be simplified, and the adaptability and expansibility of the message middleware cluster in the cloud native environment can be enhanced. At the same time, the address value in the endpoint slice is updated and accessed, which can realize seamless failover, users have no perception of failure, and user experience is improved.
[0049] In some embodiments, in response to receiving an access request, accessing a master node in the message middleware cluster according to an address value in an endpoint slice to respond to the access request, comprising:
[0050] In response to receiving an access request, initializing the running of the nodes through the plurality of nodes, obtaining the node with the fastest initialization speed, taking the node with the fastest initialization speed as the master node, and taking the remaining nodes as slave nodes;
[0051] Write the address corresponding to the master node into the endpoint slice;
[0052] Access the master node in the message middleware cluster according to the address value in the endpoint slice.
[0053] Here, the ActiveMQ service itself uses a primary only mode, and the corresponding node deployment mode is one master and multiple slaves. This mode simplifies initialization and makes it more suitable for cloud native environments.
[0054] Specifically, after receiving an access request, all nodes start initializing the running of the nodes, detect the first node that completes the running initialization, and start running the node. The node is taken as the master node, and the pod IP (container address) of the node is written into the endpoint slice of the server. The service side obtains the IP from the endpoint slice and accesses the corresponding node.
[0055] In one embodiment, each slave node remains in a running state after completing initialization, and when a fault node switching is performed, it does not need to be restarted, which can improve the speed of fault node switching.
[0056] In one embodiment, before receiving an access request, the controller uses CRDs (Custom Resource Definitions) to configure and initialize ActiveMQ Artemis nodes and node auxiliary units. It also uses CRDs to configure and initialize ActiveMQ Artemis' external access service, which implements a services-without-selectors mechanism. The controller uses CRs (Custom Resource Definitions) to configure resource instances.
[0057] In some specific implementations, in response to a change in the master node indication value, updating the address value in the endpoint slice to the address value corresponding to the target slave node includes:
[0058] Send the command to obtain the master node to the node auxiliary unit;
[0059] The receiving node auxiliary unit obtains the master node from the database cluster, and writes the address value corresponding to the master node into the endpoint slice.
[0060] Among them, since the server adopts Kubernetes' services-without-selectors mechanism, it does not generate new endpoint slices. The endpoint slices are generated by the operator (controller), and the master node is updated by updating the IP address in the endpoint slice.
[0061] Specifically, the controller keeps monitoring the master node and sends an instruction to obtain the master node to the node auxiliary unit at preset intervals. After the node auxiliary unit receives the instruction to obtain the master node sent by the controller, it obtains the master node from the database cluster and sends the master node to the endpoint slice. The master node in the endpoint slice is updated.
[0062] In this way, through the services-without-selectors mechanism of Kubernetes, it is ensured that after a node failure and the master-slave node switch, the client is unaware of the access to the ActiveMQ Artemis cluster, achieving seamless failover and improving the user experience.
[0063] In some specific embodiments, the database cluster includes multiple databases, each database includes the same master node indication value, each node corresponds to a database, each node auxiliary unit monitors the database corresponding to the node, the master node indication value monitored by multiple slave node auxiliary units is a preset value, a target slave node is determined through concurrent competition, and the master node indication value is modified to a second target value, wherein the second target value includes:
[0064] The master node indication value in the database corresponding to the slave node is monitored by the slave node auxiliary unit as a preset value, and the preset value is used as the expected value;
[0065] Performing a health check on the slave node corresponding to the slave node auxiliary unit;
[0066] When the slave node meets the health check standard, the slave node auxiliary unit obtains the actual value of the master node indication value in the database corresponding to the slave node;
[0067] Comparing the expected value of the master node indication value and the actual value of the master node indication value by the slave node auxiliary unit;
[0068] When the actual value is the same as the expected value, the slave node is used as a target slave node, the master node indication value in the database corresponding to the slave node is modified to a second target value, and in response to detecting the modification of the master node indication value, the database cluster synchronizes the master node indication value in each database in the database cluster to the second target value;
[0069] When the actual value is different from the expected value, the master node indication value in the database cluster is continuously monitored by the slave node auxiliary unit.
[0070] Here, the master node is updated through a CAS (Compare-and-Swap) operation.
[0071] Here, data in the database cluster is synchronized through database cluster technologies such as master-slave replication and master-master replication.
[0072] Here, each node corresponds to a database, and the databases corresponding to multiple nodes constitute a database cluster. The data in the database cluster is synchronized through database cluster technologies such as master-slave replication and master-master replication.
[0073] Each slave node auxiliary unit obtains the master node value from the database corresponding to the slave node in the database cluster. For example, the slave nodes include slave node 1 and slave node 2, and the database includes database 1 corresponding to slave node 1 and database 2 corresponding to slave node 2. Slave node 1 obtains the master node value from database 1, and slave node 2 obtains the master node value from database 2.
[0074] Furthermore, each slave node auxiliary unit simultaneously monitors the changes of the master node in the database cluster. Each slave node auxiliary unit performs a health check on the corresponding slave node, and attempts to elect the slave node as the new master node after the check passes.
[0075] Specifically, assuming that the slave nodes include slave node 1 and slave node 2, the slave node auxiliary unit 1 constructs a CAS operation, the key is / service / <cluster_name> / primary, the preset value is null, the expected value is the last key value listened to by the slave node auxiliary unit 1, the slave node 1 is health checked when the expected value is null, the slave node 1 passes the health check, the slave node auxiliary unit 1 again acquires the actual value of the key, if the actual value of the key is the same as the expected value, the master node in the database cluster successfully updates to the slave node 1, at this time, the slave node 1 becomes the new master node, if the slave node auxiliary unit 2 of another slave node 2 has successfully updated the value of the key before the slave node 1 attempts to update, that is, the slave node 2 has become the master node, then the CAS operation of the slave node auxiliary unit 1 will fail because the current value of the key has changed, the slave node auxiliary unit 1 will keep the slave node 1 in the slave node state until the next election.
[0076] In one embodiment, if the node auxiliary unit detects that the value of the current etcd key / service / <cluster_name> / primary becomes null, the node auxiliary unit will reevaluate the state of the corresponding node and again attempt to become the master node.
[0077] In this way, updating the master node in the database cluster through the CAS operation can ensure the atomicity and consistency of the update operation.
[0078] In some specific embodiments, the health check of the slave node corresponding to the slave node auxiliary unit includes:
[0079] Determining whether the running state of the slave node is normal through sending and receiving messages between the slave node auxiliary unit and the slave node;
[0080] When the running state of the slave node is normal, checking whether the resource usage and network connectivity of the slave node are within a preset range through the slave node auxiliary unit;
[0081] When the resource usage and network connectivity of the slave node are within the preset range, the slave node passes the health check.
[0082] Here, the resource usage can include CPU (Central Processing Unit) usage, memory usage, disk space rate, etc.
[0083] For example, the running state of the ActiveMQ Artemis broker (i.e., node) can be checked by sending and receiving a message, and a command example is as follows:
[0084]
[0085] This ensures that the slave node meets the conditions for becoming the master node.
[0086] In some embodiments, before responding to the access request, the method further includes:
[0087] Based on each node and node auxiliary unit, create a container corresponding to the node, wherein the container mounts a storage volume;
[0088] The node's messages are stored in the storage volume mounted by the container.
[0089] Here, the storage volume is a persistent volume used to persistently store messages corresponding to the node, and the node auxiliary unit is used to assist the slave node to become the new master node.
[0090] Specifically, the operator (i.e., controller) initializes the node auxiliary unit and the node through the custom resource (CR) ActiveMQArtemis. The node deployment mode is one master and multiple backups. A container runs in each node. Each container includes the node and the node auxiliary unit, and a persistent volume is mounted.
[0091] In some specific implementations, after updating the address value in the endpoint slice to the address value corresponding to the target slave node, the method further includes:
[0092] Create a temporary container;
[0093] Obtaining a message of the master node from a container corresponding to the master node, and storing the message of the master node in the temporary container;
[0094] Associating the temporary container with the target slave node, migrating and storing the master node's messages stored in the temporary container into the container corresponding to the target slave node;
[0095] Delete the temporary container.
[0096] Specifically, when the controller senses a change in the master node, it automatically deploys a temporary container, which will contact the new master node in the cluster and transfer messages to the new master node. After the message migration is completed, the temporary container will close itself.
[0097] In this way, the messages in the original master node and the messages in the new master node are synchronized.
[0098] In some embodiments, the method further comprises:
[0099] Perform fault detection on the faulty master node and determine the cause of the fault;
[0100] Perform fault clearing on the faulty master node to obtain the master node after fault clearing;
[0101] After the fault is cleared, the master node is added to the message middleware cluster as a slave node.
[0102] Here, fault cleanup includes checking and repairing configuration files, restoring data, clearing disk space, clearing memory, etc.
[0103] Specifically, after a master node fails, the master node is cleared of the fault, and the restored master node is rejoined to the message middleware cluster as a slave node to participate in the next master node election.
[0104] In this way, the faulty node is cleared and re-added to the message middleware cluster to ensure the stability and reliability of the distributed system.
[0105] In one embodiment, Figure 2 This is a schematic diagram of the module architecture in the embodiment of the present application, such as Figure 2 As shown in the figure, the modular architecture includes: user client, server, endpoint slice, message broker access control (ActiveMQArtemisAccess controller), primary broker, backup broker, role helper, message broker control (ActiveMQArtemis controller), and database (etcd). A pod includes both the role helper and the node.
[0106] Specifically, the user client is used to send an access request.
[0107] Specifically, the service is used to receive access requests and route endpoint slices.
[0108] Specifically, the endpoint slice is used to receive and write the master node address and access the master node according to the address.
[0109] Specifically, the access control of the message broker is used to list and monitor changes in master and slave nodes, and write the new master node address to the endpoint slice.
[0110] Specifically, the master node is used to perform access, and when the master node fails, the messages in the master node are migrated to the new master node.
[0111] Specifically, the slave node is used to run for the new master node when the master node fails. After the election is successful, it obtains the messages in the original master node.
[0112] Specifically, each node corresponds to a node auxiliary unit. The node auxiliary unit of the master node is used to monitor the health status of the master node, and the node auxiliary unit of the slave node is used to monitor the master node indication value in the database cluster. When the value corresponding to the master node is monitored to change, it helps the corresponding slave node to run for the new master node.
[0113] Specifically, the control of the message broker is used to create a temporary container to migrate the messages of the original master node to the new master node.
[0114] Specifically, each node corresponds to a database, the data in each database is synchronized, and the database is used to store the master and backup status.
[0115] In this way, by deeply integrating Kubernetes' API and controller mechanism, combined with the specific mechanisms of etcd and Kubernetes, instead of relying on ActiveMQ's own built-in shared store or replication mechanism, two HA strategies, a more cloud-native approach is adopted to achieve intelligent deployment, dynamic adjustment and fault recovery of ActiveMQ clusters, thereby significantly improving the availability and performance of ActiveMQ in PaaS services.
[0116] In one embodiment, the process of the slave node auxiliary unit attempting to compete with the corresponding slave node to become the new master node is as follows:
[0117] S1: Health check.
[0118] Specifically, the node assist unit performs a series of checks to ensure that the node instance of the same container meets the conditions for becoming the master node.
[0119] S2: Update the database key (i.e. elect a new primary node).
[0120] Specifically, the node helper unit attempts to update a specific key in the database: / service / {cluster_name} / primary, which is used to identify the master node in the current ActiveMQ Artemis message middleware cluster (i.e. the master node indication value). The node helper unit will use a CAS operation to update this key, with the purpose of ensuring the atomicity and consistency of the update operation. The node helper unit builds a CAS operation, where: the key is / service / <cluster_name> / primary, the preset value is empty, and the expected value is the last key value seen by the node helper unit, usually the last key value it listens to. Node 1 corresponding to node helper unit 1 wants to become the master node, and node helper unit 1 will attempt to update the value of this key using a CAS operation, setting the preset value of the key to empty and attempting to update the value of the key to the name of the node it corresponds to. If the current value (i.e. the actual value) of the key is indeed empty, database 1 will successfully update the value of the key to the name of the node 1 instance corresponding to node helper unit 1, at which point the node 1 instance corresponding to node helper unit 1 obtains the master node status, and if another instance, node helper unit 2, has successfully updated the value of the key before node 1 attempts to update, the CAS operation of instance node helper unit 1 will fail because the current value of the key has changed. If the CAS operation of node helper unit 1 fails, indicating that another node has become the master node, node helper unit 1 will keep node 1 in the standby node state until the next election.
[0121] S3: Message migration.
[0122] Specifically, when the control of the message broker detects a change in the master node of the ActiveMQ Artemis cluster, it will automatically deploy a temporary container that will contact the new master node in the cluster and transfer messages to the new master node, and after completing the message migration, the temporary container will shut down automatically.
[0123] S4: Service recovery.
[0124] Specifically, the endpoint slice object created by the access control of the message broker is associated with the service object through its label kubernetes.io / service-name. When the client traffic accesses the service without a selector, it will find the corresponding endpoint slice through the above association method and be routed to the master node container IP recorded in the endpoint slice. When the access control of the message broker detects a change in the role of the node corresponding to the node helper unit, it starts to update the IP recorded in the endpoint slice object to the container IP of the new master node, so as to realize that the client is not aware after the failover is successful.
[0125] S5: Listening and responding.
[0126] Specifically, the node auxiliary unit continuously monitors the key / service / in the database<cluster_name> / primary change event to monitor the information of the primary node. If the current database key / service / <cluster_name> When the value of / primary becomes empty, the node auxiliary unit will re-evaluate the status of the corresponding node instance and try to become the primary node again.
[0127] It should be understood that although Figure 1 and 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 and 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0128] In one embodiment, Figure 3As shown, a fault node switching device is provided, which is applied to a cloud platform, and is characterized in that the cloud platform includes a message middleware cluster, a database cluster and an endpoint slice, wherein data interaction is performed between the message middleware cluster and the database cluster, and data interaction is performed between the message middleware cluster and the endpoint slice, and the message middleware cluster includes a master node, multiple slave nodes and multiple node auxiliary units, and one node corresponds to one node auxiliary unit. The device includes: a first access module 301, which is used to access the master node in the message middleware cluster in response to the access request in response to the access request according to the address value in the endpoint slice, wherein the endpoint slice is used to store the master node address; a monitoring module 302, which is used to monitor the status of the master node through the master node auxiliary unit, and when it is monitored When the master node fails, the master node indication value in the database cluster is modified from the first target value to the preset value, wherein the first target value is the value corresponding to the current master node; the first processing module 303 is used to monitor the master node indication value as the preset value through multiple slave node auxiliary units, and determine the target slave node through concurrent competition; the second processing module 304 is used to modify the master node indication value to the second target value, wherein the second target value is the value corresponding to the target slave node; the switching module 305 is used to update the address value in the endpoint slice to the address value corresponding to the target slave node in response to the change of the master node indication value; the second access module 306 is used to access the target slave node in the message middleware cluster according to the updated address value in the endpoint slice to respond to the access request.
[0129] As a preferred implementation, in an embodiment of the present application, the first access module 301 is specifically used to: in response to receiving an access request, initialize the operation of the node through multiple nodes, obtain the node with the fastest initialization, use the node with the fastest initialization as the master node, and use the remaining nodes as slave nodes; write the address corresponding to the master node into the endpoint slice; and access the master node in the message middleware cluster according to the address value in the endpoint slice.
[0130] As a preferred implementation method, in an embodiment of the present application, the switching module 305 is specifically used to: send an instruction to obtain the master node to the node auxiliary unit; receive the master node obtained by the node auxiliary unit from the database cluster, and write the address value corresponding to the master node into the endpoint slice.
[0131] As a preferred implementation, in the embodiment of the present application, the second processing module 303 and the second processing module 304 are specifically configured to: when the master node indication value in the database corresponding to the slave node monitored by the slave node auxiliary unit is a preset value, taking the preset value as an expected value; performing health check on the slave node corresponding to the slave node auxiliary unit; when the slave node meets the standard of health check, acquiring the actual value of the master node indication value in the database corresponding to the slave node through the slave node auxiliary unit; comparing the expected value of the master node indication value and the actual value of the master node indication value through the slave node auxiliary unit; when the actual value and the expected value are the same, taking the slave node as a target slave node, modifying the master node indication value in the database corresponding to the slave node to a second target value, and the database cluster synchronizes the master node indication value in each database in the database cluster to the second target value in response to detecting the modification of the master node indication value; when the actual value and the expected value are different, continuously monitoring the master node indication value in the database cluster through the slave node auxiliary unit.
[0132] As a preferred implementation, in the embodiment of the present application, the second processing module 303 is specifically further configured to: determine whether the running state of the slave node is normal by sending and receiving messages between the slave node auxiliary unit and the slave node; when the running state of the slave node is normal, checking whether the resource usage and network connectivity of the slave node are within a preset range through the slave node auxiliary unit; when the resource usage and network connectivity of the slave node are within the preset range, the slave node passes the health check.
[0133] As a preferred implementation, in the embodiment of the present application, the device further comprises a storage module, and the storage module is specifically configured to: based on each node and node auxiliary unit, create a container corresponding to the node, wherein the container is mounted with a storage volume; store the messages of the node in the storage volume mounted by the container.
[0134] As a preferred implementation, in the embodiment of the present application, the device further comprises a migration module, and the migration module is specifically configured to: create a temporary container; acquire the messages of the master node from the container corresponding to the master node, and store the messages of the master node in the temporary container; associate the temporary container with the target slave node, migrate and store the messages of the master node stored in the temporary container to the container corresponding to the target slave node; delete the temporary container.
[0135] The specific limitations of the fault node switching device can be referred to the limitations of the fault node switching method in the above, which will not be repeated here. Each module in the above fault node switching device can be realized by software, hardware and combination thereof, in whole or in part. The above modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.
[0136] In one embodiment, a computer device, which can be a terminal, has an internal structure diagram as shown in Figure 4 The computer device includes a processor, a memory, a network interface, a display screen and an input device connected by a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the computer device is used to communicate with external terminals through network connection. The computer program is executed by the processor to implement a fault node switching method. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.
[0137] Those skilled in the art can understand that Figure 4 The structure shown in the above is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or less components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0138] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: S1: in response to receiving an access request, accessing a master node in a message middleware cluster in response to the access request according to an address value in an endpoint slice, wherein the endpoint slice is used to store the master node address; S2: monitoring the status of the master node through a master node auxiliary unit, and when a failure of the master node is detected, modifying the master node indication value in the database cluster from a first target value to a preset value, wherein the first target value is a value corresponding to the current master node; S3: monitoring the master node indication value as a preset value through multiple slave node auxiliary units, and determining a target slave node through concurrent competition; S4: modifying the master node indication value to a second target value, wherein the second target value is a value corresponding to the target slave node; S5: in response to a change in the master node indication value, updating the address value in the endpoint slice to an address value corresponding to the target slave node; S6: accessing the target slave node in the message middleware cluster in response to the access request according to the updated address value in the endpoint slice.
[0139] In one embodiment, the processor also implements the following steps when executing the computer program: in response to receiving an access request, performing node operation initialization through multiple nodes, obtaining the node with the fastest initialization, using the node with the fastest initialization as the master node, and using the remaining nodes as slave nodes; writing the address corresponding to the master node into the endpoint slice; and accessing the master node in the message middleware cluster according to the address value in the endpoint slice.
[0140] In one embodiment, when the processor executes the computer program, it also implements the following steps: sending an instruction to obtain the master node to the node auxiliary unit; receiving the master node obtained by the node auxiliary unit from the database cluster, and writing the address value corresponding to the master node into the endpoint slice.
[0141] In one embodiment, when the processor executes the computer program, the following steps are also implemented: the master node indication value in the database corresponding to the slave node is monitored to be a preset value by the slave node auxiliary unit, and the preset value is used as the expected value; a health check is performed on the slave node corresponding to the slave node auxiliary unit; when the slave node meets the health check criteria, the actual value of the master node indication value in the database corresponding to the slave node is obtained by the slave node auxiliary unit; the expected value of the master node indication value and the actual value of the master node indication value are compared by the slave node auxiliary unit; when the actual value and the expected value are the same, the slave node is used as the target slave node, and the master node indication value in the database corresponding to the slave node is modified to a second target value, and the database cluster synchronizes the master node indication value in each database in the database cluster to the second target value in response to detecting the modification of the master node indication value; when the actual value and the expected value are different, the master node indication value in the database cluster is continuously monitored by the slave node auxiliary unit.
[0142] In one embodiment, when the processor executes the computer program, it also implements the following steps: determining whether the operating status of the slave node is normal by sending and receiving messages between the slave node auxiliary unit and the slave node; when the operating status of the slave node is normal, checking whether the resource utilization rate and network connectivity of the slave node are within a preset range through the slave node auxiliary unit; when the resource utilization rate and network connectivity of the slave node are within the preset range, the slave node passes the health check.
[0143] In one embodiment, when the processor executes the computer program, it also implements the following steps: based on each node and the node auxiliary unit, creating a container corresponding to the node, wherein the container mounts a storage volume; and storing the message of the node in the storage volume mounted by the container.
[0144] In one embodiment, when the processor executes the computer program, the processor further implements the following steps: creating a temporary container; obtaining the master node's message from the container corresponding to the master node, and storing the master node's message in the temporary container; associating the temporary container with the target slave node, migrating and storing the master node's message stored in the temporary container to the container corresponding to the target slave node; and deleting the temporary container.
[0145] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: S1: in response to receiving an access request, accessing the master node in the message middleware cluster to respond to the access request according to the address value in the endpoint slice, wherein the endpoint slice is used to store the master node address; S2: monitoring the status of the master node through the master node auxiliary unit, and when it is detected that the master node fails, modifying the master node indication value in the database cluster from the first target value to the preset value, wherein the first target value is the value corresponding to the current master node; S3: monitoring the master node indication value as the preset value through multiple slave node auxiliary units, and determining the target slave node through concurrent competition; S4: modifying the master node indication value to the second target value, wherein the second target value is the value corresponding to the target slave node; S5: in response to the change of the master node indication value, updating the address value in the endpoint slice to the address value corresponding to the target slave node;
[0146] S6: According to the updated address value in the endpoint slice, access the target slave node in the message middleware cluster to respond to the access request.
[0147] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: in response to receiving an access request, initializing the operation of the node through multiple nodes, obtaining the node with the fastest initialization, using the node with the fastest initialization as the master node, and using the remaining nodes as slave nodes; writing the address corresponding to the master node into the endpoint slice; and accessing the master node in the message middleware cluster according to the address value in the endpoint slice.
[0148] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: sending an instruction to obtain the master node to the node auxiliary unit; receiving the master node obtained by the node auxiliary unit from the database cluster, and writing the address value corresponding to the master node into the endpoint slice.
[0149] In one embodiment, the computer program, when executed by the processor, further implements the following steps: monitoring, by the slave node auxiliary unit, the master node indication value in the database corresponding to the slave node, and taking the preset value as the expected value when the master node indication value is the preset value; performing health check on the slave node corresponding to the slave node auxiliary unit; obtaining, by the slave node auxiliary unit, the actual value of the master node indication value in the database corresponding to the slave node when the slave node meets the standard of the health check; comparing, by the slave node auxiliary unit, the expected value of the master node indication value with the actual value of the master node indication value; when the actual value and the expected value are the same, taking the slave node as a target slave node, modifying the master node indication value in the database corresponding to the slave node to a second target value, and synchronizing the master node indication value in each database in the database cluster to the second target value in response to detecting the modification of the master node indication value; and when the actual value and the expected value are different, continuously monitoring, by the slave node auxiliary unit, the master node indication value in the database cluster.
[0150] In one embodiment, the computer program, when executed by the processor, further implements the following steps: determining whether the running state of the slave node is normal by sending and receiving messages between the slave node auxiliary unit and the slave node; when the running state of the slave node is normal, checking, by the slave node auxiliary unit, whether the resource usage and network connectivity of the slave node are within a preset range; and when the resource usage and network connectivity of the slave node are within the preset range, the slave node passes the health check.
[0151] In one embodiment, the computer program, when executed by the processor, further implements the following steps: creating a container corresponding to each node based on each node and node auxiliary unit, wherein the container is mounted with a storage volume; and storing the messages of the node in the storage volume mounted by the container.
[0152] In one embodiment, the computer program, when executed by the processor, further implements the following steps: creating a temporary container; obtaining the messages of the master node from the container corresponding to the master node, and storing the messages of the master node in the temporary container; associating the temporary container with the target slave node, migrating and storing the messages of the master node stored in the temporary container to the container corresponding to the target slave node; and deleting the temporary container.
[0153] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0154] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0155] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A fault node switching method, applied to a cloud platform, characterized in that: The cloud platform includes a message middleware cluster, a database cluster, and endpoint slices, wherein data is exchanged between the message middleware cluster and the database cluster, and data is exchanged between the message middleware cluster and the endpoint slices. The message middleware cluster includes a master node, multiple slave nodes, and multiple node auxiliary units, and each node corresponds to one node auxiliary unit. The method includes: In response to receiving the access request, accessing a master node in the message middleware cluster according to an address value in an endpoint slice to respond to the access request, wherein the endpoint slice is used to store the master node address; Monitoring the status of the master node by a master node auxiliary unit, and when a failure of the master node is detected, modifying the master node indication value in the database cluster from a first target value to a preset value, wherein the first target value is a value corresponding to the current master node; The master node indication value is monitored by multiple slave node auxiliary units to be a preset value, and a target slave node is determined through concurrent competition; Modify the master node indication value to a second target value, wherein the second target value is a value corresponding to the target slave node; In response to a change in the master node indication value, updating the address value in the endpoint slice to the address value corresponding to the target slave node; According to the updated address value in the endpoint slice, the target slave node in the message middleware cluster is accessed to respond to the access request.
2. The fault node switching method according to claim 1, characterized in that: In response to receiving the access request, accessing the master node in the message middleware cluster according to the address value in the endpoint slice to respond to the access request includes: In response to receiving the access request, performing node operation initialization through multiple nodes, obtaining the node with the fastest initialization, using the node with the fastest initialization as the master node, and using the remaining nodes as slave nodes; Writing the address corresponding to the master node into the endpoint slice; Access the master node in the message middleware cluster according to the address value in the endpoint slice.
3. The fault node switching method according to claim 1, characterized in that: The updating of the address value in the endpoint slice to the address value corresponding to the target slave node in response to the change in the master node indication value includes: Send the command to obtain the master node to the node auxiliary unit; The receiving node auxiliary unit obtains the master node from the database cluster, and writes the address value corresponding to the master node into the endpoint slice.
4. The method for switching a faulty node according to claim 1, wherein: The database cluster includes multiple databases, each database includes the same master node indication value, each node corresponds to a database, each node auxiliary unit monitors the database corresponding to the node, the master node indication value monitored by multiple slave node auxiliary units is a preset value, and a target slave node is determined through concurrent competition, and the master node indication value is modified to a second target value, wherein the second target value is a value corresponding to the target slave node, including: The master node indication value in the database corresponding to the slave node is monitored by the slave node auxiliary unit as a preset value, and the preset value is used as the expected value; Performing a health check on the slave node corresponding to the slave node auxiliary unit; When the slave node meets the health check standard, the slave node auxiliary unit obtains the actual value of the master node indication value in the database corresponding to the slave node; Comparing the expected value of the master node indication value and the actual value of the master node indication value by the slave node auxiliary unit; When the actual value is the same as the expected value, the slave node is used as a target slave node, the master node indication value in the database corresponding to the slave node is modified to a second target value, and in response to detecting the modification of the master node indication value, the database cluster synchronizes the master node indication value in each database in the database cluster to the second target value; When the actual value is different from the expected value, the master node indication value in the database cluster is continuously monitored by the slave node auxiliary unit.
5. The fault node switching method according to claim 4, characterized in that: The performing a health check on the slave node corresponding to the slave node auxiliary unit includes: Determining whether the operating status of the slave node is normal by sending and receiving messages between the slave node auxiliary unit and the slave node; When the operating state of the slave node is normal, checking whether the resource utilization rate and network connectivity of the slave node are within a preset range through the slave node auxiliary unit; When the resource usage and network connectivity of the slave node are within a preset range, the slave node passes the health check.
6. The method for switching a faulty node according to claim 1, wherein: Before responding to the access request, the method further includes: Based on each node and node auxiliary unit, create a container corresponding to the node, wherein the container mounts a storage volume; The node's messages are stored in the storage volume mounted by the container.
7. The method for switching a faulty node according to claim 6, wherein: After updating the address value in the endpoint slice to the address value corresponding to the target slave node, the method further includes: Create a temporary container; Obtaining a message of the master node from a container corresponding to the master node, and storing the message of the master node in the temporary container; Associating the temporary container with the target slave node, migrating and storing the master node's messages stored in the temporary container into the container corresponding to the target slave node; Delete the temporary container.
8. A fault node switching device, applied to a cloud platform, characterized in that: The cloud platform includes a message middleware cluster, a database cluster, and endpoint slices, wherein the message middleware cluster and the database cluster interact with each other, and the message middleware cluster and the endpoint slice interact with each other. The message middleware cluster includes a master node, multiple slave nodes, and multiple node auxiliary units, and each node corresponds to one node auxiliary unit. The device includes: A first access module is configured to, in response to receiving an access request, access a master node in the message middleware cluster according to an address value in an endpoint slice to respond to the access request, wherein the endpoint slice is used to store the master node address; a monitoring module configured to monitor the status of the master node through a master node auxiliary unit, and when a failure of the master node is detected, modify the master node indication value in the database cluster from a first target value to a preset value, wherein the first target value is a value corresponding to the current master node; A first processing module is configured to monitor, through a plurality of slave node auxiliary units, that the master node indication value is a preset value, and determine a target slave node through concurrent competition; A second processing module is configured to modify the master node indication value to a second target value, wherein the second target value is a value corresponding to the target slave node; a switching module, configured to update the address value in the endpoint slice to the address value corresponding to the target slave node in response to a change in the master node indication value; The second access module is used to access the target slave node in the message middleware cluster to respond to the access request based on the updated address value in the endpoint slice.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Master-slave switching method and device for database cluster nodes, equipment and medium
CN111200532A
Network endpoint slicing method and system based on Kubernetes container
CN112104486A