CN108023932A - A kind of implementation method based on Redis general-purpose proxies, storage medium and electronic equipment - Google Patents

A kind of implementation method based on Redis general-purpose proxies, storage medium and electronic equipment Download PDF

Info

Publication number
CN108023932A
CN108023932A CN201711020724.2A CN201711020724A CN108023932A CN 108023932 A CN108023932 A CN 108023932A CN 201711020724 A CN201711020724 A CN 201711020724A CN 108023932 A CN108023932 A CN 108023932A
Authority
CN
China
Prior art keywords
redis
examples
master
proxies
slave
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
CN201711020724.2A
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.)
Concord Health Cloud Services Ltd
Original Assignee
Concord Health Cloud Services 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 Concord Health Cloud Services Ltd filed Critical Concord Health Cloud Services Ltd
Priority to CN201711020724.2A priority Critical patent/CN108023932A/en
Publication of CN108023932A publication Critical patent/CN108023932A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The present invention provides a kind of implementation method based on Redis general-purpose proxies, and this method includes:The connection configuration of Redis general-purpose proxies, it is connected to Redis Sentinel, Master examples are obtained by Sentinel Masters orders, and it recorded set Masters, travel through set Masters and the associated Slave examples of Master examples are obtained by Sentinel Slaves orders, by Master examples, Slave examples are distributed by using uniformity hash algorithm, switch master message is subscribed to by Redis Sentinel PSUBSCRIBE orders, client call Redis proxy interfaces, create agency's connection handle, handle is acted on behalf of by connection and performs Redis orders.Connected and configured by Redis general-purpose proxies, record the relation between Master examples and Slave examples, Master examples, Slave examples are distributed by using uniformity hash algorithm, the distributions of key in the cluster can be managed by consistent hashing mode, and can ensure the uniformity being distributed between each example.

Description

