CN117675846A - Cache cluster maintenance method, device, electronic equipment and computer readable medium - Google Patents

Cache cluster maintenance method, device, electronic equipment and computer readable medium Download PDF

Info

Publication number
CN117675846A
CN117675846A CN202311545354.XA CN202311545354A CN117675846A CN 117675846 A CN117675846 A CN 117675846A CN 202311545354 A CN202311545354 A CN 202311545354A CN 117675846 A CN117675846 A CN 117675846A
Authority
CN
China
Prior art keywords
node
cache
cluster
slave
old
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311545354.XA
Other languages
Chinese (zh)
Inventor
刘金铭
魏立群
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
CCB Finetech Co Ltd
Original Assignee
China Construction Bank Corp
CCB Finetech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp, CCB Finetech Co Ltd filed Critical China Construction Bank Corp
Priority to CN202311545354.XA priority Critical patent/CN117675846A/en
Publication of CN117675846A publication Critical patent/CN117675846A/en
Pending legal-status Critical Current

Links

Landscapes

  • Hardware Redundancy (AREA)

Abstract

The invention discloses a cache cluster maintenance method, a device, electronic equipment and a computer readable medium, and relates to the technical field of cache clusters. The method comprises the following steps: each new node is used as a slave node to be added into a cache cluster; adding the address of each new node into the cache configuration information of the application service, and restarting the application service; switching a new slave node newly added into the cache cluster into a master node, and switching an old master node of the cache cluster into a slave node; deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, and restarting the application service; and deleting the old master node and the old slave node from the cache cluster. The implementation mode can solve the technical problem that the application service needs to be stopped.

Description

