CN106559267A - The master-slave switching method of Redis, device and redis systems - Google Patents

The master-slave switching method of Redis, device and redis systems Download PDF

Info

Publication number
CN106559267A
CN106559267A CN201611054605.4A CN201611054605A CN106559267A CN 106559267 A CN106559267 A CN 106559267A CN 201611054605 A CN201611054605 A CN 201611054605A CN 106559267 A CN106559267 A CN 106559267A
Authority
CN
China
Prior art keywords
redis
switching device
systems
priority
address
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
CN201611054605.4A
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.)
Poly Polytron Technologies Inc
Juhaokan Technology Co Ltd
Original Assignee
Poly Polytron Technologies Inc
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 Poly Polytron Technologies Inc filed Critical Poly Polytron Technologies Inc
Priority to CN201611054605.4A priority Critical patent/CN106559267A/en
Publication of CN106559267A publication Critical patent/CN106559267A/en
Pending legal-status Critical Current

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)

Abstract

The embodiment of the present invention provides a kind of master-slave switching method of redis, device and redis systems, and its method includes:Obtain the mark of the main redis in redis systems;According to the mark of main redis, the priority of the corresponding redis of switching device is updated;If the priority of the corresponding redis of switching device arranges the mapping relations of the IP address of the virtual ip address redis corresponding with switching device of redis systems more than the priority of other redis in redis systems;If the priority of the corresponding redis of switching device is less than or equal to the priority of other redis in redis systems, when it is determined that the IP address of the virtual ip address of redis systems redis corresponding with switching device has mapping relations, cancel mapping relations.For improving the efficiency that master-slave swap is carried out to redis.

Description