A kind of implementation method based on Redis general-purpose proxies, storage medium and electronic equipment
Technical field
The present invention relates to data processing field, more particularly to a kind of implementation method based on Redis general-purpose proxies, storage to be situated between Matter and electronic equipment.
Background technology
Redis be it is a increase income, high performance key-value storage (key-value store) system.Redis's is all Key assignments is stored in memory, has very high unit readwrite performance.Operate Redis when, it is necessary to according to Redis protocol specifications with Redis servers communicate.Redis provides sentinel functions since 2.8 versions, when Redis is configured with principal and subordinate's mould During formula, master-slave swap can be carried out by sentinel.
In the prior art, there are the following problems by Redis:The order of Redis can not cross over multiple Redis examples, same A operation multiple key of possible operation, existing Redis clients can not ensure multiple key on same Redis examples, together One multiple key of operation possible operation.
The content of the invention
For overcome the deficiencies in the prior art, it is an object of the present invention to provide one kind to be based on Redis general-purpose proxies Implementation method, it, which can solve the order of Redis, can not cross over multiple Redis examples, and same operation possible operation is multiple Key, existing Redis clients can not ensure multiple key on same Redis examples, and same operation possible operation is more The problem of a key.
The second object of the present invention is to provide a kind of a kind of electronic equipment, it, which can solve the order of Redis, to cross over Multiple Redis examples, the same operation multiple key of possible operation, existing Redis clients can not ensure multiple key same On one Redis example, the problem of same operation possible operation multiple key.
The third object of the present invention is to provide a kind of computer-readable recording medium, it can solve the order nothing of Redis Method crosses over multiple Redis examples, and the same operation multiple key of possible operation, existing Redis clients can not ensure multiple Key is on same Redis examples, the problem of same operation possible operation multiple key.
An object of the present invention is realized using following technical scheme:
A kind of implementation method based on Redis general-purpose proxies, this method comprise the following steps:
During Redis general-purpose proxies, it is necessary first to initialized, including step 1-3:
Step 1:The connection configuration of Redis general-purpose proxies, configures the link information of the Redis Sentinel in cluster;
Step 2:Redis Sentinel are connected to, Master examples are obtained by Sentinel Masters orders, and It recorded set Masters;
Step 3:Redis Sentinel are connected to, traversal set Masters is obtained by Sentinel Slaves orders The associated Slave examples of Master examples, record the relation between the Master examples and the Slave examples;
Step 4:The Master examples, the Slave examples are distributed by using uniformity hash algorithm;
Step 5:Switch-master message is subscribed to by Redis Sentinel PSUBSCRIBE orders;
Step 6:Client call Redis proxy interfaces, create agency's connection handle, are held by connecting the handle of acting on behalf of Row Redis orders.
Further, when calling Redis general-purpose proxies to perform order, following steps are performed:
Step A:Judge whether to specify the business prefix of Key, if so, the hash value of Key business prefixes is then calculated, if It is no, then calculate the hash value of complete Key;
Step B:The example of Redis is selected by hash value;
Step C:Whether have available TCP long connection to selected Redis example, if then using if checking in connection pool The TCP long connections;
Step D:Redis orders are sent in the TCP long connections;
Step E:After receiving Redis response messages, perform Redis agreements and explain flow;
Step F:The return value of response command is sent to client.
Further, the hash value of the calculating Key business prefixes calculates Key industry specifically by Hash consistency algorithm The hash value for prefix of being engaged in;It is described calculate complete Key hash value be specially:Calculate complete Key's by Hash consistency algorithm Hash value.
Further, when master-slave swap occurs for Redis, following steps are performed:
Step G:The switch-master message that processing PSubscribe orders subscribe to, and obtain Redis Sentinel example link informations;
Step H:By Sentinel Slave orders, obtain Master examples and correspond to all Slave examples and again Update the relation between Master and Slave examples;
Step I:Discharge connection pool in the relevant TCP long connections of the Master and Slave examples.
The second object of the present invention is realized using following technical scheme:
A kind of electronic equipment, it is characterised in that including:Processor;
Memory;And program, wherein described program is stored in the memory, and is configured to by processor Perform, described program includes a kind of implementation method based on Redis general-purpose proxies of the present invention.
The third object of the present invention is realized using following technical scheme:
A kind of computer-readable recording medium, is stored thereon with computer program, it is characterised in that:The computer program It is executed by processor a kind of implementation method based on Redis general-purpose proxies of the present invention.
Compared with prior art, the beneficial effects of the present invention are:A kind of Redis general-purpose proxies of being based on of the present invention Implementation method, is connected by Redis general-purpose proxies and configured, and records the relation between Master examples and Slave examples, will Master examples, Slave examples are distributed by using uniformity hash algorithm, can be managed by consistent hashing mode The distributions of key in the cluster, and can ensure the uniformity being distributed between each example;If specifying the weight of example, Then each example according to weight pro rate key.Redis general-purpose proxies can coordinate sentinel functions, real in agent side Existing master-slave swap, finds new Redis examples by Sentinel related commands, master-slave swap is completed when breaking down switching Afterwards, can communicate with new example;Ensure the high availability of service;Before Redis general-purpose proxies can specify the business of key Sew, consistent hashing is carried out only according to the business prefix part of Key, it is ensured that the key values hash of certain a kind of business arrives same In a Redis examples, easy to need the computing of multiple key.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention, And can be practiced according to the content of specification, below with presently preferred embodiments of the present invention and coordinate attached drawing describe in detail as after. The embodiment of the present invention is shown in detail by following embodiments and its attached drawing.
Brief description of the drawings
Attached drawing described herein is used for providing a further understanding of the present invention, forms the part of the application, this hair Bright schematic description and description is used to explain the present invention, does not form inappropriate limitation of the present invention.In the accompanying drawings:
Fig. 1 is a kind of flow chart of implementation method based on Redis general-purpose proxies of the present invention.
Embodiment
In the following, with reference to attached drawing and embodiment, the present invention is described further, it is necessary to which explanation is, not Under the premise of afoul, new implementation can be formed between various embodiments described below or between each technical characteristic in any combination Example.
A kind of implementation method based on Redis general-purpose proxies as shown in Figure 1 comprises the following steps:
During Redis general-purpose proxies, it is necessary first to initialized, including step 1-3:
Step 1:The connection configuration of Redis general-purpose proxies, configures the link information of Redis Sentinel in cluster;
Step 2:Redis Sentinel are connected to, Master examples are obtained by Sentinel Masters orders, and It recorded set Masters;
Step 3:Redis Sentinel are connected to, traversal set Masters is obtained by Sentinel Slaves orders The associated Slave examples of Master examples, record the relation between Master examples and Slave examples;
Step 4:Master examples, Slave examples are distributed by using uniformity hash algorithm;
Step 5:Switch-master message is subscribed to by Redis Sentinel PSUBSCRIBE orders;
Step 6:Client call Redis proxy interfaces, create agency's connection handle, and acting on behalf of handle by connection performs Redis orders.
When calling Redis general-purpose proxies to perform order, following steps are performed:
Step A:Judge whether to specify the business prefix of Key, if so, the hash value of Key business prefixes is then calculated, if It is no, then the hash value of complete Key is calculated, the hash value for calculating Key business prefixes is calculated specifically by Hash consistency algorithm The hash value of Key business prefixes;The hash value for calculating complete Key is specially:Calculate complete Key's by Hash consistency algorithm Hash value.
Step B:The example of Redis is selected by hash value;
Step C:Whether have available TCP long connection to selected Redis example, if then using if checking in connection pool TCP long connections;
Step D:Redis orders are sent in TCP long connections;
Step E:After receiving Redis response messages, perform Redis agreements and explain flow;
Step F:The return value of response command is sent to client.
When master-slave swap occurs for Redis, following steps are performed:
Step G:The switch-master message that processing PSubscribe orders subscribe to, and obtain Redis Sentinel example link informations;
Step H:By Sentinel Slave orders, obtain Master examples and correspond to all Slave examples and again Update the relation between Master and Slave examples;
Step I:Discharge TCP long connections relevant with Master and Slave examples in connection pool.
The a kind of electronic equipment of the present invention, it is characterised in that including:Processor;
Memory;And program, its Program are stored in memory, and it is configured to be performed by processor, journey Sequence includes being used for a kind of implementation method based on Redis general-purpose proxies for performing the present invention.
A kind of computer-readable recording medium of the present invention, is stored thereon with computer program, it is characterised in that:Computer Program is executed by processor a kind of implementation method based on Redis general-purpose proxies of the present invention.
A kind of implementation method based on Redis general-purpose proxies of the present invention, is connected by Redis general-purpose proxies and configured, note The relation between Master examples and Slave examples is recorded, Master examples, Slave examples are calculated by using uniformity Hash Method is distributed, and the distributions of key in the cluster can be managed by consistent hashing mode, and can ensure each example it Between the uniformity that is distributed;Redis general-purpose proxies can coordinate sentinel functions, and master-slave swap is realized in agent side, occur New Redis examples are found by Sentinel related commands during failover, after the completion of master-slave swap, can with new example into Row communication;Ensure the high availability of service;Redis general-purpose proxies can specify the business prefix of key, only according to the business of Key Prefix part carries out consistent hashing, it is ensured that the key values of certain a kind of business are hashed into same Redis examples, are easy to Need the computing of multiple key.
More than, it is only presently preferred embodiments of the present invention, not makees limitation in any form to the present invention;All one's own professions The those of ordinary skill of industry can swimmingly implement the present invention shown in by specification attached drawing and above;But all to be familiar with sheet special The technical staff of industry without departing from the scope of the present invention, is made a little using disclosed above technology contents The equivalent variations of variation, modification and evolution, are the equivalent embodiment of the present invention;Meanwhile all substantial technologicals according to the present invention Variation, modification and evolution of any equivalent variations made to above example etc., still fall within technical scheme Within protection domain.