Cache cluster maintenance method, device, electronic equipment and computer readable medium
Technical Field
The present invention relates to the field of cache clusters, and in particular, to a method and apparatus for maintaining a cache cluster, an electronic device, and a computer readable medium.
Background
In online application systems using Redis cluster mode, if maintenance, such as application upgrade, system upgrade, or hardware maintenance, is to be performed on the Redis cluster node server, it is often necessary to stop the Redis cluster service, which may cause a problem of cache data loss. Moreover, because the online transaction of the application system has a large number of application scenes for reading and writing the Redis cache, if the Redis service is stopped, the online application can report the abnormality that the cache cannot be connected at any time, and the online return failure is directly caused.
In order not to generate an online transaction failure situation, conventional schemes may be adopted: stopping application service before stopping Redis service, restarting application after caching is available, and taking the application as the most conventional operation scheme, so that the method has the advantages of high safety and low error probability; the disadvantage is that the application downtime involves business impacts, requiring early notification to the user.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, an electronic device, and a computer readable medium for maintaining a cache cluster, so as to solve a technical problem that an application service needs to be stopped.
To achieve the above object, according to an aspect of the embodiments of the present invention, there is provided a method for maintaining a cache cluster, including:
each new node is used as a slave node to be added into a cache cluster;
adding the address of each new node into the cache configuration information of the application service, and restarting the application service;
switching a new slave node newly added into the cache cluster into a master node, and switching an old master node of the cache cluster into a slave node;
deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, and restarting the application service;
And deleting the old master node and the old slave node from the cache cluster.
Optionally, before adding each new node as a slave node to the cache cluster, the method further includes:
logging in each new node one by one, and checking the node state of each new node;
logging in a node of a cache cluster, and checking the node state of the node;
the node states comprise a process state, a service state, a password, a data quantity, a port number and a cluster situation, wherein the cluster situation comprises a current state of a cluster, nodes contained in the cluster, master-slave relations of all nodes and partition situations of each node in the cluster.
Optionally, adding each new node as a slave node to the cache cluster includes:
2N new nodes are added into the cache cluster as slave nodes of N master nodes, and each master node is newly added with two slave nodes.
Optionally, switching a new slave node newly added to the cache cluster to a master node, and switching an old master node of the cache cluster to a slave node, including:
and switching N new slave nodes newly added into the cache cluster into a master node, and switching N old master nodes of the cache cluster into slave nodes.
Optionally, before deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, the method further includes:
and executing shutdown operation on the old master node and the old slave node so as to enable the node states of the old master node and the old slave node to be shutdown states.
Optionally, after restarting the application service, the method further includes:
and checking the cache connection condition of the application service, wherein the cache connection condition comprises a starting log of the application service and whether the cache connection is in error or not.
In addition, according to another aspect of the embodiment of the present invention, there is provided a cache cluster maintenance apparatus, including:
the joining module is used for joining each new node into the cache cluster as a slave node;
the configuration module is used for adding the address of each new node into the cache configuration information of the application service and restarting the application service; deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, and restarting the application service;
the switching module is used for switching a new slave node newly added into the cache cluster into a master node and switching an old master node of the cache cluster into a slave node;
And the deleting module is used for deleting the old master node and the old slave node from the cache cluster.
Optionally, the device further comprises an inspection module for:
logging in each new node one by one, and checking the node state of each new node;
logging in a node of a cache cluster, and checking the node state of the node;
the node states comprise a process state, a service state, a password, a data quantity, a port number and a cluster situation, wherein the cluster situation comprises a current state of a cluster, nodes contained in the cluster, master-slave relations of all nodes and partition situations of each node in the cluster.
Optionally, the joining module is further configured to:
2N new nodes are added into the cache cluster as slave nodes of N master nodes, and each master node is newly added with two slave nodes.
Optionally, the switching module is further configured to:
and switching N new slave nodes newly added into the cache cluster into a master node, and switching N old master nodes of the cache cluster into slave nodes.
Optionally, the deletion module is further configured to:
before deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, executing a shutdown operation on the old master node and the old slave node so as to enable the node states of the old master node and the old slave node to be shutdown states.
Optionally, the configuration module is further configured to:
after restarting the application service, checking the cache connection condition of the application service, wherein the cache connection condition comprises a starting log of the application service and whether the cache connection is in error or not.
According to another aspect of an embodiment of the present invention, there is also provided an electronic device including:
one or more processors;
storage means for storing one or more programs,
the one or more processors implement the method of any of the embodiments described above when the one or more programs are executed by the one or more processors.
According to another aspect of an embodiment of the present invention, there is also provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements the method according to any of the embodiments described above.
According to another aspect of embodiments of the present invention, there is also provided a computer program product comprising a computer program which, when executed by a processor, implements the method according to any of the embodiments described above.
One embodiment of the above invention has the following advantages or benefits: because each new node is added into the cache cluster as the slave node, the new slave node newly added into the cache cluster is switched to the master node, the old master node of the cache cluster is switched to the slave node, and the old master node and the old slave node are deleted from the cache cluster, the technical problem that the application service in the prior art needs to be stopped is solved. According to the embodiment of the invention, a set of new node servers replace an online cluster server, so that operation and maintenance operations can be performed on new nodes in advance, the operation can be performed in advance, only the switching operation is performed on an online change time window, the change time is saved, and the problem of cache data loss can be avoided; and by configuring the cache configuration information of the plurality of sets of cluster nodes and using the cache configuration information in different stages, the application read-write request can not fail in the process of master-slave switching between new and old nodes, the application service can not be influenced by the maintenance of the cache clusters, and the application service does not need to be stopped, so that the service can be ensured to be continuously carried out.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. Wherein:
FIG. 1 is a flow chart of a cache cluster maintenance method according to an embodiment of the invention;
FIG. 2 is a flow chart of a method of maintaining a cache cluster according to one referenceable embodiment of the invention;
FIG. 3 is a schematic diagram of a new node being added to a cache cluster as a slave node in accordance with an embodiment of the invention;
FIG. 4 is a schematic diagram after a master-slave switch according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a new cache cluster according to an embodiment of the invention;
FIG. 6 is a flow chart of a method of maintaining a cache cluster according to another referenceable embodiment of the invention;
FIG. 7 is a schematic diagram of a cache cluster maintenance apparatus according to an embodiment of the invention;
FIG. 8 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 9 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the technical scheme of the invention, the aspects of acquisition, analysis, use, transmission, storage and the like of the related user personal information all meet the requirements of related laws and regulations, are used for legal and reasonable purposes, are not shared, leaked or sold outside the aspects of legal use and the like, and are subjected to supervision and management of a supervision department. Necessary measures should be taken for the personal information of the user to prevent illegal access to such personal information data, ensure that personnel having access to the personal information data comply with the regulations of the relevant laws and regulations, and ensure the personal information of the user. Once these user personal information data are no longer needed, the risk should be minimized by limiting or even prohibiting the data collection and/or deletion.
User privacy is protected, when applicable, by de-identifying the data, including in some related applications, such as by removing a particular identifier (e.g., date of birth, etc.), controlling the amount or specificity of stored data, controlling how the data is stored, and/or other methods.
Fig. 1 is a flowchart of a cache cluster maintenance method according to an embodiment of the present invention. As an embodiment of the present invention, as shown in fig. 1, the cache cluster maintenance method may include:
and step 101, each new node is added into the cache cluster as a slave node.
First, each new node is logged in, and a node joining command is executed, for example: redis-cli-a [ password ] - -cluster add-node [ new slave node ip: port ] [ old master node ip: port ] -a [ password ] - -cluster-slave [ old master node id ], thereby adding each new node as a slave node into the current cache cluster.
Optionally, after each new node is added to the cache cluster as a slave node, a > cluster nodes command is executed to check the state of the cache cluster, for example to check that the new node was successfully added under the master node as a slave node.
Optionally, before step 101, the method further includes: logging in each new node one by one, and checking the node state of each new node; logging in a node of a cache cluster, and checking the node state of the node; the node states comprise a process state, a service state, a password, a data quantity, a port number and a cluster situation, wherein the cluster situation comprises a current state of a cluster, nodes contained in the cluster, master-slave relations of all nodes and partition situations of each node in the cluster. In the embodiment of the invention, before each new node is added into a cache cluster as a slave node, each new node is logged in, a Redis-cli-h [ current node ip ] -p [ current node port ] -a [ password ] command is executed on the new node to check the process state, service state, password and port number of the new node, a > dbsize command can be executed on the new node to check whether the data volume of the node is zero, a > cluster nodes command can be executed on the new node to check whether the node has no cluster information.
Further, any node of the cache cluster may be logged in, and a Redis-cli-h [ current node ip ] -p [ current node port ] -a [ password ] command may be executed on the node to check a process state, a service state, a password, and a port number of the cluster, a > dbsize command may be executed on the node to check whether a data size of the node is greater than zero, a > clusterides command may be executed on a new node to check a cluster condition of the node, such as a current state of the cluster, nodes included in the cluster, a master-slave relationship of each node, a partition condition of each node in the cluster, and the like.
Optionally, the cache cluster is a dis cluster, in which a master node provides a query service and a slave node provides a write service. The embodiment of the invention provides cache service by adopting a Redis cluster mode, which is a technology for realizing high availability, data slicing and load balancing by connecting a plurality of Redis nodes together. It allows Redis to provide services on different nodes simultaneously, improving overall performance and reliability. In cluster mode, nodes are divided into a master node and a slave node, and requests are routed to corresponding nodes according to hash values of keys. The system may have a plurality of master nodes in cluster mode, and each master node may correspond to one or more slave nodes as data redundancy. The master node is responsible for handling requests to write data and the slave node is responsible for handling requests to read data. When the master node is abnormal, the cluster switches one slave node corresponding to the master node into the master node.
And adding a node function by using the Redis cluster mode, adding a new node with installed Redis basic software into a cache cluster as a slave node, wherein the cluster can automatically synchronize application data from the master node to the new slave node. After synchronization, the new node can provide query service as other slave nodes and can be switched to the master node.
And 102, adding the address of each new node to the cache configuration information of the application service, and restarting the application service.
After each new node is added into the cache cluster as a slave node, the IP address of each new node is added into the cache configuration information of the application service, then the application service is restarted, and the Redis connection condition of the application service is checked, such as checking the starting log of the application service and whether the Redis connection is in error or not.
Because the Redis writing can only be performed on the master node, the IP address of the new node needs to be added in the cache configuration information of the application service in advance before the new slave node and the old master node are replaced by the master-slave switching method, so that when the master-slave switching is performed, if a writing operation request exists, the application service can still find the master node, and the failure caused by the fact that the master node cannot be found can be avoided.
And step 103, switching the new slave node newly added into the cache cluster into a master node, and switching the old master node of the cache cluster into a slave node.
Specifically, a Redis command end is logged in a new slave node, and the new slave node newly added into the cache cluster is switched to a master node by executing a > CLUSTERRFAILOVER command, so that the old master node of the cache cluster is switched to the slave node.
And 104, deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, and restarting the application service.
After performing master-slave switching on the old master node and the new slave node in the cache cluster, deleting the IP address of the old master node and the IP address of the old slave node from the cache configuration information of the application service, restarting the application service, and checking the Redis connection condition of the application service, such as checking the starting log of the application service and whether the Redis connection is in error.
In the embodiment of the present invention, three sets of cache configuration information are required to be prepared, namely, a pre-handover version (the IP address of the old master node and the IP address of the old slave node), an in-handover version (the IP address of the new node is added on the basis of the pre-handover version), and a post-handover version (the IP address of the new node).
And 105, deleting the old master node and the old slave node from the cache cluster.
Specifically, a node deletion command may be executed to delete the old master node and the old slave node from the cache cluster, where the node deletion command may be: redis-cli-a [ password ] - -clusteridel-node [ old slave node ip: port ]. After the old master node and the old slave node are deleted, the nodes in the cluster only have new master nodes and new slave nodes.
The embodiment of the invention increases cluster nodes by introducing new nodes on the basis of the existing cache clusters, realizes online maintenance by utilizing a master-slave data synchronization mechanism of a cluster mode, modifying cache configuration information of application service and other methods, and has no influence on the application service.
According to the various embodiments described above, it can be seen that in the embodiments of the present invention, by adding each new node as a slave node into a cache cluster, switching the new slave node newly added into the cache cluster to a master node, switching the old master node of the cache cluster to a slave node, and deleting the old master node and the old slave node from the cache cluster, the technical problem that in the prior art, an application service needs to be stopped is solved. According to the embodiment of the invention, a set of new node servers replace an online cluster server, so that operation and maintenance operations can be performed on new nodes in advance, the operation can be performed in advance, only the switching operation is performed on an online change time window, the change time is saved, and the problem of cache data loss can be avoided; and by configuring the cache configuration information of the plurality of sets of cluster nodes and using the cache configuration information in different stages, the application read-write request can not fail in the process of master-slave switching between new and old nodes, the application service can not be influenced by the maintenance of the cache clusters, and the application service does not need to be stopped, so that the service can be ensured to be continuously carried out.
Fig. 2 is a flow chart of a method of maintaining a cache cluster according to one exemplary embodiment of the present invention. As yet another embodiment of the present invention, as shown in fig. 2, the cache cluster maintenance method may include:
in step 201, 2N new nodes are added to the cache cluster as slave nodes of N master nodes, and each master node is newly added with two slave nodes.
If the number of the master nodes in the cache cluster is N, the number of the new nodes is 2N, the 2N new nodes are added into the cache cluster as the slave nodes of the N master nodes, and two slave nodes are newly added under each master node. For each master node, if the number of slave nodes under the master node is N, after 2N new nodes are added to the cache cluster as slave nodes of N master nodes, the number of slave nodes under each master node is n+2.
As shown in fig. 3, the application system calls a set of three-master three-slave configuration Redis clusters as a system distributed cache for storing application data, and the application system online transactions read and write the data from the clusters in real time. Since there are 3 master nodes in the cluster, 6 new nodes are added to the cache cluster as slave nodes of N master nodes, and two slave nodes are newly added under each master node, at this time, there are 3 slave nodes under each master node.
Specifically, each new node is logged in separately, and a node joining command is executed, for example: redis-cli-a [ password ] - -cluster add-node [ new slave node ip: port ] [ old master node ip: port ] -a [ password ] - -cluster-slave [ old master node id ], thereby adding each new node as a slave node into the current cache cluster. And adding a node function by using the Redis cluster mode, adding a new node with installed Redis basic software into a cache cluster as a slave node, wherein the cluster can automatically synchronize application data from the master node to the new slave node. After synchronization, the new node can provide query service as other slave nodes and can be switched to the master node.
And 202, adding the address of each new node to the cache configuration information of the application service, and restarting the application service.
As shown in fig. 4, after 6 new nodes are added to the cache cluster as slave nodes, the IP addresses of the 6 new nodes (the IP addresses of node 7, node 8, node 9, node 10, node 11, and node 12) are added to the cache configuration information of the application service, and then the application service is restarted and the condition of the dis connection of the application service is checked, for example, the start log of the application service is checked, and whether the dis connection is misplaced is checked.
Because the Redis writing can only be performed on the master node, the IP address of the new node needs to be added in the cache configuration information of the application service in advance before the new slave node and the old master node are replaced by the master-slave switching method, so that when the master-slave switching is performed, if a writing operation request exists, the application service can still find the master node, and the failure caused by the fact that the master node cannot be found can be avoided.
And 203, switching N new slave nodes newly added into the cache cluster into master nodes, and switching N old master nodes of the cache cluster into slave nodes.
As shown in fig. 4, since 6 new nodes are added to the cache cluster as slave nodes of 3 master nodes, in this step, 3 new slave nodes (such as node 10, node 11, node 12) newly added to the cache cluster are switched to the master node, and at the same time, 3 old master nodes in the cache cluster are switched to the slave nodes. Specifically, a Redis command end is logged in a new slave node, and the new slave node newly added into the cache CLUSTER is switched to a master node by executing a > CLUSTER FAILOVER command, so that the old master node of the cache CLUSTER is switched to the slave node.
And 204, deleting the addresses of the N old master nodes and the addresses of the N old slave nodes from the cache configuration information of the application service, and restarting the application service.
After performing master-slave switching on N old master nodes and N new slave nodes in the cache cluster, deleting the IP addresses of the N old master nodes and the IP addresses of the N old slave nodes from the cache configuration information of the application service, restarting the application service, and checking the Redis connection condition of the application service, such as checking a starting log of the application service and whether the Redis connection is in error.
As shown in fig. 5, the IP addresses of the node 1, the node 2, the node 3, the node 4, the node 5, and the node 6 are deleted from the cache configuration information of the application service, and then the application service is restarted and the Redis connection condition of the application service is checked.
In the embodiment of the present invention, three sets of cache configuration information are prepared, namely, a pre-handover version (IP addresses of node 1, node 2, node 3, node 4, node 5, and node 6), an in-handover version (IP addresses of node 1, node 2, node 3, node 4, node 5, node 6, node 7, node 8, node 9, node 10, node 11, and node 12), and a post-handover version (IP addresses of node 7, node 8, node 9, node 10, node 11, and node 12).
And step 205, deleting the N old master nodes and the N old slave nodes from the cache cluster.
Specifically, a node deletion command may be executed to delete N old master nodes and N old slave nodes from the cache cluster, where the node deletion command may be: redis-cli-a [ password ] - -cluster del-node [ old slave node ip: port ]. After the old master node and the old slave node are deleted, the nodes in the cluster only have new master nodes and new slave nodes. As shown in fig. 5, nodes 1, 2, 3, 4, 5, 6 are deleted from the cache cluster, and only nodes 7, 8, 9, 10, 11, 12 remain in the cache set.
In addition, in the embodiment of the present invention, the implementation of the method for maintaining a cache cluster has been described in detail in the foregoing method for maintaining a cache cluster, so that the description is not repeated here.
Fig. 6 is a flowchart of a method for maintaining a cache cluster according to another exemplary embodiment of the present invention. As another embodiment of the present invention, as shown in fig. 6, the cache cluster maintenance method may include:
step 601, logging in each new node one by one, checking the node state of each new node, logging in the nodes of the cache cluster, and checking the node state of the nodes. The node states comprise a process state, a service state, a password, a data quantity, a port number and a cluster situation, wherein the cluster situation comprises a current cluster state, nodes contained in the cluster, master-slave relations of all nodes and partition situations of each node in the cluster.
In this step, each new node is logged in, and a Redis-cli-h [ current node ip ] -p [ current node port ] -a [ password ] command is executed on the new node to check the process state, service state, password and port number of the new node, and a > dbsize command may be executed on the new node to check whether the data size of the node is zero, and a > cluster nodes command may be executed on the new node to check whether the node has no cluster information.
Any node of the cache cluster can be logged in, a Redis-cli-h [ current node ip ] -p [ current node port ] -a [ password ] command is executed on the node to check the process state, service state, password and port number of the cluster, a > dbsize command can be executed on the node to check whether the data volume of the node is greater than zero, a > cluster nodes command can be executed on a new node to check the cluster condition of the node, such as the current state of the cluster, the nodes contained in the cluster, the master-slave relationship of each node, the partition condition of each node in the cluster, and the like.
And step 602, adding each new node as a slave node of the master node into the cache cluster, and enabling each master node to newly add two slave nodes.
And step 603, adding the address of each new node to the cache configuration information of the application service, restarting the application service and checking the cache connection condition of the application service. The cache connection condition comprises a starting log of the application service and whether the cache connection is in error reporting or not.
Step 604, switching each new slave node newly added into the cache cluster to a master node, and switching an old master node of the cache cluster to a slave node.
And step 605, executing shutdown operation on the old master node and the old slave node so as to enable the node states of the old master node and the old slave node to be shutdown states.
Specifically, a Redis command end is logged in at the new node, and a shutdown command is executed, so that the old master node and the old slave node are disconnected, namely, the node states of the old master node and the old slave node are in shutdown states.
And step 606, deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, restarting the application service and checking the cache connection condition of the application service. The cache connection condition comprises a starting log of the application service and whether the cache connection is in error reporting or not.
And step 607, deleting the old master node and the old slave node from the cache cluster.
In addition, in another embodiment of the present invention, the implementation of the method for maintaining a cache cluster has been described in detail in the foregoing method for maintaining a cache cluster, so that the description is not repeated here.
Fig. 7 is a schematic diagram of a cache cluster maintenance apparatus according to an embodiment of the present invention. As shown in fig. 7, the cache cluster maintenance device 700 includes a joining module 701, a configuration module 702, a switching module 703, and a deleting module 704; the adding module 701 is configured to add each new node as a slave node into the cache cluster; the configuration module 702 is configured to add the address of each new node to the cache configuration information of the application service, and restart the application service; deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, and restarting the application service; the switching module 703 is configured to switch a new slave node newly added to the cache cluster to a master node, and switch an old master node of the cache cluster to a slave node; the deletion module 704 is configured to delete the old master node and the old slave node from the cache cluster.
Optionally, the device further comprises an inspection module for:
logging in each new node one by one, and checking the node state of each new node;
logging in a node of a cache cluster, and checking the node state of the node;
the node states comprise a process state, a service state, a password, a data quantity, a port number and a cluster situation, wherein the cluster situation comprises a current state of a cluster, nodes contained in the cluster, master-slave relations of all nodes and partition situations of each node in the cluster.
Optionally, the adding module 701 is further configured to:
2N new nodes are added into the cache cluster as slave nodes of N master nodes, and each master node is newly added with two slave nodes.
Optionally, the switching module 703 is further configured to:
and switching N new slave nodes newly added into the cache cluster into a master node, and switching N old master nodes of the cache cluster into slave nodes.
Optionally, the deletion module 704 is further configured to:
before deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, executing a shutdown operation on the old master node and the old slave node so as to enable the node states of the old master node and the old slave node to be shutdown states.
Optionally, the configuration module 702 is further configured to:
after restarting the application service, checking the cache connection condition of the application service, wherein the cache connection condition comprises a starting log of the application service and whether the cache connection is in error or not.
The specific implementation of the cache cluster maintenance device of the present invention is described in detail in the above-mentioned cache cluster maintenance method, so that the description thereof will not be repeated here.
Fig. 8 illustrates an exemplary system architecture 800 to which a cache cluster maintenance method or cache cluster maintenance apparatus of embodiments of the present invention may be applied.
As shown in fig. 8, a system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. The network 804 serves as a medium for providing communication links between the terminal devices 801, 802, 803 and the server 805. The network 804 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 805 through the network 804 using the terminal devices 801, 802, 803 to receive or send messages or the like. Various communication client applications such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only) may be installed on the terminal devices 801, 802, 803.
The terminal devices 801, 802, 803 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 805 may be a server providing various services, such as a background management server (by way of example only) that provides support for shopping-type websites browsed by users using the terminal devices 801, 802, 803. The background management server can analyze and other data such as the received article information inquiry request and feed back the processing result to the terminal equipment.
It should be noted that, the method for maintaining a cache cluster according to the embodiment of the present invention is generally executed by the server 805, and accordingly, the device for maintaining a cache cluster is generally disposed in the server 805.
It should be understood that the number of terminal devices, networks and servers in fig. 8 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 9, there is illustrated a schematic diagram of a computer system 900 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 9 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU) 901, which can execute various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. In the RAM903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901, ROM 902, and RAM903 are connected to each other through a bus 904. An input/output (I/O) interface 905 is also connected to the bus 904.
The following components are connected to the I/O interface 905: an input section 906 including a keyboard, a mouse, and the like; an output portion 907 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage portion 908 including a hard disk or the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as needed. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on the drive 910 so that a computer program read out therefrom is installed into the storage section 908 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from the network via the communication portion 909 and/or installed from the removable medium 911. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 901.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer programs according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes a joining module, a configuration module, a switching module, and a deleting module, wherein the names of the modules do not constitute a limitation on the module itself in some cases.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, implement the method of: each new node is used as a slave node to be added into a cache cluster; adding the address of each new node into the cache configuration information of the application service, and restarting the application service; switching a new slave node newly added into the cache cluster into a master node, and switching an old master node of the cache cluster into a slave node; deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, and restarting the application service; and deleting the old master node and the old slave node from the cache cluster.
As a further aspect, embodiments of the present invention also provide a computer program product comprising a computer program which, when executed by a processor, implements the method according to any of the above embodiments.
According to the technical scheme of the embodiment of the invention, each new node is added into the cache cluster as the slave node, the new slave node newly added into the cache cluster is switched to the master node, the old master node of the cache cluster is switched to the slave node, and the old master node and the old slave node are deleted from the cache cluster, so that the technical problem that the application service needs to be stopped in the prior art is solved. According to the embodiment of the invention, a set of new node servers replace an online cluster server, so that operation and maintenance operations can be performed on new nodes in advance, the operation can be performed in advance, only the switching operation is performed on an online change time window, the change time is saved, and the problem of cache data loss can be avoided; and by configuring the cache configuration information of the plurality of sets of cluster nodes and using the cache configuration information in different stages, the application read-write request can not fail in the process of master-slave switching between new and old nodes, the application service can not be influenced by the maintenance of the cache clusters, and the application service does not need to be stopped, so that the service can be ensured to be continuously carried out.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (15)