The master-slave switching method of Redis, device and redis systems
Technical field
The present embodiments relate to communication technical field, more particularly to a kind of master-slave switching method of redis, device and Redis systems.
Background technology
Redis is based on key-value storage systems, as redis has higher readwrite performance, the application of redis It is more and more extensive.
At present, during the use to redis, in order to improve the reliability of redis, by different servers Principal and subordinate redis is set, and principal and subordinate redis is managed by monitoring module.When main redis breaks down, monitoring module will From redis switching based on redis, and to need access redis each business network element send a notification message so that each business Network element modification storage, redis IP address, so that business network element can be according to the Internet protocol of amended redis (Internet Protocol, abbreviation IP) address accesses the main redis after switching.
However, in the prior art, when master-slave swap is carried out to redis, monitoring module is needed to each service network Unit sends a notification message, due to the number of business network element it is more, and need each business network element respectively to store redis IP Address is modified, and causes to carry out the less efficient of master-slave swap to redis.
The content of the invention
The embodiment of the present invention provides a kind of master-slave switching method of redis, device and redis systems, improves to redis Carry out the efficiency of master-slave swap.
In a first aspect, the embodiment of the present invention provides a kind of master-slave switching method of redis, it is applied in redis systems The corresponding switching devices of any one redis, including:
Obtain the mark of the main redis in the redis systems, the redis systems include a main redis and extremely Lack one from redis;
According to the mark of the main redis, the priority of the corresponding redis of the switching device is updated;
If the priority of the corresponding redis of the switching device more than in the redis systems other redis it is preferential Level, the then mapping for arranging the IP address of the virtual ip address redis corresponding with the switching device of the redis systems are closed System, so that business network element accesses the corresponding redis of the switching device by the virtual ip address of the redis systems;
If the priority of the corresponding redis of the switching device is less than or equal to other redis in the redis systems Priority, then it is determined that the IP address of the virtual ip address of redis systems redis corresponding with the switching device is present During mapping relations, cancel the mapping relations.
In a kind of possible embodiment, according to the mark of the main redis, the switching device is updated corresponding The priority of redis, including:
Judge the main redis mark redis corresponding with the switching device identify whether it is consistent;
If so, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device Initial priority and priority delta sum, the initial priority and priority delta of the corresponding redis of the switching device Priority of the sum more than other redis in the redis systems;
If it is not, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device Initial priority.
In alternatively possible embodiment, the virtual ip address that the redis systems are set and the switching The mapping relations of the IP address of the corresponding redis of device, including:
Set up the virtual ip address of the corresponding redis of the switching device;
The virtual ip address of the switching device corresponding redis is defined as into the virtual ip address of the redis systems.
In alternatively possible embodiment, methods described also includes:
After the switching device receives time-out notice, according to the mark of the main redis, the switching dress is judged Put corresponding redis whether based on redis;
If so, then suspend the corresponding redis of the switching device, so that the redis systems switch main redis.
In alternatively possible embodiment, methods described also includes:
Obtain the state of the corresponding redis of the switching device;
When it is determined that the state of the corresponding redis of the switching device is halted state, default script is called, with by institute State the state of the corresponding redis of switching device described in default script startup.
Second aspect, the embodiment of the present invention provide a kind of master-slave swap device of redis, including the first acquisition module, more New module and setup module, wherein,
First acquisition module is used for, and obtains the mark of the main redis in the redis systems, the redis systems Include a main redis and at least one from redis;
The update module is used for, and according to the mark of the main redis, updates the corresponding redis's of the switching device Priority;
The setup module is used for, in the priority of the corresponding redis of the switching device is more than the redis systems During the priority of other redis, arrange the virtual ip address redis's corresponding with the switching device of the redis systems The mapping relations of IP address, so that business network element accesses the switching device pair by the virtual ip address of the redis systems The redis for answering;
The setup module is additionally operable to, and is less than or equal in the priority of the corresponding redis of the switching device described The priority of other redis in redis systems, and determine the virtual ip address and the switching device pair of the redis systems When the IP address of the redis for answering has mapping relations, cancel the mapping relations.
In a kind of possible embodiment, the update module specifically for:
Judge the main redis mark redis corresponding with the switching device identify whether it is consistent;
If so, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device Initial priority and priority delta sum, the initial priority and priority delta of the corresponding redis of the switching device Priority of the sum more than other redis in the redis systems;
If it is not, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device Initial priority.
In alternatively possible embodiment, the setup module specifically for:
Set up the virtual ip address of the corresponding redis of the switching device;
The virtual ip address of the switching device corresponding redis is defined as into the virtual ip address of the redis systems.
In alternatively possible embodiment, described device also includes judge module and suspends module, wherein,
The judge module is used for, and after receiving time-out and notifying, according to the mark of the main redis, judges described The corresponding redis of switching device whether based on redis;
The time-out module is used for, and judges redis based on the corresponding redis of the switching device in the judge module When, suspend the corresponding redis of the switching device, so that the redis systems switch main redis.
In alternatively possible embodiment, described device also includes the second acquisition module and starting module, wherein,
Second acquisition module is used for, and obtains the state of the corresponding redis of the switching device;
The starting module is used for, and when it is determined that the state of the corresponding redis of the switching device is halted state, calls Default script, with the state by the corresponding redis of switching device described in the default script startup.
The third aspect, the embodiment of the present invention provide a kind of redis systems, including monitoring module, multiple redis and each institute State the master-slave swap device of the corresponding redis as described in any one of second aspect of redis.
The master-slave switching method of redis provided in an embodiment of the present invention, device and redis systems, by every in redis systems The corresponding switching device of one redis safeguarded to the IP address of redis, the master in a redis is redis systems During redis, the corresponding switching devices of the redis arrange the corresponding relation of the redis and the virtual ip address of redis systems, with Allow business network element according to the virtual ip address of redis systems, the main redis of the redis systems is conducted interviews.Above-mentioned During, after master-slave swap is carried out to redis, only the IP address of redis in redis systems need to be updated, Without the need for sending a notification message to each business network element, and the IP address of the main redis of redis systems is carried out by business network element Modification, simplify carries out the process of master-slave swap to redis, and then improves the efficiency that middle switching is carried out to redis.
Description of the drawings
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing Accompanying drawing to be used needed for having technology description is briefly described, it should be apparent that, drawings in the following description are these Some bright embodiments, for those of ordinary skill in the art, without having to pay creative labor, can be with Other accompanying drawings are obtained according to these accompanying drawings.
The application scenarios schematic diagram of the master-slave swap of the redis that Fig. 1 is provided for the present invention;
The schematic flow sheet of the master-slave switching method of the redis that Fig. 2 is provided for the present invention;
The schematic flow sheet of the renewal redis priority approach that Fig. 3 is provided for the present invention;
The structural representation one of the master-slave swap device of the redis that Fig. 4 is provided for the present invention;
The structural representation two of the master-slave swap device of the redis that Fig. 5 is provided for the present invention.
Specific embodiment
To make purpose, technical scheme and the advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is The a part of embodiment of the present invention, rather than the embodiment of whole.Based on the embodiment in the present invention, those of ordinary skill in the art The every other embodiment obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.
The application scenarios schematic diagram of the master-slave swap of the redis that Fig. 1 is provided for the present invention.Refer to Fig. 1, including redis System 101 and multiple business network element (being designated as 102-1 to 102-N respectively).
Redis systems 101 include monitoring module 1011 and multiple nodes (being designated as 1012-1 to 1012-M respectively), each Node can be physical machine, virtual machine etc..Monitoring module 1011 can monitor the state of each redis, and according to redis's State determines main redis.Redis and corresponding switching device are provided with each node, the switching dress in each node Put and can be communicated with monitoring module 1011, and the switching device in different nodes can be in communication with each other.In synchronization, Redis based on a redis in Redis systems, other redis are from redis, wherein, each redis can be with based on redis.Business network element can conduct interviews to any one redis in redis systems, certainly, in actual application, Business network element to redis systems in main redis conduct interviews.
In this application, virtual ip address is provided with each business network element, business network element can be virtual according to this IP address to redis systems in main redis conduct interviews.In actual application, the corresponding switching dresses of each redis The main redis that can be determined according to monitoring module is put, the IP address of its corresponding redis is safeguarded, so that business network element Can according to virtual ip address to redis systems in main redis conduct interviews.
In this application, the IP address of its corresponding redis is safeguarded by the switching device in each node, To realize carrying out master-slave swap to redis.Wherein, each switching device is safeguarded to the IP address of its corresponding redis Process it is identical.Below, the IP address with the switching device in any one node in redis systems to its corresponding redis As a example by the process safeguarded, the master-slave switching method of redis described herein is described in detail.It is several concrete below Embodiment can be combined with each other, for same or analogous concept and process no longer carry out repeated description.
The schematic flow sheet of the master-slave switching method of the redis that Fig. 2 is provided for the present invention.The executive agent of the method is The corresponding switching devices of any one redis in redis systems, refer to Fig. 2, and the method can include:
The mark of S201, the main redis obtained in redis systems, redis systems include a main redis and at least One from redis.
In this application, optionally, switching device can be keepalived modules.Switching device periodically can be held Embodiment shown in row Fig. 2.Optionally, the cycle can be 1 second, 2 seconds etc., in actual application, can be according to reality Need to arrange the cycle.Certainly, switching device can also perform the embodiment shown in Fig. 2 under preset trigger condition, for example, When monitoring module determination in redis systems needs to carry out principal and subordinate redis switchings, monitoring module sends to switching device and indicates letter Breath, so that switching device performs the embodiment shown in Fig. 2 according to the configured information.Certainly, switching device can be with tactile at other The embodiment shown in Fig. 2 is performed under the conditions of sending out, the present invention is not especially limited to this.
Monitoring module in redis systems can obtain the state of each redis in redis systems in real time, and according to each The state of individual redis determines a main redis, accordingly, other redis in redis systems in addition to main redis be from redis.Optionally, when operation personnel disposes redis systems, operation personnel can configure the main redis of an acquiescence;Accordingly , when initial, the main redis that operation personnel configures can be set to monitoring module the main redis of redis systems, as the master During redis failures, then monitoring module by redis systems from redis arrange based on redis.
When switching device needs the mark of the main redis of acquisition redis systems, switching device can be in monitoring module Obtain the mark of the main redis in redis systems.Optionally, the mark of main redis can the IP address of the redis with based on, master Numbering of redis etc..The mark of main redis, in actual application, can be set according to actual needs.
S202, the priority for according to the mark of main redis, updating the corresponding redis of switching device.
After the mark of the main redis of the redis systems that switching device is acquired, switching device judges which is corresponding Redis mark with the main redis of redis systems identify whether it is consistent.
If so, then switching device according to preset rules, can safeguard that the priority of its corresponding redis is constant or incites somebody to action The priority of its corresponding redis is raised, so that the priority of its corresponding redis is more than other redis in redis systems Priority.
If it is not, then switching device according to preset rules, can safeguard that the priority of its corresponding redis is constant or incites somebody to action The priority of its corresponding redis is reduced so that the priority of its corresponding redis less than in redis systems main redis it is excellent First level.
If the priority of the corresponding redis of S203, switching device is more than the priority of other redis in redis systems, The mapping relations of the IP address of the virtual ip address redis corresponding with switching device of redis systems are set, so that business network element The corresponding redis of switching device is accessed by the virtual ip address of redis systems.
After priority update of the switching device to its corresponding redis, switching device obtains other in redis systems The priority of redis, optionally, the switching device can switching device corresponding with other redis communicated, to obtain other The priority of redis.
Switching device judge the priority of its corresponding redis whether more than in redis systems other redis it is preferential Level, if so, then in redis systems, the highest priority of the corresponding redis of the switching device illustrates that the redis is redis systems Main redis in system.
Switching device judges It is no with mapping relations.Wherein, when between the IP address of the virtual ip address of redis systems redis corresponding with switching device During with mapping relations, then business network element can access the corresponding redis of switching device according to virtual ip address.
If having mapping relations between the IP address of the virtual ip address of redis systems redis corresponding with switching device, Then switching device need not perform other operations.
If not having mapping to close between the IP address of the virtual ip address of redis systems redis corresponding with switching device It is that then switching device will arrange the mapping pass of the IP address of the virtual ip address redis corresponding with switching device of redis systems System.Optionally, switching device can set up the virtual ip address of the corresponding redis of switching device, and switching device is corresponding The virtual ip address of redis is defined as the virtual ip address of redis systems.
If the priority of the corresponding redis of S204, switching device less than or equal in redis systems other redis it is excellent First level, then it is determined that the IP address of the virtual ip address of redis systems redis corresponding with switching device has mapping relations When, cancel mapping relations.
Whether switching device judges the priority of its corresponding redis less than or equal to other redis in redis systems During priority, illustrate that the corresponding redis of switching device is not the main redis of redis systems.Switching device is determined whether Whether there are mapping relations between the IP address of the virtual ip address of redis systems redis corresponding with switching device.
If judge not have between the IP address of the virtual ip address of redis systems redis corresponding with switching device reflecting Relation is penetrated, then switching device need not perform other operations.
If judging that there is between the IP address of the virtual ip address of redis systems redis corresponding with switching device mapping Relation, then switching device cancel the mapping relations, to avoid business network element redis corresponding to switching device from conducting interviews.Can Choosing, switching device can delete the redis, and redis systems virtual ip address identical IP address.
The master-slave switching method of redis provided in an embodiment of the present invention, it is corresponding by each redis in redis systems Switching device is safeguarded to the IP address of redis, when a redis is the main redis in redis systems, this redis pair The switching device answered arranges the corresponding relation of the redis and the virtual ip address of redis systems, so that business network element can basis The virtual ip address of redis systems, conducts interviews to the main redis of the redis systems.In above process, when entering to redis After row master-slave swap, only the IP address of redis in redis systems need to be updated, without the need for each service network Unit sends a notification message, and the IP address of the main redis of redis systems is modified by business network element, simplifies to redis The process of master-slave swap is carried out, and then improves the efficiency that middle switching is carried out to redis.
In the embodiment shown in Figure 2, optionally, mark of the following feasible implementation according to main redis can be passed through Know, update the priority (S202 in embodiment illustrated in fig. 2) of the corresponding redis of switching device, specifically, refer to Fig. 3 institutes The embodiment shown.
The schematic flow sheet of the renewal redis priority approach that Fig. 3 is provided for the present invention.Refer to Fig. 3, the method can be with Including:
S301, the mark for judging main redis redis corresponding with switching device identify whether it is consistent;
If so, then perform S302.If it is not, then performing S303.
When switching device judges that the mark of the mark of main redis redis corresponding with switching device is consistent, switching device Determine its corresponding redis be redis systems main redis, then need the priority for safeguarding its corresponding redis it is constant, or The priority of its corresponding redis is raised by person, so that the priority of its corresponding redis is more than other in redis systems The priority of redis.
When switching device judges that the mark of the mark of main redis redis corresponding with switching device is inconsistent, switching dress Put and determine that its corresponding redis is redis systems from redis, then need the priority for safeguarding its corresponding redis it is constant, Or the priority of its corresponding redis is reduced, so that the priority of its corresponding redis is less than or equal to redis systems The priority of middle main redis.
S302, by the priority update of switching device corresponding redis for the corresponding redis of switching device initial priority Level and priority delta sum, initial priority and the priority delta sum of the corresponding redis of switching device are more than redis systems The priority of other redis in system.
In the embodiment shown in fig. 3, each redis one initial priority of correspondence in redis systems, this is initial Priority can be that operation personnel is arranged for each redis in deployment redis systems.Optionally, in operation personnel portion During administration's redis systems, operation personnel can configure the main redis in redis systems and from redis, and arrange the first of main redis Beginning priority is higher than the initial priority from redis.For example, it is assumed that operation personnel is when redis systems are disposed, redis systems Include 3 redis, be designated as redis1-redis3 respectively, it is further assumed that operation personnel by redis1 arrange based on redis, will Redis2 and redis3 are set to from redis, then the initial priority of redis1 can be set to 100 by operation personnel, will The initial priority of redis2 and redis3 is set to 90.
Certainly, when operation personnel disposes redis systems, operation personnel can be with the initial priority according to main redis With from redis initial priority arrange priority delta, wherein, priority delta more than main redis initial priority with From the difference of the initial priority of redis.For example, it is assumed that the initial priority of main redis is 100, from the initial priority of redis For 90, then priority delta is more than 10 (100-90), and for example, priority delta can be 20,30,50 etc..
When switching device judges that the mark of the mark of main redis redis corresponding with switching device is consistent, switching device Obtain the initial priority and priority delta of its corresponding redis, and by the priority of switching device corresponding redis more The new initial priority for the corresponding redis of switching device and priority delta sum.So, the switching device is corresponding Priority of the priority of redis more than other redis in redis systems.
S303, by the priority update of switching device corresponding redis for the corresponding redis of switching device initial priority Level.
When switching device judges that the mark of the mark of main redis redis corresponding with switching device is inconsistent, switching dress Put by the priority update of its corresponding redis for the corresponding redis of switching device initial priority.
In above process, by arranging initial priority and priority delta for each redis in redis systems, And the priority of each redis in redis systems is safeguarded using said method, so, in each switching device During safeguarding to the priority of its corresponding redis, it is ensured that in redis systems, the priority of main redis is most Height, and then can ensure that accurate master-slave swap is carried out to redis.
On the basis of above-mentioned any one embodiment, optionally, in actual application, in order to ensure switching device Superperformance, it may be necessary to the operation such as periodically carry out upgrading to switching device, safeguard.Being updated to switching device, When safeguarding, need to suspend switching device, suspended to switching device input from operation personnel when usual and notified.As switching device is needed The IP address of redis is managed, when switching device is suspended, then the IP address of redis cannot be managed, be made The IP address for obtaining the redis cannot be corresponding with the virtual ip address of redis systems, causes the redis then cannot be by business network element Access, however, now, if the redis is the main redis of redis systems, access of the business network element to redis systems fails.
In order to avoid the generation of the problems referred to above, after switching device receives time-out notice, switching device is according to master The mark of redis, judge the corresponding redis of switching device whether based on redis, if so, then suspend switching device corresponding Redis, so that redis systems switch main redis.Certainly, after in order to avoid being suspended in switching device, the switching device pair Redis based on the monitored module settings of redis answered, after switching device receives time-out notice, switching device can be straight Connect and suspend the corresponding redis of the switching device.Optionally, after switching device receives time-out notice, can call Stopmasterredis.sh scripts, so that redis is suspended by stopmasterredis.sh scripts.
On the basis of above-mentioned any one embodiment, optionally, in the running of redis, redis because of Many reasons operation suspension, for example, it may be possible to due to the temporary load too high of redis, and cause redis operation suspensions.In reality In the application process of border, in order to ensure operation that redis can be good, it is corresponding that switching device can periodically obtain which The state of redis, optionally, the state of redis includes running status and halted state.If switching device judges the shape of redis When state is halted state, then switching device can call default script, with corresponding by default script startup switching device The state of redis.Optionally, the default script can be startredis.sh scripts.Call in switching device After startredis.sh scripts, the startredis.sh scripts can control redis and start in preset duration, and this is preset Duration can be 1 minute.
Below, by instantiation, the technical scheme shown in said method embodiment is described in detail.
Exemplary, it is assumed that redis systems include 3 redis, are designated as redis1-redis3 respectively, 3 redis Correspondence switching device is designated as switching device 1- switching device 3 respectively.Assume again that the main redis of acquiescence that user is arranged is redis1, It is and the initialization priority of redis1 that user is arranged is respectively 90 for the initialization priority of 100, redis2 and redis3, excellent First level increment is 50.
When initial, monitoring module according to the setting of user by redis1 arrange based on redis, by redis2 and redis3 It is set to from redis.
Switching device 1 determines that the main redis of redis systems is redis1, then switching dress by interacting with monitoring module It is 100+50=150 that 1 is put by the priority update of redis1.
Switching device 2 is determined that the main redis of redis systems is not redis2, is then switched by being interacted with monitoring module The priority update of redis2 is 90 by device 2.
Switching device 3 is determined that the main redis of redis systems is not redis3, is then switched by being interacted with monitoring module The priority update of redis3 is 90 by device 3.
Switching device 1- switching device 3 determines the highest priority of redis1 by interaction, switching device 1, then switching dress Put 1 and virtual IP address is set for redis1, and the virtual IP address of redis1 is set to the virtual IP address of redis systems.Assume redis systems Virtual IP address be IP0, then switching device 1 virtual IP address of redis1 is set to into IP0.
Virtual IP address (IP0) as redis systems are provided with business network element, then business network element can be right according to IP0 Redis1 conducts interviews.
In the running of redis systems, it is assumed that due to breaking down and operation suspension, then monitoring module will for redis1 Redis based on redis2 switchings, now, redis3 is still from redis.
Switching device 1 judges the state of redis1 for halted state, then switching device calls startredis.sh scripts, And pass through startredis.sh script startup redis1.After redis1 is activated, switching device 1 judges redis systems Main redis is not redis1, then switching device by the priority update of redis1 for redis1 initial priority 100.
By interacting with monitoring module, switching device 2 determines that the main redis of redis systems is redis2, then switching dress It is 90+50=140 that 2 are put by the priority update of redis2.
Switching device 3 is determined that the main redis of redis systems is not redis3, is then switched by being interacted with monitoring module The priority update of redis3 is 90 by device 3.
Switching device 1- switching device 3 determines the highest priority of redis2 by interaction, switching device 2, then switching dress Put 2 and virtual IP address is set for redis1, and the virtual IP address of redis2 is arranged into IP0.Meanwhile, switching device 1 judges that redis1 also sets Virtual IP address (IP0) is equipped with, then switching device 1 can delete the virtual IP address of redis1.Certainly, after redis1 is suspended Setting in redis1 may recover initial setting up, so that the virtual IP address in redis1 is deleted.
Virtual IP address (IP0) as redis systems are provided with business network element, then business network element can be right according to IP0 Redis2 conducts interviews.
In above process, when in redis systems, main redis changes, without the need for sending logical to each business network element Know message, the IP address of the main redis of the redis systems stored to which without each business network element is updated, only need each Individual switching device is safeguarded that to the IP address of its corresponding redis simplify carries out the mistake of master-slave swap to redis Journey, and then improve the efficiency that master-slave swap is carried out to redis.
The structural representation one of the master-slave swap device of the redis that Fig. 4 is provided for the present invention.Fig. 4 is referred to, the device can To include the first acquisition module 401, update module 402 and setup module 403, wherein,
First acquisition module 401 is used for, and obtains the mark of the main redis in the redis systems, the redis System includes a main redis and at least one from redis;
The update module 402 is used for, and according to the mark of the main redis, updates the corresponding redis of the switching device Priority;
The setup module 403 is used for, and is more than the redis systems in the priority of the corresponding redis of the switching device In system during the priority of other redis, the virtual ip address for arranging the redis systems is corresponding with the switching device The mapping relations of the IP address of redis, so that business network element accesses the switching by the virtual ip address of the redis systems The corresponding redis of device;
The setup module 403 is additionally operable to, and is less than or equal in the priority of the corresponding redis of the switching device described The priority of other redis in redis systems, and determine the virtual ip address and the switching device pair of the redis systems When the IP address of the redis for answering has mapping relations, cancel the mapping relations.
The master-slave swap device of the redis shown in the embodiment of the present invention can perform the technology shown in said method embodiment Scheme, which is realized that principle and beneficial effect are similar, is no longer repeated herein.
In a kind of possible embodiment, the update module 402 specifically for:
Judge the main redis mark redis corresponding with the switching device identify whether it is consistent;
If so, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device Initial priority and priority delta sum, the initial priority and priority delta of the corresponding redis of the switching device Priority of the sum more than other redis in the redis systems;
If it is not, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device Initial priority.
In alternatively possible embodiment, the setup module 403 specifically for:
Set up the virtual ip address of the corresponding redis of the switching device;
The virtual ip address of the switching device corresponding redis is defined as into the virtual ip address of the redis systems.
The structural representation two of the master-slave swap device of the redis that Fig. 5 is provided for the present invention.In embodiment illustrated in fig. 4 On the basis of, optionally, described device also includes judge module 404 and suspends module 405, wherein,
The judge module 404 is used for, and after receiving time-out and notifying, according to the mark of the main redis, judges institute State the corresponding redis of switching device whether based on redis;
The time-out module 405 is used for, and judges based on the corresponding redis of the switching device in the judge module During redis, suspend the corresponding redis of the switching device, so that the redis systems switch main redis.
In alternatively possible embodiment, described device also includes the second acquisition module 406 and starting module 407, Wherein,
Second acquisition module 406 is used for, and obtains the state of the corresponding redis of the switching device;
The starting module 407 is used for, when it is determined that the state of the corresponding redis of the switching device is halted state, Default script is called, with the state by the corresponding redis of switching device described in the default script startup.
The master-slave swap device of the redis shown in the embodiment of the present invention can perform the technology shown in said method embodiment Scheme, which is realized that principle and beneficial effect are similar, is no longer repeated herein.
It should be noted that the master-slave swap device of redis shown in the embodiment of the present invention and said method embodiment institute The switching device shown is identical.In embodiment of the method, for the ease of description, the master-slave swap device of redis is referred to as switched Device.
The embodiment of the present invention also provides a kind of redis systems, including monitoring module, multiple redis and each redis The master-slave swap device of the corresponding redis as described in Fig. 4 or Fig. 5 embodiments.Wherein, the structure of redis systems may be referred to Fig. 1, the embodiment of the present invention are no longer repeated.
One of ordinary skill in the art will appreciate that:Realize that all or part of step of above-mentioned each method embodiment can be led to Cross the related hardware of programmed instruction to complete.Aforesaid program can be stored in a computer read/write memory medium.The journey Sequence upon execution, performs the step of including above-mentioned each method embodiment;And aforesaid storage medium includes:ROM, RAM, magnetic disc or Person's CD etc. is various can be with the medium of store program codes.
Finally it should be noted that:Various embodiments above only to illustrate technical scheme, rather than a limitation;To the greatest extent Pipe has been described in detail to the present invention with reference to foregoing embodiments, it will be understood by those within the art that:Its according to So the technical scheme described in foregoing embodiments can be modified, or which part or all technical characteristic are entered Row equivalent;And these modifications or replacement, do not make the essence of appropriate technical solution depart from various embodiments of the present invention technology The scope of scheme.

