CN110224871A - A kind of high availability method and device of Redis cluster - Google Patents

A kind of high availability method and device of Redis cluster Download PDF

Info

Publication number
CN110224871A
CN110224871A CN201910540450.2A CN201910540450A CN110224871A CN 110224871 A CN110224871 A CN 110224871A CN 201910540450 A CN201910540450 A CN 201910540450A CN 110224871 A CN110224871 A CN 110224871A
Authority
CN
China
Prior art keywords
redis
server
redis server
address
cluster
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.)
Granted
Application number
CN201910540450.2A
Other languages
Chinese (zh)
Other versions
CN110224871B (en
Inventor
杨永帮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank 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 WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN201910540450.2A priority Critical patent/CN110224871B/en
Publication of CN110224871A publication Critical patent/CN110224871A/en
Priority to PCT/CN2020/095421 priority patent/WO2020253596A1/en
Application granted granted Critical
Publication of CN110224871B publication Critical patent/CN110224871B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0668Management of faults, events, alarms or notifications using network fault recovery by dynamic selection of recovery network elements, e.g. replacement by the most appropriate element after failure
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/30Decision processes by autonomous network management units using voting and bidding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • H04L61/103Mapping addresses of different types across network layers, e.g. resolution of network layer into physical layer addresses or address resolution protocol [ARP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/58Caching of addresses or names

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Hardware Redundancy (AREA)

Abstract

The present embodiments relate to the field techno-financial (Fintech), the present invention discloses the high availability method and device of a kind of Redis cluster, and cluster includes at least two Redis servers, and the monitor component of configuration corresponding with Redis server;This method comprises: the monitor component of the first Redis server detects the connecting link of each Redis server by initiating detecting thread;The monitor component of first Redis server then initiates to vote if it is determined that the 2nd Redis server connecting link breaks down;The slave Redis server that voting results are greater than or equal to half is determined as the slave Redis server switched over the 2nd Redis server by the monitor component of the first Redis server;The present invention is reduced costs in the case where realizing the VIP of failure of Redis server drift.

Description

A kind of high availability method and device of Redis cluster
Technical field
The present invention relates to the fields of communication technology of financial technology (Fintech) more particularly to a kind of height of Redis cluster can Use method and device.
Background technique
With the development of computer technology, more and more technical applications are in financial field, and traditional financial industry is gradually Change to financial technology (Fintech), Redis Clustering is no exception, but since the safety of financial industry, real-time are wanted It asks, the higher requirement that also technology is proposed.
Web application system, all can be in web application system and database in order to solve high concurrent bring performance issue at present Between take cache layer, the most widely used is exactly that (Redis is substantially the internal storage data of a key-value type to Redis Library).For Redis as the buffer layer between software and traditional database, operational order is simple, in the feelings that ensure that data validity Under condition, while also ensuring high-performance.
In the prior art, it is the High Availabitity for realizing Redis, reduces the server for the purpose of out of service time, pass through guarantor The service that externally uninterruptedly provides of business procedure of shield user, because of influence of the failure to business caused by software/hardware/artificial It is reduced to minimum, needs migration component to carry out failure migration, multiple monitor components is needed to carry out the monitoring of server, needs Component it is excessive, maintenance cost is higher.
Summary of the invention
The embodiment of the present invention provides the high availability method and device of a kind of Redis cluster, to solve prior art access The component of Redis database is excessive, the higher problem of maintenance cost.
The embodiment of the present invention provides a kind of high availability method of Redis cluster, and the cluster takes including at least two Redis Business device, and the monitor component of configuration corresponding with the Redis server;This method comprises:
The monitor component of first Redis server detects the connecting link of each Redis server by initiating detecting thread;
The monitor component of the first Redis server is if it is determined that the 2nd Redis server connecting link breaks down, then Initiate ballot;The 2nd Redis server is main Redis server;
The monitor component of the first Redis server is if it is determined that the slave Redis that voting results are greater than or equal to half takes Business device is the first Redis server, then is determined as the first Redis server and the 2nd Redis server The slave Redis server switched over;
The monitor component of the first Redis server sets described for the address VIP of the first Redis server The address VIP of Redis cluster, so as to access the client of the Redis cluster according to the modified address VIP access described the One Redis server.
A kind of possible implementation, the monitor component of the first Redis server is by the first Redis server The address VIP be set as the address VIP of the Redis cluster, comprising:
The monitor component of the first Redis server obtains the monitor component of the 2nd Redis server in failure The parameter spread out of when switching;
The monitor component of the first Redis server is if it is determined that the source IP address in the parameter is described second The IP address of Redis server then initiates the unbundlings operation of the address VIP;
The monitor component of the first Redis server is if it is determined that the purpose IP address in the parameter is described first The IP address of Redis server, then whether the address VIP for detecting the Redis cluster is connected state;
If the monitor component of the first Redis server, which does not receive, is communicated back to message, by the first Redis The VIP address binding of server is to the Redis cluster.
A kind of possible implementation disappears if the monitor component of the first Redis server does not receive to be communicated back to Breath, further includes:
The address VIP of the first Redis server is updated to arp cache, so that the gateway of the Redis cluster is set The standby address VIP for confirming the Redis cluster corresponds to the first Redis server.
A kind of possible implementation, the monitor component of the first Redis server is by initiating detecting thread detecting The connecting link of each Redis server, comprising:
The monitor component of the first Redis server sends heartbeat detection to each Redis server;
If heartbeat detection success, determines available connecting link from the successful Redis example of heartbeat detection.
The embodiment of the present invention provides a kind of high-availability device of Redis cluster, and the cluster takes including at least two Redis Business device, and the monitor component of configuration corresponding with the Redis server;The device includes:
Monitoring unit, for detecting the connecting link of each Redis server by initiating detecting thread;
Processing unit, for if it is determined that the 2nd Redis server connecting link breaks down, then initiating to vote;Described Two Redis servers are main Redis server;If it is determined that the slave Redis server that voting results are greater than or equal to half is institute The first Redis server is stated, then is determined as switching over the 2nd Redis server by the first Redis server Slave Redis server;Set the address VIP of the first Redis server to the address VIP of the Redis cluster, with The client for accessing the Redis cluster is set to access the first Redis server according to the modified address VIP.
A kind of possible implementation, the processing unit are specifically used for:
Obtain the parameter that the monitor component of the 2nd Redis server is spread out of in failover;If it is determined that the ginseng Source IP address in number is the IP address of the 2nd Redis server, then initiates the unbundlings operation of the address VIP;If it is determined that institute The IP address that the purpose IP address in parameter is the first Redis server is stated, then with detecting the VIP of the Redis cluster Whether location is connected state;If not receiving and being communicated back to message, by the VIP address binding of the first Redis server To the Redis cluster.
A kind of possible implementation, the processing unit are also used to: by the address VIP of the first Redis server It is updated to arp cache, so that the gateway of the Redis cluster confirms that the address VIP of the Redis cluster corresponds to described One Redis server.
A kind of possible implementation, the monitoring unit are specifically used for:
Heartbeat detection is sent to each Redis server;It is real from the successful Redis of heartbeat detection if heartbeat detection success Example determines available connecting link.
The embodiment of the present invention by the cluster include at least two Redis servers, and with the Redis server pair The monitor component that should be configured;Reduce the number of monitor component in the prior art;Pass through the monitoring group of the first Redis server Part detects the connecting link of each Redis server by initiating detecting thread;If the monitor component of the first Redis server It determines that the 2nd Redis server connecting link breaks down, then initiates to vote;The 2nd Redis server is main Redis clothes Business device;The monitor component of the first Redis server determines the slave Redis server that voting results are greater than or equal to half For the slave Redis server switched over the 2nd Redis server;The monitor component of the first Redis server The address VIP of the Redis cluster is set by the address VIP of the first Redis server, so as to access the Redis The client of cluster accesses the first Redis server according to the modified address VIP.While reducing monitor component, The VIP drift for realizing the failure of Redis server, does not need to increase additional monitor component, also, due to the address VIP Setting is completed by monitor component, is not needed other assemblies in the prior art and is completed, further reduces setting for component It sets, reduces the cost of maintenance.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodiment Attached drawing is briefly introduced, it should be apparent that, drawings in the following description are only some embodiments of the invention, for this For the those of ordinary skill in field, without creative efforts, it can also be obtained according to these attached drawings other Attached drawing.
Fig. 1 a provides a kind of Redis aggregated structure for the embodiment of the present invention;
Fig. 1 b provides a kind of Redis aggregated structure for the embodiment of the present invention;
Fig. 2 provides a kind of configuration diagram of Redis cluster for the embodiment of the present invention;
Fig. 3 provides a kind of high availability method flow diagram of Redis cluster for the embodiment of the present invention;
Fig. 4 provides a kind of structural schematic diagram of the high-availability device of Redis cluster for the embodiment of the present invention;
Fig. 5 is that the embodiment of the present invention also provides a kind of structural schematic diagram of Redis monitor component.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with attached drawing to the present invention make into It is described in detail to one step, it is clear that the described embodiments are only some of the embodiments of the present invention, rather than whole implementation Example.Based on the embodiments of the present invention, obtained by those of ordinary skill in the art without making creative efforts All other embodiment, shall fall within the protection scope of the present invention.
High-availability cluster: refer to the server cluster technology for the purpose of reducing out of service time.It is used by protection The service that the business procedure at family externally uninterruptedly provides, because caused by software/hardware/artificial influence of the failure to business reduce To minimum.
Redis server: one using the ANSI C open source write, support network, based on memory, it is optional persistent Key-value pair storing data library is generally also used as cache database.
Monitor component sentinel: the available mode of redis server is monitored.Decide Redis server-when with Redis When from the high availability scheme of Redis server, if main Redis server delay machine, Redis itself is (including its many visitors Family end) it is all not carried out and automatic carry out active-standby switch and can monitor whether redis presses by monitor component sentinel component It is run well according to expection;If it find that the operation of some redis node is broken down, can notify another process (such as Its client), automatically switched.
Redis- monitor component sentinel itself is also an independently operated process, it can monitor multiple main Redis Server-can be carried out automatic switchover after finding main Redis server delay machine from Redis server cluster.Only use single monitoring Component sentinel process come monitor redis cluster be it is insecure, when monitor component sentinel process run malfunction, or Network blockage, then will be unable to realize redis cluster active-standby switch (monitor component sentinel itself also has single-point to ask Topic, single-point-of-failure) entire group system will be unable to run in the intended manner.It is therefore necessary to will Monitor component sentinel cluster needs to be provided with multiple monitor component sentinel.
When a main Redis server node is unavailable, monitor component can elect main Redis server at least One from one in Redis server as new main Redis server.Others can be incited somebody to action from Redis server node The address for the main Redis server that it is followed be changed to be elevated the slave Redis server for main Redis server newly Location.If most of monitor component sentinel can be communicated with each other, there will eventually be one to be authorized to carry out failure migration, It ensure that the activity of Redis.
The component of health status inspection and for keeping between standby machine under Keepalived: one load balancing cluster Fail-over components.
HAProxy: being one makes the freedom shown a C language and open-source software, provides high availability, load Equilibrium, and the Application Agent based on TCP and HTTP.
Vip: for the address ip of outside access in cluster, there is usually one.
In practical applications, the deployment way of Redis in the embodiment of the present invention, provides deployment way there are many structure Example, as shown in Figure 1a, a kind of deployment way are deployment VIP nodes, manage multiple nodes, each node administration by VIP node One example set is realized that the function of data fragmentation, i.e., the read-write requests that application program is sent pass through VIP node point by VIP node It is assigned to the corresponding example set processing of respective nodes.
It, can will be from Redis by Keepalived for the master-slave swap of Redis server if breaking down migration Server switching is main Redis server.Keepalived can be set in each Redis server, if monitor component Sentinel determines current main Redis server operation troubles, and determination needs to carry out failure migration, can pass through Process on the main Redis server of failure is migrated the new master determined to monitor component sentinel by Keepalived Redis server.
For the switching of VIP node, HAProxy component can be set in each Redis server, be passed through HAProxy component can realize detection immediately to the master-slave swap of Redis server, however, it is determined that the principal and subordinate of Redis server cuts Completion is changed, then enables the address VIP of new main Redis server, is set to the address VIP of current Redis cluster, is had The setting of body can realize the switching of the address VIP by VRRP.
For the switching of the address VIP, Virtual Router Redundacy Protocol (Virtual Router Redundancy can be passed through Protocol, abbreviation VRRP) it realizes.VRRP can take the physical router equipment of the first Redis server and the 2nd Redis The physical router equipment of business device invents a virtual flow-line, this virtual router is externally provided by virtual IP address (VIP) Service, and may include that multiple physical routers cooperate inside virtual router, the same time only has a physics road Service, i.e. active router are externally provided by device, for example, if current main Redis server is the first Redis server, this When, only server is externally provided by the physical router of the first Redis server.Wherein, active router is produced by election algorithm Raw, it possesses the virtual IP address externally serviced, provides various network functions, such as: ARP request, ICMP (Internet Control Message Protocol, internet control message protocol) data forwarding etc., and other physical routers do not possess externally Virtual IP address, external network function is not provided yet, only receives the VRRP state advertisement information of active router, these routers are Backup router.When active router failure, election will be re-started in backup router, generates a new active router Into active router, continue to provide external service, entire switching is fully transparent for client.
In the case where a main Redis server and one or more are from Redis server, each main Redis service Device and a monitor component sentinel component is respectively configured from Redis server;In addition, due to needing to elect main Redis Multiple one from Redis server of server as new main Redis server, if main Redis server with from The sum of Redis server is even number, to guarantee going on smoothly for election, needs additionally to be arranged the monitoring of 1 redis server Monitor component component sentinel, the problem are not obvious in large construction cluster, but in small-sized cluster, the group being additionally arranged Part increases the cost of maintenance.
As shown in Figure 1 b, the embodiment of the present invention provides another deployment way, has several example sets in Redis cluster, answers Direct-connected with program and multiple example sets, i.e., application program is connected with the server that multiple groups principal and subordinate cooperates, and transports in each primary server The example of several responsible data backups of row.
Under the program, for be not based on VIP cluster deployment scheme, need when switching, main Redis server Switching need by monitor component sentinel notify client, client need reconnect to switching after main Redis clothes It is engaged on device.In the specific implementation process, client needs to monitor the event queue of monitor component sentinel, after obtaining switching The port ip of main Redis server, and initiate to access to the port ip of the main Redis server after switching, compared to VIP section The deployment scenario of point is unfavorable for the timeliness of switching.
Based on identical reason, due to needing to elect multiple one from Redis server of main Redis server As new main Redis server, if main Redis server with from the sum of Redis server be even number, to guarantee election Go on smoothly, under the premise of a main Redis server and one are from Redis server, need additionally be arranged 1 monitoring Component sentinel, in small-sized cluster, the problem of component that is additionally arranged increases the cost of maintenance.
Based on the above issues, shown in Figure 2, the cluster include at least two Redis servers, and with it is described The monitor component of the corresponding configuration of Redis server;As shown in figure 3, the embodiment of the present invention provides a kind of High Availabitity of Redis cluster Method flow schematic diagram, specifically implementation method include:
Step 301: the monitor component sentinel of the first Redis server detects each Redis by initiating detecting thread The connecting link of server;
A kind of possible implementation, the monitor component of the first Redis server is by initiating detecting thread detecting The connecting link of each Redis server, comprising:
The monitor component of the first Redis server sends heartbeat detection to each Redis server;
If heartbeat detection success, determines available connecting link from the successful Redis example of heartbeat detection.
Specifically, can star individual thread regularly sends detection messages to each Redis example, according to its response To judge its health status.In addition, also feedback interface has been opened to external callers, when caller read-write Redis encounters exception When, feedback interface can be called, so that the health status in time to Redis example is updated.
Step 302: the monitor component of the first Redis server is if it is determined that event occurs for the 2nd Redis server connecting link Barrier, then initiate to vote;The 2nd Redis server is main Redis server;
Specifically, monitor component sentinel is listening to main Redis server after specific time does not connect, confirmation 2nd Redis server failure needs to trigger failure transfer.
Step 303: the monitor component of the first Redis server if it is determined that voting results be greater than or equal to half from Redis server is the first Redis server, then is determined as the first Redis server and the 2nd Redis The slave Redis server that server switches over;
In the specific implementation process, all monitor component sentinel for monitoring main Redis server are involved in ballot, select It enumerates one and switches to main Redis server from Redis server.Under only one framework scene from Redis server, It does not need more monitor component sentinel and participates in ballot, it is only necessary to the ballot of half, it so both can be in master Ensure that in the case of Redis server delay machine can switch successfully, and also save the resource of monitor component sentinel.It is right It answers, the ballot mode in the embodiment of the present invention is more than or equal to half, and specific code can be such that
Monitor component sentinel.c:voters_quorum=voters/2;
The triggering of failure transfer can be completed to realize the monitor component sentinel of only half in cluster.
Step 304: the monitor component of the first Redis server sets the address VIP of the first Redis server to The address VIP of the Redis cluster, so that the client for accessing the Redis cluster accesses institute according to the modified address VIP State the first Redis server.
The embodiment of the present invention by the cluster include at least two Redis servers, and with the Redis server pair The monitor component that should be configured;Reduce the number of monitor component in the prior art;Pass through the monitoring group of the first Redis server Part detects the connecting link of each Redis server by initiating detecting thread;If the monitor component of the first Redis server It determines that the 2nd Redis server connecting link breaks down, then initiates to vote;The 2nd Redis server is main Redis clothes Business device;The monitor component of the first Redis server determines the slave Redis server that voting results are greater than or equal to half For the slave Redis server switched over the 2nd Redis server;The monitor component of the first Redis server The address VIP of the Redis cluster is set by the address VIP of the first Redis server, so as to access the Redis The client of cluster accesses the first Redis server according to the modified address VIP.Redis is realized by voting mechanism The switching of Redis server in cluster realizes the VIP drift of the failure of Redis server while reducing monitor component It moves, does not need to increase additional monitor component, also, since the setting of the address VIP is completed by monitor component, do not need Other assemblies in the prior art are completed, and are further reduced the setting of component, are reduced the cost of maintenance.So that the gold such as bank When melting the Redis cluster progress Redis server switching of mechanism, the cost spent is lower, and maintenance cost also reduces, and has more Add apparent economic benefit.
In step 304, a kind of possible implementation, comprising:
Step 1: the monitor component of the first Redis server obtains the monitor component of the 2nd Redis server in event The parameter spread out of when barrier switching;
Step 2: the monitor component of the first Redis server is if it is determined that the source IP address in the parameter is described second The IP address of Redis server then initiates the unbundlings operation of the address VIP;
Step 3: the monitor component of the first Redis server is if it is determined that purpose IP address in the parameter is described the The IP address of one Redis server, then whether the address VIP for detecting the Redis cluster is connected state;
Step 4: if the monitor component of the first Redis server does not receive and is communicated back to message, by described first The VIP address binding of Redis server is to the Redis cluster.
In the specific implementation process, a script can be triggered in the main Redis server failure transfer of Redis cluster, The script can be shell language and write.
Specifically, the script is for judging that monitor component is cut from the monitor component of the 2nd Redis server in failure The parameter spread out of when changing.For example, the IP address in parameter from-ip is the machine ip, then it still can be second with the address that VIP is bound Therefore Redis server can execute unbundlings VIP operation by the ip order of operating system.For example, "/bin/ip addr del{VIP}/24dev eth0".For example, the IP address in parameter to-ip is the machine ip, then it can determine that the address of VIP is to cut Main Redis server after changing, therefore, it is necessary to send ping message to VIP;Disappear if it is determined that can receive corresponding PONG Breath, then can determine that link is normal, then waits correlation time, to start the VIP after switching.If transmission can not be received The corresponding PONG message of ping then illustrates current VIP unbundlings, and the first Redis server after unbound switching, needs The VIP is bound on first Redis server.For example, can be realized by following code: "/bin/ip addr add { VIP }/ 24dev eth0”。
In the scene with ARP (Address Resolution Protocol, address resolution protocol, i.e. ARP), one The possible implementation of kind, if the monitor component of the first Redis server, which does not receive, is communicated back to message, further includes:
The address VIP of the first Redis server is updated to arp cache, so that the gateway of the Redis cluster is set The standby address VIP for confirming the Redis cluster corresponds to the first Redis server.
Specifically, the arp caching of the VIP in local area network can be updated.For example, can be realized by following code :/ usr/sbin/arping-I eth0-A{VIP}-c 3。
Therefore, it can make new VIP that can be tied on the first Redis server, and have updated arp caching, so that Gateway confirms that the corresponding address mac the ip is on the first Redis server, and in failure, client can pass through in this way VIP accesses the first Redis server, to realize the high-availability cluster that can be drifted about by VIP.
The embodiment of the present invention provides a kind of high availability method of more efficient Redis cluster, relatively for other clusters, The component for reducing maintenance eliminates the cost of study other assemblies;Also, the use of monitor component is effectively reduced, is saved The host resource that need to consume.Redis active-standby switch process is simple with respect to other, and client does not need replacement access Ip is to achieve the purpose that the main Redis server after access switching.
Based on identical inventive concept, as shown in figure 4, the embodiment of the present invention provides a kind of High Availabitity dress of Redis cluster It sets, the cluster includes at least two Redis servers, and the monitor component of configuration corresponding with the Redis server;The dress It sets and includes:
Monitoring unit 401, for detecting the connecting link of each Redis server by initiating detecting thread;
Processing unit 402, for if it is determined that the 2nd Redis server connecting link breaks down, then initiating to vote;It is described 2nd Redis server is main Redis server;The slave Redis server that voting results are greater than or equal to half is determined as The slave Redis server switched over the 2nd Redis server;The address VIP of the first Redis server is set It is set to the address VIP of the Redis cluster, so that the client for accessing the Redis cluster is visited according to the modified address VIP Ask the first Redis server.
A kind of possible implementation, the processing unit 402, is specifically used for:
Obtain the parameter that the monitor component of the 2nd Redis server is spread out of in failover;If it is determined that the ginseng Source IP address in number is the IP address of the 2nd Redis server, then initiates the unbundlings operation of the address VIP;If it is determined that institute The IP address that the purpose IP address in parameter is the first Redis server is stated, then with detecting the VIP of the Redis cluster Whether location is connected state;If not receiving and being communicated back to message, by the VIP address binding of the first Redis server To the Redis cluster.
A kind of possible implementation, the processing unit 402, is also used to: by the VIP of the first Redis server Address is updated to arp cache, so that the gateway of the Redis cluster confirms that the address VIP of the Redis cluster corresponds to institute State the first Redis server.
A kind of possible implementation, the monitoring unit 401, is specifically used for:
Heartbeat detection is sent to each Redis server;It is real from the successful Redis of heartbeat detection if heartbeat detection success Example determines available connecting link.
After obtaining the read-write requests that application program is sent in view of the Redis cluster in the embodiment of the present invention, may include:
According to the data Major key in read-write requests, corresponding Redis server is determined;
The cryptographic Hash that Hash operation generation is carried out according to the data Major key, determines the corresponding Redis server Port;The corresponding Redis example of the read-write requests is determined according to determining port.
For example, Redis cluster receives the read-write requests that application program is sent for Redis cluster, it is first determined this Which corresponding VIP node of read-write requests, after determining VIP node, Redis cluster is selected from corresponding connection pool One connecting link sends read-write requests to VIP node, and VIP node is determined further according to the data Major key in read-write requests Which corresponding Redis server of this read-write requests carries out the cryptographic Hash of Hash operation generation further according to data Major key, really The port of the fixed corresponding Redis server, and determine that the corresponding Redis of the read-write requests is real according to determining port Example.After determining Redis example, Redis cluster obtains a long connection from the corresponding connection pool of Redis example, Thus this read-write requests can be sent by long connect.
Therefore, the Redis cluster in the embodiment of the present invention does not need the access of cross-node, avoids in the prior art, More than Redis3.0 version big cluster needs the main redis server of at least three, and key can be divided into the form of slot, often A main redis deposits different slots respectively, causes when client accesses some redis server, if slot is not where the key It is accessed on redis where then needing to be redirected to the key in the redis of the access, access of the efficiency than single redis server Low efficiency, and do not support those to need while handling the Redis order of multiple keys, for example, the orders such as mset/mget are not supported The access of cross-node.
Based on identical inventive concept, based on the above embodiment, as shown in fig.5, in the embodiment of the present invention, a kind of calculating The structural schematic diagram of machine equipment.
The embodiment of the invention provides a kind of computer equipment, which may include: processor 1001, such as CPU, network interface 1004, user interface 1003, memory 1005, communication bus 1002.Wherein, communication bus 1002 is for real Connection communication between these existing components.User interface 1003 may include display screen (Display), input unit such as keyboard (Keyboard), optional user interface 1003 can also include standard wireline interface and wireless interface.Network interface 1004 is optional May include standard wireline interface and wireless interface (such as WI-FI interface).Memory 1005 can be high speed RAM memory, It is also possible to stable memory (non-volatile memory), such as magnetic disk storage.Memory 1005 optionally may be used also To be independently of the storage device of aforementioned processor 1001.
It, can be with it will be understood by those skilled in the art that structure shown in Fig. 5 does not constitute the restriction to computer equipment Including perhaps combining certain components or different component layouts than illustrating more or fewer components.
As may include operating system, network communication module, use in a kind of memory 1005 of computer storage medium The generation program of family interface module and information recommendation model.Wherein, operating system is to manage and control model parameter to obtain system The program for hardware and software resource of uniting supports the generation program of information recommendation model and the operation of other softwares or program.
User interface 1003 is mainly used for connection, second server and third server etc., is counted with each server According to communication;Network interface 1004 is mainly used for connecting background server, carries out data communication with background server;And processor 1001 can be used for calling the generation program of the information recommendation model stored in memory 1005, and execute following operation:
If it is determined that the 2nd Redis server connecting link breaks down, then initiate to vote;The 2nd Redis server For main Redis server;The slave Redis server that voting results are greater than or equal to half is determined as and the 2nd Redis The slave Redis server that server switches over;The Redis collection is set by the address VIP of the first Redis server The address VIP of group, so that the client for accessing the Redis cluster accesses the first Redis according to the modified address VIP Server.
A kind of possible implementation, the processor 1001, is specifically used for:
Obtain the parameter that the monitor component of the 2nd Redis server is spread out of in failover;If it is determined that the ginseng Source IP address in number is the IP address of the 2nd Redis server, then initiates the unbundlings operation of the address VIP;If it is determined that institute The IP address that the purpose IP address in parameter is the first Redis server is stated, then with detecting the VIP of the Redis cluster Whether location is connected state;If not receiving and being communicated back to message, by the VIP address binding of the first Redis server To the Redis cluster.
A kind of possible implementation, the processor 1001, is also used to: by the VIP of the first Redis server Location is updated to arp cache, so that the gateway of the Redis cluster confirms described in the address the VIP correspondence of the Redis cluster First Redis server.
A kind of possible implementation, the processor 1001, is specifically used for:
Heartbeat detection is sent to each Redis server;It is real from the successful Redis of heartbeat detection if heartbeat detection success Example determines available connecting link.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates, Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one The step of function of being specified in a box or multiple boxes.
Although preferred embodiments of the present invention have been described, it is created once a person skilled in the art knows basic Property concept, then additional changes and modifications may be made to these embodiments.So it includes excellent that the following claims are intended to be interpreted as It selects embodiment and falls into all change and modification of the scope of the invention.
Obviously, various changes and modifications can be made to the invention without departing from essence of the invention by those skilled in the art Mind and range.In this way, if these modifications and changes of the present invention belongs to the range of the claims in the present invention and its equivalent technologies Within, then the present invention is also intended to include these modifications and variations.

Claims (10)

1. a kind of high availability method of Redis cluster, which is characterized in that the cluster includes at least two Redis servers, and The monitor component of configuration corresponding with the Redis server;This method comprises:
The monitor component of first Redis server detects the connecting link of each Redis server by initiating detecting thread;
The monitor component of the first Redis server is then initiated if it is determined that the 2nd Redis server connecting link breaks down Ballot;The 2nd Redis server is main Redis server;
The monitor component of the first Redis server is if it is determined that voting results are greater than or equal to the slave Redis server of half For the first Redis server, then the first Redis server is determined as carrying out with the 2nd Redis server The slave Redis server of switching;
The monitor component of the first Redis server sets described for the address VIP of the first Redis server The address VIP of Redis cluster, so as to access the client of the Redis cluster according to the modified address VIP access described the One Redis server.
2. the method as described in claim 1, which is characterized in that the monitor component of the first Redis server is by described The address VIP of one Redis server is set as the address VIP of the Redis cluster, comprising:
The monitor component of the first Redis server obtains the monitor component of the 2nd Redis server in failover When the parameter that spreads out of;
The monitor component of the first Redis server is if it is determined that the source IP address in the parameter is the 2nd Redis clothes The IP address of business device then initiates the unbundlings operation of the address VIP;
The monitor component of the first Redis server is if it is determined that the purpose IP address in the parameter is the first Redis The IP address of server, then whether the address VIP for detecting the Redis cluster is connected state;
If the monitor component of the first Redis server, which does not receive, is communicated back to message, the first Redis is serviced The VIP address binding of device is to the Redis cluster.
3. method according to claim 2, which is characterized in that if the monitor component of the first Redis server does not receive To being communicated back to message, further includes:
The address VIP of the first Redis server is updated to arp cache, so that the gateway of the Redis cluster is true The address VIP for recognizing the Redis cluster corresponds to the first Redis server.
4. the method according to claim 1, which is characterized in that the monitor component of the first Redis server The connecting link of each Redis server is detected by initiating detecting thread, comprising:
The monitor component of the first Redis server sends heartbeat detection to each Redis server;
If heartbeat detection success, determines available connecting link from the successful Redis example of heartbeat detection.
5. a kind of high-availability device of Redis cluster, which is characterized in that the cluster includes at least two Redis servers, and The monitor component of configuration corresponding with the Redis server;The device includes:
Monitoring unit, for detecting the connecting link of each Redis server by initiating detecting thread;
Processing unit, for if it is determined that the 2nd Redis server connecting link breaks down, then initiating to vote;Described second Redis server is main Redis server;If it is determined that the slave Redis server that voting results are greater than or equal to half is described The first Redis server then is determined as switching over the 2nd Redis server by the first Redis server From Redis server;Set the address VIP of the first Redis server to the address VIP of the Redis cluster, so that The client for accessing the Redis cluster accesses the first Redis server according to the modified address VIP.
6. device as claimed in claim 5, which is characterized in that the processing unit is specifically used for:
Obtain the parameter that the monitor component of the 2nd Redis server is spread out of in failover;If it is determined that in the parameter Source IP address be the 2nd Redis server IP address, then initiate the address VIP unbundlings operation;If it is determined that the ginseng Purpose IP address in number is the IP address of the first Redis server, then the address VIP for detecting the Redis cluster is No is connected state;If not receiving and being communicated back to message, by the VIP address binding of the first Redis server to institute State Redis cluster.
7. device as claimed in claim 6, which is characterized in that the processing unit is also used to: the first Redis is taken The address VIP of business device is updated to arp cache, so that the gateway of the Redis cluster confirms the VIP of the Redis cluster Address corresponds to the first Redis server.
8. such as the described in any item devices of claim 5-7, which is characterized in that the monitoring unit is specifically used for:
Heartbeat detection is sent to each Redis server;If heartbeat detection success, true from the successful Redis example of heartbeat detection Fixed available connecting link.
9. a kind of computer equipment characterized by comprising
At least one processor;And
The memory being connect at least one described processor communication;Wherein,
The memory is stored with the instruction that can be executed by least one described processor, and described instruction is by described at least one It manages device to execute, so that at least one described processor is able to carry out any method of claim 1-4.
10. a kind of non-transient computer readable storage medium, which is characterized in that the non-transient computer readable storage medium is deposited Computer instruction is stored up, the computer instruction is for making the computer perform claim require 1~4 any the method.
CN201910540450.2A 2019-06-21 2019-06-21 High-availability method and device for Redis cluster Active CN110224871B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910540450.2A CN110224871B (en) 2019-06-21 2019-06-21 High-availability method and device for Redis cluster
PCT/CN2020/095421 WO2020253596A1 (en) 2019-06-21 2020-06-10 High availability method and apparatus for redis cluster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910540450.2A CN110224871B (en) 2019-06-21 2019-06-21 High-availability method and device for Redis cluster

Publications (2)

Publication Number Publication Date
CN110224871A true CN110224871A (en) 2019-09-10
CN110224871B CN110224871B (en) 2022-11-08

Family

ID=67814194

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910540450.2A Active CN110224871B (en) 2019-06-21 2019-06-21 High-availability method and device for Redis cluster

Country Status (2)

Country Link
CN (1) CN110224871B (en)
WO (1) WO2020253596A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110674192A (en) * 2019-10-09 2020-01-10 浪潮云信息技术有限公司 Redis high-availability VIP (very important person) drifting method, terminal and storage medium
CN111444062A (en) * 2020-04-01 2020-07-24 山东汇贸电子口岸有限公司 Method and device for managing master node and slave node of cloud database
CN112306720A (en) * 2020-11-23 2021-02-02 迈普通信技术股份有限公司 Service system cluster management method
CN113079192A (en) * 2021-02-08 2021-07-06 马上消费金融股份有限公司 Information processing method, device, equipment and readable storage medium
CN113535126A (en) * 2020-04-14 2021-10-22 天津科技大学 House renting platform based on SSM
CN114363156A (en) * 2022-01-25 2022-04-15 南瑞集团有限公司 Hydropower station computer monitoring system deployment method based on cluster technology
CN114785713A (en) * 2022-03-31 2022-07-22 度小满科技(北京)有限公司 Method and proxy middleware for realizing high availability of Redis cluster

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11917001B2 (en) * 2020-02-04 2024-02-27 Nutanix, Inc. Efficient virtual IP address management for service clusters
CN112860485A (en) * 2021-02-03 2021-05-28 北京北信源信息安全技术有限公司 Control method of dual-computer hot standby system based on keepalived
CN113806181A (en) * 2021-09-24 2021-12-17 重庆富民银行股份有限公司 Redis multi-cluster automatic monitoring method and system
CN114598711B (en) * 2022-03-29 2024-04-16 百果园技术(新加坡)有限公司 Data migration method, device, equipment and medium
CN115037785B (en) * 2022-08-12 2022-11-01 深圳市星卡软件技术开发有限公司 Instant communication system and method
CN115484267A (en) * 2022-09-15 2022-12-16 中国联合网络通信集团有限公司 Multi-cluster deployment processing method and device, electronic equipment and storage medium
CN116546092B (en) * 2023-07-04 2023-10-13 深圳市亲邻科技有限公司 Redis-based object model storage system
CN117251341A (en) * 2023-09-27 2023-12-19 中国科学院空天信息创新研究院 Real-time monitoring method and device for cache service cluster, electronic equipment and medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105933407A (en) * 2016-04-20 2016-09-07 中国银联股份有限公司 Method and system for achieving high availability of Redis cluster
CN106210151A (en) * 2016-09-27 2016-12-07 深圳市彬讯科技有限公司 A kind of zedis distributed caching and server cluster monitoring method
US20180121304A1 (en) * 2016-10-27 2018-05-03 Machine Zone, Inc. System and method for managing a cluster of cache servers (trask)

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106534328B (en) * 2016-11-28 2020-01-31 网宿科技股份有限公司 Node connection method and distributed computing system
CN108206843B (en) * 2016-12-16 2021-06-04 北京金山云网络技术有限公司 Cluster access method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105933407A (en) * 2016-04-20 2016-09-07 中国银联股份有限公司 Method and system for achieving high availability of Redis cluster
CN106210151A (en) * 2016-09-27 2016-12-07 深圳市彬讯科技有限公司 A kind of zedis distributed caching and server cluster monitoring method
US20180121304A1 (en) * 2016-10-27 2018-05-03 Machine Zone, Inc. System and method for managing a cluster of cache servers (trask)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110674192A (en) * 2019-10-09 2020-01-10 浪潮云信息技术有限公司 Redis high-availability VIP (very important person) drifting method, terminal and storage medium
CN111444062A (en) * 2020-04-01 2020-07-24 山东汇贸电子口岸有限公司 Method and device for managing master node and slave node of cloud database
CN111444062B (en) * 2020-04-01 2023-09-19 山东汇贸电子口岸有限公司 Method and device for managing master node and slave node of cloud database
CN113535126A (en) * 2020-04-14 2021-10-22 天津科技大学 House renting platform based on SSM
CN112306720A (en) * 2020-11-23 2021-02-02 迈普通信技术股份有限公司 Service system cluster management method
CN112306720B (en) * 2020-11-23 2022-06-21 迈普通信技术股份有限公司 Service system cluster management method
CN113079192A (en) * 2021-02-08 2021-07-06 马上消费金融股份有限公司 Information processing method, device, equipment and readable storage medium
CN113079192B (en) * 2021-02-08 2021-12-31 马上消费金融股份有限公司 Information processing method, device, equipment and readable storage medium
CN114363156A (en) * 2022-01-25 2022-04-15 南瑞集团有限公司 Hydropower station computer monitoring system deployment method based on cluster technology
CN114785713A (en) * 2022-03-31 2022-07-22 度小满科技(北京)有限公司 Method and proxy middleware for realizing high availability of Redis cluster
CN114785713B (en) * 2022-03-31 2024-02-23 度小满科技(北京)有限公司 Method and proxy middleware for realizing high availability of Redis cluster

Also Published As

Publication number Publication date
CN110224871B (en) 2022-11-08
WO2020253596A1 (en) 2020-12-24

Similar Documents

Publication Publication Date Title
CN110224871A (en) A kind of high availability method and device of Redis cluster
US11445019B2 (en) Methods, systems, and media for providing distributed database access during a network split
US10713135B2 (en) Data disaster recovery method, device and system
US11765110B2 (en) Method and system for providing resiliency in interaction servicing across data centers
US8676760B2 (en) Maintaining data integrity in data servers across data centers
US7225356B2 (en) System for managing operational failure occurrences in processing devices
KR100711396B1 (en) Server duplexing method and duplexed server system
CN114787781A (en) System and method for enabling high availability managed failover services
CN111130835A (en) Data center dual-active system, switching method, device, equipment and medium
US10826812B2 (en) Multiple quorum witness
WO2012145963A1 (en) Data management system and method
CN110727709A (en) Cluster database system
CN108369544A (en) The server delayed in computing system restores
CN105874433B (en) System and method for supporting asynchronous calls in a distributed data grid
CN113489691B (en) Network access method, network access device, computer readable medium and electronic equipment
CN105069152B (en) data processing method and device
CN104753987B (en) A kind of distributed conversation management method and system
CN107357800A (en) A kind of database High Availabitity zero loses solution method
CN113849136B (en) Automatic FC block storage processing method and system based on domestic platform
CN113326100B (en) Cluster management method, device, equipment and computer storage medium
US20190124145A1 (en) Method and apparatus for availability management
JP4856949B2 (en) Failover method, failover program, and cluster system
CN110266795A (en) One kind being based on Openstack platform courses method
US11947431B1 (en) Replication data facility failure detection and failover automation
CN117271205A (en) Data processing system, data processing method, data processing device and related equipment

Legal Events

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