1. The cache cluster maintenance method is characterized by comprising the following steps:
each new node is used as a slave node to be added into a cache cluster;
adding the address of each new node into the cache configuration information of the application service, and restarting the application service;
switching a new slave node newly added into the cache cluster into a master node, and switching an old master node of the cache cluster into a slave node;
deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, and restarting the application service;
and deleting the old master node and the old slave node from the cache cluster.
2. The method of claim 1, wherein prior to joining each new node as a slave node to the cache cluster, further comprising:
logging in each new node one by one, and checking the node state of each new node;
logging in a node of a cache cluster, and checking the node state of the node;
the node states comprise a process state, a service state, a password, a data quantity, a port number and a cluster situation, wherein the cluster situation comprises a current state of a cluster, nodes contained in the cluster, master-slave relations of all nodes and partition situations of each node in the cluster.
3. The method of claim 1, wherein joining each new node as a slave node into the cache cluster comprises:
2N new nodes are added into the cache cluster as slave nodes of N master nodes, and each master node is newly added with two slave nodes.
4. A method according to claim 3, wherein switching a new slave node newly joining the cache cluster to a master node and switching an old master node of the cache cluster to a slave node comprises:
and switching N new slave nodes newly added into the cache cluster into a master node, and switching N old master nodes of the cache cluster into slave nodes.
5. The method of claim 1, wherein prior to deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, further comprising:
and executing shutdown operation on the old master node and the old slave node so as to enable the node states of the old master node and the old slave node to be shutdown states.
6. The method of claim 1, further comprising, after restarting the application service:
and checking the cache connection condition of the application service, wherein the cache connection condition comprises a starting log of the application service and whether the cache connection is in error or not.
7. A cache cluster maintenance device, comprising:
the joining module is used for joining each new node into the cache cluster as a slave node;
the configuration module is used for adding the address of each new node into the cache configuration information of the application service and restarting the application service; deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, and restarting the application service;
the switching module is used for switching a new slave node newly added into the cache cluster into a master node and switching an old master node of the cache cluster into a slave node;
and the deleting module is used for deleting the old master node and the old slave node from the cache cluster.
8. The apparatus of claim 7, further comprising an inspection module to:
logging in each new node one by one, and checking the node state of each new node;
logging in a node of a cache cluster, and checking the node state of the node;
the node states comprise a process state, a service state, a password, a data quantity, a port number and a cluster situation, wherein the cluster situation comprises a current state of a cluster, nodes contained in the cluster, master-slave relations of all nodes and partition situations of each node in the cluster.
9. The apparatus of claim 7, wherein the joining module is further configured to:
2N new nodes are added into the cache cluster as slave nodes of N master nodes, and each master node is newly added with two slave nodes.
10. The apparatus of claim 9, wherein the switching module is further configured to:
and switching N new slave nodes newly added into the cache cluster into a master node, and switching N old master nodes of the cache cluster into slave nodes.
11. The apparatus of claim 7, wherein the deletion module is further configured to:
before deleting the address of the old master node and the address of the old slave node from the cache configuration information of the application service, executing a shutdown operation on the old master node and the old slave node so as to enable the node states of the old master node and the old slave node to be shutdown states.
12. The apparatus of claim 7, wherein the configuration module is further configured to:
after restarting the application service, checking the cache connection condition of the application service, wherein the cache connection condition comprises a starting log of the application service and whether the cache connection is in error or not.
13. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
the one or more processors implement the method of any of claims 1-6 when the one or more programs are executed by the one or more processors.
14. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-6.
15. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-6.
CN202311545354.XA 2023-11-20 2023-11-20 Cache cluster maintenance method, device, electronic equipment and computer readable medium Pending CN117675846A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311545354.XA CN117675846A (en) 2023-11-20 2023-11-20 Cache cluster maintenance method, device, electronic equipment and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311545354.XA CN117675846A (en) 2023-11-20 2023-11-20 Cache cluster maintenance method, device, electronic equipment and computer readable medium