Claims (10)

1. a kind of master-slave switching method of redis, it is characterised in that any one redis correspondence being applied in redis systems Switching device, including:
The mark of the main redis in the redis systems is obtained, the redis systems include a main redis and at least It is individual from redis;
According to the mark of the main redis, the priority of the corresponding redis of the switching device is updated;
If the priority of the corresponding redis of the switching device is more than the priority of other redis in the redis systems, The mapping relations of the IP address of the virtual ip address redis corresponding with the switching device of the redis systems are set, so that Business network element accesses the corresponding redis of the switching device by the virtual ip address of the redis systems;
If the priority of the corresponding redis of the switching device less than or equal in the redis systems other redis it is preferential Level, then it is determined that the IP address of the virtual ip address of redis systems redis corresponding with the switching device has mapping During relation, cancel the mapping relations.
2. method according to claim 1, it is characterised in that according to the mark of the main redis, updates the switching dress The priority of corresponding redis is put, including:
Judge the main redis mark redis corresponding with the switching device identify whether it is consistent;
If so, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device just Beginning priority and priority delta sum, the initial priority and priority delta sum of the corresponding redis of the switching device More than the priority of other redis in the redis systems;
If it is not, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device just Beginning priority.
3. method according to claim 1 and 2, it is characterised in that the virtual ip address of the setting redis systems The mapping relations of the IP address of redis corresponding with the switching device, including:
Set up the virtual ip address of the corresponding redis of the switching device;
The virtual ip address of the switching device corresponding redis is defined as into the virtual ip address of the redis systems.
4. method according to claim 1 and 2, it is characterised in that methods described also includes:
After the switching device receives time-out notice, according to the mark of the main redis, the switching device pair is judged The redis for answering whether based on redis;
If so, then suspend the corresponding redis of the switching device, so that the redis systems switch main redis.
5. method according to claim 1 and 2, it is characterised in that methods described also includes:
Obtain the state of the corresponding redis of the switching device;
When it is determined that the state of the corresponding redis of the switching device is halted state, default script is called, with by described pre- If the state of the corresponding redis of switching device described in script startup.
6. the master-slave swap device of a kind of redis, it is characterised in that including the first acquisition module, update module and setup module, Wherein,
First acquisition module is used for, and obtains the mark of the main redis in the redis systems, wraps in the redis systems A main redis and at least one is included from redis;
The update module is used for, and according to the mark of the main redis, updates the preferential of the corresponding redis of the switching device Level;
The setup module is used for, the corresponding redis of the switching device priority more than in the redis systems other The IP ground of the virtual ip address redis corresponding with the switching device of the redis systems, during the priority of redis, is set The mapping relations of location, so that business network element is corresponding by the virtual ip address access switching device of the redis systems redis;
The setup module is additionally operable to, and is less than or equal to the redis systems in the priority of the corresponding redis of the switching device The priority of other redis in system, and determine that the virtual ip address of the redis systems is corresponding with the switching device When the IP address of redis has mapping relations, cancel the mapping relations.
7. device according to claim 6, it is characterised in that the update module specifically for:
Judge the main redis mark redis corresponding with the switching device identify whether it is consistent;
If so, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device just Beginning priority and priority delta sum, the initial priority and priority delta sum of the corresponding redis of the switching device More than the priority of other redis in the redis systems;
If it is not, then by the priority update of the switching device corresponding redis be the corresponding redis of the switching device just Beginning priority.
8. the device according to claim 6 or 7, it is characterised in that the setup module specifically for:
Set up the virtual ip address of the corresponding redis of the switching device;
The virtual ip address of the switching device corresponding redis is defined as into the virtual ip address of the redis systems.
9. the device according to claim 6 or 7, it is characterised in that described device also includes judge module and suspend module, Wherein,
The judge module is used for, and after receiving time-out and notifying, according to the mark of the main redis, judges the switching The corresponding redis of device whether based on redis;
The time-out module is used for, when the judge module judges redis based on the corresponding redis of the switching device, temporarily Stop the corresponding redis of the switching device, so that the redis systems switch main redis.
10. a kind of redis systems, it is characterised in that corresponding such as including monitoring module, multiple redis and each redis The master-slave swap device of redis described in any one of claim 6-9.
CN201611054605.4A 2016-11-25 2016-11-25 The master-slave switching method of Redis, device and redis systems Pending CN106559267A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611054605.4A CN106559267A (en) 2016-11-25 2016-11-25 The master-slave switching method of Redis, device and redis systems

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611054605.4A CN106559267A (en) 2016-11-25 2016-11-25 The master-slave switching method of Redis, device and redis systems