Claims (6)

1. a kind of implementation method based on Redis general-purpose proxies, it is characterised in that comprise the following steps:
During Redis general-purpose proxies, it is necessary first to initialized, comprised the following steps:
Step 1:The connection configuration of Redis general-purpose proxies, configures the link information of the Redis Sentinel in cluster;
Step 2:Redis Sentinel are connected to, Master examples are obtained by Sentinel Masters orders, and record To set Masters;
Step 3:Redis Sentinel are connected to, traversal set Masters passes through described in Sentinel Slaves orders acquisition The associated Slave examples of Master examples, record the relation between the Master examples and the Slave examples;
Step 4:The Master examples, the Slave examples are distributed by using uniformity hash algorithm;
Step 5:Switch-master message is subscribed to by Redis Sentinel PSUBSCRIBE orders;
Step 6:Client call Redis proxy interfaces, create agency's connection handle, are performed by connecting the handle of acting on behalf of Redis orders.
A kind of 2. implementation method based on Redis general-purpose proxies as claimed in claim 1, it is characterised in that:
When calling Redis general-purpose proxies to perform order, following steps are performed:
Step A:Judge whether to specify the business prefix of Key, if so, the hash value of Key business prefixes is then calculated, if it is not, then Calculate the hash value of complete Key;
Step B:The example of Redis is selected by hash value;
Step C:Whether have available TCP long connection to selected Redis example, if then using described if checking in connection pool TCP long connections;
Step D:Redis orders are sent in the TCP long connections;
Step E:After receiving Redis response messages, perform Redis agreements and explain flow;
Step F:The return value of response command is sent to client.
A kind of 3. implementation method based on Redis general-purpose proxies as claimed in claim 2, it is characterised in that:The calculating Key The hash value of business prefix calculates the hash value of Key business prefixes specifically by Hash consistency algorithm;It is described to calculate completely The hash value of Key is specially:The hash value of complete Key is calculated by Hash consistency algorithm.
A kind of 4. implementation method based on Redis general-purpose proxies as described in any one in claim 2, it is characterised in that:
When master-slave swap occurs for Redis, following steps are performed:
Step G:The switch-master message that processing PSubscribe orders subscribe to, and obtain Redis Sentinel realities Example link information;
Step H:By Sentinel Slave orders, obtain Master examples and correspond to all Slave examples and update again Relation between Master and Slave examples;
Step I:Discharge connection pool in the relevant TCP long connections of the Master and Slave examples.
5. a kind of electronic equipment, it is characterised in that including:Processor;
Memory;And program, wherein described program is stored in the memory, and is configured to be held by processor OK, described program includes being used for the method described in perform claim requirement 1-4 any one.
6. a kind of computer-readable recording medium, is stored thereon with computer program, it is characterised in that:The computer program quilt Processor performs the method as described in claim 1-4 any one.
CN201711020724.2A 2017-10-26 2017-10-26 A kind of implementation method based on Redis general-purpose proxies, storage medium and electronic equipment Pending CN108023932A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711020724.2A CN108023932A (en) 2017-10-26 2017-10-26 A kind of implementation method based on Redis general-purpose proxies, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711020724.2A CN108023932A (en) 2017-10-26 2017-10-26 A kind of implementation method based on Redis general-purpose proxies, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN108023932A true CN108023932A (en) 2018-05-11