Publications (1)

Publication Number Publication Date
CN117675846A true CN117675846A (en) 2024-03-08

Family

ID=90065338

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311545354.XA Pending CN117675846A (en) 2023-11-20 2023-11-20 Cache cluster maintenance method, device, electronic equipment and computer readable medium

Country Status (1)

Country Link
CN (1) CN117675846A (en)

Similar Documents

Publication Publication Date Title
CN111460129A (en) Method and device for generating identification, electronic equipment and storage medium
CN109325002B (en) Text file processing method, device and system, electronic equipment and storage medium
CN113282589A (en) Data acquisition method and device
CN116737662A (en) Method, device, electronic equipment and storage medium for processing business data
CN116302716A (en) Cluster deployment method and device, electronic equipment and computer readable medium
CN112559233B (en) Method, device, equipment and computer readable medium for identifying fault type
CN111008202A (en) Distributed transaction processing method and framework
CN114756173A (en) Method, system, device and computer readable medium for file merging
CN117675846A (en) Cache cluster maintenance method, device, electronic equipment and computer readable medium
CN115190125A (en) Monitoring method and device for cache cluster
CN113765871B (en) Method and device for managing fort machine
CN112241332B (en) Interface compensation method and device
CN112711572B (en) Online capacity expansion method and device suitable for database and table division
CN113778503B (en) Software maintenance method and device
CN109213815B (en) Method, device, server terminal and readable medium for controlling execution times
CN112883103A (en) Method and device for data transfer between clusters
CN112235332A (en) Read-write switching method and device for cluster
CN117131071B (en) Data processing method, device, electronic equipment and computer readable medium
CN112749042B (en) Application running method and device
CN110262756B (en) Method and device for caching data
CN113760886B (en) Method, apparatus, device and computer readable medium for providing data service
CN113761056A (en) Distributed service processing method, device and system
CN112181701A (en) Method and device for positioning abnormal service request
CN112181700A (en) Fault transaction isolation method and device
CN115033600A (en) Data processing method and data processing device

Legal Events

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