Publications (1)

Publication Number Publication Date
CN106559267A true CN106559267A (en) 2017-04-05

Family

ID=58444954

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611054605.4A Pending CN106559267A (en) 2016-11-25 2016-11-25 The master-slave switching method of Redis, device and redis systems

Country Status (1)

Country Link
CN (1) CN106559267A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106982259A (en) * 2017-04-19 2017-07-25 聚好看科技股份有限公司 The failure solution of server cluster
CN107181834A (en) * 2017-06-13 2017-09-19 聚好看科技股份有限公司 A kind of redis manages method, device and the redis systems of virtual ip address
CN108234191A (en) * 2017-05-31 2018-06-29 深圳市创梦天地科技有限公司 The management method and device of cloud computing platform
CN110324176A (en) * 2019-05-29 2019-10-11 平安科技(深圳)有限公司 Monitoring method, device and the storage medium of mqtt cluster based on Redis
CN110659262A (en) * 2019-09-20 2020-01-07 聚好看科技股份有限公司 Master-slave switching method and device for redis node
CN111934909A (en) * 2020-07-13 2020-11-13 深圳栅格信息技术有限公司 Method and device for switching IP (Internet protocol) resources of host and standby machine, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103188105A (en) * 2011-12-31 2013-07-03 中国航天科工集团第二研究院七〇六所 Safety enhancing system and method thereof of NAS equipment
CN104199957A (en) * 2014-09-17 2014-12-10 合一网络技术(北京)有限公司 Redis universal agent implementation method
CN104394142A (en) * 2014-11-24 2015-03-04 北京京东尚科信息技术有限公司 Method and device for achieving automatic Redis master-slave conversion
US20160188426A1 (en) * 2014-12-31 2016-06-30 International Business Machines Corporation Scalable distributed data store
CN106021370A (en) * 2016-05-11 2016-10-12 智者四海(北京)技术有限公司 Memory database instance management method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103188105A (en) * 2011-12-31 2013-07-03 中国航天科工集团第二研究院七〇六所 Safety enhancing system and method thereof of NAS equipment
CN104199957A (en) * 2014-09-17 2014-12-10 合一网络技术(北京)有限公司 Redis universal agent implementation method
CN104394142A (en) * 2014-11-24 2015-03-04 北京京东尚科信息技术有限公司 Method and device for achieving automatic Redis master-slave conversion
US20160188426A1 (en) * 2014-12-31 2016-06-30 International Business Machines Corporation Scalable distributed data store
CN106021370A (en) * 2016-05-11 2016-10-12 智者四海(北京)技术有限公司 Memory database instance management method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
UREY_PP: "利用redis-sentinel+keepalived实现redis高可用", 《51CTO博客》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106982259A (en) * 2017-04-19 2017-07-25 聚好看科技股份有限公司 The failure solution of server cluster
CN108234191A (en) * 2017-05-31 2018-06-29 深圳市创梦天地科技有限公司 The management method and device of cloud computing platform
CN107181834A (en) * 2017-06-13 2017-09-19 聚好看科技股份有限公司 A kind of redis manages method, device and the redis systems of virtual ip address
CN107181834B (en) * 2017-06-13 2021-02-12 聚好看科技股份有限公司 Method and device for managing virtual IP address by redis and redis system
CN110324176A (en) * 2019-05-29 2019-10-11 平安科技(深圳)有限公司 Monitoring method, device and the storage medium of mqtt cluster based on Redis
CN110659262A (en) * 2019-09-20 2020-01-07 聚好看科技股份有限公司 Master-slave switching method and device for redis node
CN111934909A (en) * 2020-07-13 2020-11-13 深圳栅格信息技术有限公司 Method and device for switching IP (Internet protocol) resources of host and standby machine, computer equipment and storage medium
CN111934909B (en) * 2020-07-13 2023-06-13 深圳栅格信息技术有限公司 Main-standby machine IP resource switching method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN106559267A (en) The master-slave switching method of Redis, device and redis systems
WO2020253596A1 (en) High availability method and apparatus for redis cluster
CN106301876B (en) Physical machine upgrade method, business migration method and device
CN109815049A (en) Node delay machine restoration methods, device, electronic equipment and storage medium
CN107239383A (en) A kind of failure monitoring method and device of OpenStack virtual machines
CN107147540A (en) Fault handling method and troubleshooting cluster in highly available system
CN104077199B (en) Based on partition method and the system of the high-availability cluster of shared disk
CN107222320A (en) The method and apparatus that Cloud Server cluster sets up High Availabitity connection
CN103051470B (en) The control method of a kind of cluster and magnetic disk heartbeat thereof
CN110134518A (en) A kind of method and system improving big data cluster multinode high application availability
CN103383689A (en) Service process fault detection method, device and service node
CN108108255A (en) The detection of virtual-machine fail and restoration methods and device
CN109286529A (en) A kind of method and system for restoring RabbitMQ network partition
JP2005327271A (en) Reconfiguration of logical setting in storage system
CN112948063A (en) Cloud platform creation method and device, cloud platform and cloud platform implementation system
CN102301344A (en) Method for debugging kernel of operating system and virtual debugging service module
CN111181780A (en) HA cluster-based host pool switching method, system, terminal and storage medium
CN112199240A (en) Method for switching nodes during node failure and related equipment
CN115167757A (en) Acceleration card distributed storage access method, device, equipment and storage medium
CN110413225A (en) Highly reliable cluster-based storage dual-active configuration method, system, terminal and storage medium
WO2022172062A1 (en) Network service management device and network service management method
JP2015114952A (en) Network system, monitoring control unit, and software verification method
CN108334401B (en) System and method for realizing logic roll dynamic distribution and supporting virtual machine dynamic migration
CN105871524B (en) A kind of method and system based on TIPC protocol realization two-node cluster hot backup
CN111966469B (en) Cluster virtual machine high availability method and system

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20170405