Family

ID=62079606

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711020724.2A Pending CN108023932A (en) 2017-10-26 2017-10-26 A kind of implementation method based on Redis general-purpose proxies, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN108023932A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108846051A (en) * 2018-05-30 2018-11-20 努比亚技术有限公司 Data processing method, device and computer readable storage medium
CN109032511A (en) * 2018-07-09 2018-12-18 武汉斗鱼网络科技有限公司 Data storage method, server and storage medium
CN109151074A (en) * 2018-10-29 2019-01-04 南京感度信息技术有限责任公司 Centralized buffer queue service architecture method and network structure based on Redis
CN111026379A (en) * 2019-12-06 2020-04-17 南京联创信息科技有限公司 High-availability method for Redis master-slave fragment cluster
CN113965582A (en) * 2020-07-20 2022-01-21 中移(苏州)软件技术有限公司 Mode conversion method and system, and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104199957A (en) * 2014-09-17 2014-12-10 合一网络技术(北京)有限公司 Redis universal agent implementation method
US20160232372A1 (en) * 2015-02-05 2016-08-11 Alibaba Group Holidng Limited System, method and database proxy server for separating operations of read and write

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104199957A (en) * 2014-09-17 2014-12-10 合一网络技术(北京)有限公司 Redis universal agent implementation method
US20160232372A1 (en) * 2015-02-05 2016-08-11 Alibaba Group Holidng Limited System, method and database proxy server for separating operations of read and write

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108846051A (en) * 2018-05-30 2018-11-20 努比亚技术有限公司 Data processing method, device and computer readable storage medium
CN109032511A (en) * 2018-07-09 2018-12-18 武汉斗鱼网络科技有限公司 Data storage method, server and storage medium
CN109032511B (en) * 2018-07-09 2022-05-13 武汉斗鱼网络科技有限公司 Data storage method, server and storage medium
CN109151074A (en) * 2018-10-29 2019-01-04 南京感度信息技术有限责任公司 Centralized buffer queue service architecture method and network structure based on Redis
CN109151074B (en) * 2018-10-29 2023-05-23 南京感度信息技术有限责任公司 Redis-based centralized cache queue service architecture method and network structure
CN111026379A (en) * 2019-12-06 2020-04-17 南京联创信息科技有限公司 High-availability method for Redis master-slave fragment cluster
CN113965582A (en) * 2020-07-20 2022-01-21 中移(苏州)软件技术有限公司 Mode conversion method and system, and storage medium
CN113965582B (en) * 2020-07-20 2024-04-09 中移(苏州)软件技术有限公司 Mode conversion method and system, and storage medium

Similar Documents

Publication Publication Date Title
CN108023932A (en) A kind of implementation method based on Redis general-purpose proxies, storage medium and electronic equipment
US11514076B2 (en) Cooperative naming for configuration items in a distributed configuration management database environment
CN109766330B (en) Data slicing method and device, electronic equipment and storage medium
CN107977396B (en) Method and device for updating data table of KeyValue database
CN102882974B (en) Method for saving website access resource by website identification version number
EP3780493A1 (en) Subscription processing method, network node, and user data repository
CN104199957A (en) Redis universal agent implementation method
US20180025049A1 (en) Server and Data Processing Method
CN111262726B (en) Configuration information updating method and device and computer readable storage medium
CN105677789A (en) Method and system for managing directory capacity of distributed file system
WO2019076236A1 (en) Data synchronization method and device, super controller, domain controller, and storage medium
CN105007317A (en) Data processing method for distributed nodes, and gateway equipment
CN109710223B (en) API gateway hot plug system based on distributed KV storage system
CN108768849A (en) Message processing method and device
CN111897643A (en) Thread pool configuration system, method, device and storage medium
CN110401709A (en) Processing method, device and the storage medium of session in a kind of instant messaging application
CN113076380B (en) Data synchronization method, device, system, equipment and storage medium
US20220247711A1 (en) Domain management and synchronization system
CN114866970A (en) Policy control method, system and related equipment
CN107273047A (en) A kind of buffer memory management method, cache manager and storage management software
CN110768855B (en) Method and device for testing linkmzation performance
CN103699616B (en) Data structure creation method, subscription message data sending method and relevant apparatus
CN113282384A (en) Cooperative office management method and device based on Internet and cooperative management platform
CN110389966B (en) Information processing method and device
CN111813880A (en) Method, system and storage medium for managing territorial space planning project

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: 20180511