CN109753244A - A kind of application method of Redis cluster - Google Patents
A kind of application method of Redis cluster Download PDFInfo
- Publication number
- CN109753244A CN109753244A CN201811638767.1A CN201811638767A CN109753244A CN 109753244 A CN109753244 A CN 109753244A CN 201811638767 A CN201811638767 A CN 201811638767A CN 109753244 A CN109753244 A CN 109753244A
- Authority
- CN
- China
- Prior art keywords
- redis
- service instance
- inquiry request
- cluster
- redis service
- 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
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention provides a kind of application methods of Redis cluster, comprising: Redis cluster is disposed in Docker;Redis cluster is configured, so that each Redis Service Instance in Redis cluster respectively corresponds the slot of the preset quantity in bond space;Predefine Redis Service Instance corresponding to various inquiry requests;Any one the Redis Service Instance of client into Redis cluster sends inquiry request, and inquiry request mark is provided in the prefix of the key of inquiry request;When Redis Service Instance receives the inquiry request of client transmission, corresponding Redis Service Instance is determined according to the inquiry request mark in the prefix of key;The inquiry request is handled by identified Redis Service Instance.The problems such as using the linear expansion of High Availabitity, load balancing and the memory capacity of the invention that can solve buffer service and performance.
Description
Technical field
This application involves Redis caching technology field more particularly to a kind of application methods of Redis cluster.
Background technique
Currently, user volume increases sharply with the fast development of business event, new choose is proposed to web site performance
War.Become a solution for improving system performance using Redis caching.
However, facing a series of problems to be solved using Redis caching.For example, if Redis server delay machine why
Do? if enterprise there are many websites, if a Redis service is disposed in each website, the wasting of resources will cause.Redis
It being deployed on single server, the memory and cpu resource of single server are limited, and single thread technology is used inside Redis,
Therefore, it is difficult to carry out linear expansion to Redis memory capacity and performance.
Summary of the invention
In view of this, the present invention provides a kind of application method of Redis cluster, so as to solve the height of buffer service
Can use, the linear expansion of load balancing and memory capacity and performance the problems such as.
Technical solution of the present invention is specifically achieved in that
A kind of application method of Redis cluster, this method comprises:
Multiple Redis Service Instances are disposed in Docker, form Redis cluster;
Redis cluster is configured, so that each Redis Service Instance in Redis cluster respectively corresponds bond space
In preset quantity slot;
Predefine Redis Service Instance corresponding to various inquiry requests;
Any one the Redis Service Instance of client into Redis cluster sends inquiry request, the inquiry request
Corresponding inquiry request mark is provided in the prefix of key;
When Redis Service Instance receives the inquiry request of client transmission, according in the prefix of the key of inquiry request
Inquiry request mark determines corresponding Redis Service Instance;
The inquiry request is handled by identified Redis Service Instance.
Preferably, each Redis Service Instance is disposed by Docker container.
Preferably, when disposing multiple Redis Service Instances in Docker, it can be by the Redis Service Instance of preset quantity
It is set as host node, M Redis Service Instance then is set for each host node again and is used as from node;Wherein, M is nature
Number.
Preferably, Redis cluster is automatically configured using script, so that each Redis Service Instance in Redis cluster point
The slot of the preset quantity in bond space is not corresponded to.
The inquiry request is handled by identified Redis Service Instance include: preferably, described
When identified Redis Service Instance is to receive the Redis Service Instance of the inquiry request, by the Redis
The Service Instance processing inquiry request;Otherwise, which sends out the information of identified Redis Service Instance
Client is given, the client sends identified Redis Service Instance for inquiry request according to the information received.
Preferably, described dispose multiple Redis Service Instances in Docker, composition Redis cluster includes:
Create file;
Dispose each multiple Redis Service Instances;
Dispose cluster.
As above multiple due to being disposed in Docker as it can be seen that in the application method of Redis cluster in the present invention
After Redis Service Instance forms Redis cluster, each Redis Service Instance in Redis cluster is respectively corresponded into bond space
In preset quantity slot, subregion has been carried out to bond space to be equivalent to.The division operation can make Redis Service Instance pipe
Manage bigger memory so that each Redis Service Instance can use all machines memory (and if without subregion,
Then each Redis Service Instance can only at most use the memory of a machine) so that the calculating energy of Redis Service Instance
Power can be promoted at double simply by increasing the quantity of computer, and the network bandwidth of Redis Service Instance can also be with
It is doubled and redoubled as the quantity of computer and network interface card increases, thus the High Availabitity of buffer service, load can be efficiently solved
The problems such as linear expansion of balanced and memory capacity and performance.
In addition, in the inventive solutions, client can be direct with the Redis Service Instance in Redis cluster
Connection, without passing through intermediate proxy layers.Moreover, client does not need to connect with all nodes in Redis cluster,
And it need to only be connect with the available Redis Service Instance of any one of Redis cluster;Client can freely to
Any one Redis Service Instance (including from node) in Redis cluster sends inquiry request, without what is fixed to some
Redis Service Instance sends inquiry request, when some or the multiple Redis Service Instances in Redis cluster break down,
Inquiry operation can be carried out by remaining on.When the fail of node fails only in Redis cluster more than the nodal test of half
It comes into force.
Detailed description of the invention
Fig. 1 is the flow chart of the application method of the Redis cluster in the embodiment of the present invention.
Fig. 2 is the schematic diagram of the Redis cluster in the embodiment of the present invention.
Specific embodiment
For technical solution of the present invention and advantage is more clearly understood, below in conjunction with drawings and the specific embodiments, to this
Invention is described in further detail.
Fig. 1 is the flow chart of the application method of the Redis cluster in the embodiment of the present invention.
As shown in Figure 1, the application method of the Redis cluster in the embodiment of the present invention includes step as described below:
Step 11, multiple Redis Service Instances are disposed in Docker, form Redis cluster.
In the inventive solutions, multiple Redis Service Instances can be disposed, in Docker in advance to form
Redis cluster.
Wherein, Docker is a kind of application container engine of open source, and Redis is a kind of open source, using ANSI C language
Write, support network, it is memory-based also can persistence log type, Key-Value database.
In addition, preferably, in one particular embodiment of the present invention, each Redis Service Instance can pass through
Docker container is disposed.It is disposed by Docker container, can make deployment more rapidly and reusable.
Therefore, in the inventive solutions, the Redis cluster is a reticular structure, each node (Redis
Service Instance) all by TCP connection with other each node connections (for example, PING-PONG mechanism).Further, Redis
Cluster internal can also use binary protocol as communication protocol, so as to optimize transmission speed and bandwidth.
Therefore, in the Redis cluster for having N number of node at one, each node has the TCP connection of (N-1) a outflow, and
(N-1) connection that a TCP flow enters.These TCP connections meeting permanent retention, is not to create on demand.
In addition, it is further, in a preferable specific embodiment of the invention, disposed in Docker multiple
When Redis Service Instance, host node (Master) can be set by the Redis Service Instance of preset quantity, then again be every
One host node is arranged M Redis Service Instance and is used as from node (Slave).Wherein, M is natural number.
For example, as shown in Fig. 2, multiple Master can be arranged in Redis cluster (for example, Master-1, Master-
2, Master-3 ..., N number of Master such as Master-N), then for each Master be arranged a Slave (for example,
Slave-1, Slave-2, Slave-3 ..., N number of Slave such as Slave-N).
It is being the default one or more of a host node after node, then can failing in network outage or host node
When, host node is replaced using from node.This leader follower replication model will be so that in part of nodes failure or most of section
In the case that point can not communicate, the Redis cluster is still available.
In the inventive solutions, the quantity of host node can be preset according to the needs of practical situations
And the value of M, details are not described herein.
Step 12, Redis cluster is configured, so that each Redis Service Instance in Redis cluster respectively corresponds
The slot (slot) of preset quantity in bond space.
Since bond space can be divided into 16384 slots (slot), the maximum node quantity of a cluster is
16384.So in the inventive solutions, can be configured to Redis cluster, so that each in Redis cluster
A Redis Service Instance respectively corresponds the slot of the preset quantity in bond space.
For example, preferably, script can be used and automatically configure Redis cluster, make in a specific embodiment of the invention
Obtain the slot that each Redis Service Instance in Redis cluster respectively corresponds the preset quantity in bond space.Therefore, Redis collection
Each Redis Service Instance in group is responsible for a part in 16384 Hash slots.When Redis cluster is in stable state
When, reconfiguration operation is not being executed in Redis cluster, and each Hash slot is only handled by a node.
Step 13, Redis Service Instance corresponding to various inquiry requests is predefined.
In the inventive solutions, Redis Service Instance corresponding to various inquiry requests can also be predefined.
Step 14, any one the Redis Service Instance of client into Redis cluster sends inquiry request, described to look into
It askes and is provided with corresponding inquiry request mark in the prefix of the key of request.
Step 15, when Redis Service Instance receives the inquiry request of client transmission, according to the key's of inquiry request
Inquiry request mark in prefix determines corresponding Redis Service Instance.
In addition, preferably, in one particular embodiment of the present invention, can also determine corresponding Redis service
Before example, determine whether the inquiry request is inquiry that Redis cluster can execute.If the inquiry request is the Redis
(being exactly to pertain only to a key in inquiry) that cluster can execute, further according to the inquiry request in the prefix of the key of inquiry request
Mark determines corresponding Redis Service Instance.
Step 16, the inquiry request is handled by identified Redis Service Instance.
It, in this step, can be by identified after corresponding Redis Service Instance has been determined in step 15
Redis Service Instance handles the inquiry request.
For example, preferably, in a specific embodiment of the invention, when identified Redis Service Instance is reception institute
When stating the Redis Service Instance of inquiry request, the inquiry request is handled by the Redis Service Instance;Otherwise, which takes
The information of identified Redis Service Instance is sent to client (for example, returning to a MOVED mistake to client by pragmatic example
Accidentally, the information such as the IP address and port numbers of Redis Service Instance determined by being carried in the MOVED mistake), the client
Identified Redis Service Instance is sent by inquiry request according to the information received.
In addition, in the inventive solutions, can realize above-mentioned step 11 in several ways.It below will be with
Technical solution of the present invention is described in detail for one such specific implementation.
For example, preferably, in one particular embodiment of the present invention, the step 11 may include following step:
Step 111, file is created.
In the inventive solutions, can create first corresponding each port file (for example, can first/
The file of corresponding each port is created in data/redis catalogue).
For example, relevant specific implementation can be as follows:
The file of the corresponding each port of creation first in/data/redis catalogue, here is script:
Addition executes permission and executes:
chmod 777create.sh
./create.sh
By the above-mentioned means, file can be created.
Step 112, each multiple Redis Service Instances are disposed.
For example, relevant specific implementation can be as follows:
Create docker-compose.yml:
Start all redis
docker-compose up-d
By the above-mentioned means, each multiple Redis Service Instances can be disposed.
Step 113, cluster (cluster) is disposed.
For example, relevant specific implementation can be as follows:
Operation is to issue orders:
Note: plus-it, not so subsequent confirmation cannot continue
docker run--rm-it inem0o/redis-trib create--replicas 1 192.168.30.70:
7001 192.168.30.70:7002 192.168.30.70:7003 192.168.30.70:7004 192.168.30.70:
7005 192.168.30.70:7006
It will appear:
Input yes carriage return:
Deployment is completed.
By the above-mentioned means, cluster can be disposed.
Through the above steps 111~113, multiple Redis Service Instances can be disposed in Docker, form Redis
Cluster.
In conclusion in the inventive solutions, due to disposing multiple Redis Service Instance compositions in Docker
After Redis cluster, each Redis Service Instance in Redis cluster is respectively corresponded to the slot of the preset quantity in bond space,
Subregion has been carried out to bond space to be equivalent to.The division operation can make Redis Service Instance manage bigger memory, so that
Each Redis Service Instance can use the memories of all machines, and (and if without subregion, each Redis service is real
Example can only at most use the memory of a machine) so that the computing capability of Redis Service Instance can be simply by increasing
Add the quantity of computer and promoted at double, the network bandwidth of Redis Service Instance can also be with computer and network interface card
Quantity increase and be doubled and redoubled, thus can efficiently solve buffer service High Availabitity, load balancing and memory capacity and
The problems such as linear expansion of performance.
In addition, in the inventive solutions, client can be direct with the Redis Service Instance in Redis cluster
Connection, without passing through intermediate proxy layers.Moreover, client does not need to connect with all nodes in Redis cluster,
And it need to only be connect with the available Redis Service Instance of any one of Redis cluster;Client can freely to
Any one Redis Service Instance (including from node) in Redis cluster sends inquiry request, without what is fixed to some
Redis Service Instance sends inquiry request, when some or the multiple Redis Service Instances in Redis cluster break down,
Inquiry operation can be carried out by remaining on.When the fail of node fails only in Redis cluster more than the nodal test of half
It comes into force.
In addition, it is further, it can also be the default one or more of a host node in the inventive solutions
From node, and host node can be replaced using from node when network outage or host node fail.This leader follower replication
Model, each node can have N-1 duplicate, so that can not be communicated in part of nodes failure or most of node
In the case of, the Redis cluster is still available.
In addition, being reachable in most of host node, and at least for each inaccessible host node
One it slave node up in the case where, Redis cluster can still provide for division operation.
In addition, technical solution of the present invention additionally provides the solution that multiple systems access the key conflict of the same Redis cluster
Certainly method.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention
Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the present invention.
Claims (6)
1. a kind of application method of Redis cluster, which is characterized in that this method comprises:
Multiple Redis Service Instances are disposed in Docker, form Redis cluster;
Redis cluster is configured, so that each Redis Service Instance in Redis cluster respectively corresponds in bond space
The slot of preset quantity;
Predefine Redis Service Instance corresponding to various inquiry requests;
Any one the Redis Service Instance of client into Redis cluster sends inquiry request, the key of the inquiry request
Prefix in be provided with corresponding inquiry request mark;
When Redis Service Instance receives the inquiry request of client transmission, according to the inquiry in the prefix of the key of inquiry request
Request mark determines corresponding Redis Service Instance;
The inquiry request is handled by identified Redis Service Instance.
2. according to the method described in claim 1, it is characterized by:
Each Redis Service Instance is disposed by Docker container.
3. according to the method described in claim 2, it is characterized by:
When disposing multiple Redis Service Instances in Docker, can by the Redis Service Instance of preset quantity be arranged based on save
Then point is arranged M Redis Service Instance again for each host node and is used as from node;Wherein, M is natural number.
4. according to the method described in claim 1, it is characterized by:
Redis cluster is automatically configured using script, so that each Redis Service Instance in Redis cluster respectively corresponds key sky
Between in preset quantity slot.
5. the method according to claim 1, wherein it is described by identified Redis Service Instance to handle
Stating inquiry request includes:
When identified Redis Service Instance is to receive the Redis Service Instance of the inquiry request, serviced by the Redis
Inquiry request described in instance processes;Otherwise, which is sent to the information of identified Redis Service Instance
Client, the client send identified Redis Service Instance for inquiry request according to the information received.
6. the method according to claim 1, wherein described dispose multiple Redis Service Instances in Docker,
Forming Redis cluster includes:
Create file;
Dispose each multiple Redis Service Instances;
Dispose cluster.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811638767.1A CN109753244A (en) | 2018-12-29 | 2018-12-29 | A kind of application method of Redis cluster |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811638767.1A CN109753244A (en) | 2018-12-29 | 2018-12-29 | A kind of application method of Redis cluster |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109753244A true CN109753244A (en) | 2019-05-14 |
Family
ID=66404458
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811638767.1A Pending CN109753244A (en) | 2018-12-29 | 2018-12-29 | A kind of application method of Redis cluster |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109753244A (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110597772A (en) * | 2019-08-21 | 2019-12-20 | 福建天泉教育科技有限公司 | Multi-instance file processing method and terminal |
CN111212145A (en) * | 2020-01-09 | 2020-05-29 | 国网福建省电力有限公司 | Redis cluster for power supply service command system |
CN112416847A (en) * | 2020-04-15 | 2021-02-26 | 上海哔哩哔哩科技有限公司 | Redis cluster creating method, system and device |
CN112579650A (en) * | 2020-12-25 | 2021-03-30 | 恩亿科(北京)数据科技有限公司 | Data processing method and system based on Redis cache |
CN114969149A (en) * | 2022-05-06 | 2022-08-30 | 北京偶数科技有限公司 | Data resource processing method and device and storage medium |
CN116521688A (en) * | 2023-07-04 | 2023-08-01 | 浩鲸云计算科技股份有限公司 | Key prefix operation KEY value method based on Redis cluster |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105159985A (en) * | 2015-08-31 | 2015-12-16 | 努比亚技术有限公司 | Data query device and method based on redis cluster |
CN105357296A (en) * | 2015-10-30 | 2016-02-24 | 河海大学 | Elastic caching system based on Docker cloud platform |
CN106375425A (en) * | 2016-08-30 | 2017-02-01 | 中国民生银行股份有限公司 | Processing method and device for distributed caching |
CN106506605A (en) * | 2016-10-14 | 2017-03-15 | 华南理工大学 | A kind of SaaS application construction methods based on micro services framework |
CN107800551A (en) * | 2016-08-31 | 2018-03-13 | 北京优朋普乐科技有限公司 | Redis group systems and its method, the client for improving reliability |
CN108416039A (en) * | 2018-03-14 | 2018-08-17 | 北京思特奇信息技术股份有限公司 | A kind of data query method and system |
CN109062660A (en) * | 2018-07-06 | 2018-12-21 | 杭州涂鸦信息技术有限公司 | A kind of method of the offline application service of Docker Environmental security |
-
2018
- 2018-12-29 CN CN201811638767.1A patent/CN109753244A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105159985A (en) * | 2015-08-31 | 2015-12-16 | 努比亚技术有限公司 | Data query device and method based on redis cluster |
CN105357296A (en) * | 2015-10-30 | 2016-02-24 | 河海大学 | Elastic caching system based on Docker cloud platform |
CN106375425A (en) * | 2016-08-30 | 2017-02-01 | 中国民生银行股份有限公司 | Processing method and device for distributed caching |
CN107800551A (en) * | 2016-08-31 | 2018-03-13 | 北京优朋普乐科技有限公司 | Redis group systems and its method, the client for improving reliability |
CN106506605A (en) * | 2016-10-14 | 2017-03-15 | 华南理工大学 | A kind of SaaS application construction methods based on micro services framework |
CN108416039A (en) * | 2018-03-14 | 2018-08-17 | 北京思特奇信息技术股份有限公司 | A kind of data query method and system |
CN109062660A (en) * | 2018-07-06 | 2018-12-21 | 杭州涂鸦信息技术有限公司 | A kind of method of the offline application service of Docker Environmental security |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110597772A (en) * | 2019-08-21 | 2019-12-20 | 福建天泉教育科技有限公司 | Multi-instance file processing method and terminal |
CN111212145A (en) * | 2020-01-09 | 2020-05-29 | 国网福建省电力有限公司 | Redis cluster for power supply service command system |
CN112416847A (en) * | 2020-04-15 | 2021-02-26 | 上海哔哩哔哩科技有限公司 | Redis cluster creating method, system and device |
CN112416847B (en) * | 2020-04-15 | 2023-05-02 | 上海哔哩哔哩科技有限公司 | Redis cluster creation method, system and device |
CN112579650A (en) * | 2020-12-25 | 2021-03-30 | 恩亿科(北京)数据科技有限公司 | Data processing method and system based on Redis cache |
CN114969149A (en) * | 2022-05-06 | 2022-08-30 | 北京偶数科技有限公司 | Data resource processing method and device and storage medium |
CN114969149B (en) * | 2022-05-06 | 2024-04-30 | 北京偶数科技有限公司 | Data resource processing method, device and storage medium |
CN116521688A (en) * | 2023-07-04 | 2023-08-01 | 浩鲸云计算科技股份有限公司 | Key prefix operation KEY value method based on Redis cluster |
CN116521688B (en) * | 2023-07-04 | 2023-09-26 | 浩鲸云计算科技股份有限公司 | Key prefix operation KEY value method based on Redis cluster |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109753244A (en) | A kind of application method of Redis cluster | |
US11789925B2 (en) | System and method for conditionally updating an item with attribute granularity | |
US20210103604A1 (en) | System and method for implementing a scalable data storage service | |
US20230400990A1 (en) | System and method for performing live partitioning in a data store | |
JP2018088293A (en) | Database system providing single tenant environment and a plurality of tenant environments | |
US8819027B1 (en) | System and method for partitioning and indexing table data using a composite primary key | |
US11609697B2 (en) | System and method for providing a committed throughput level in a data store | |
US8930409B2 (en) | System and method for supporting named operations in a distributed data grid | |
CN101576915B (en) | Distributed B+ tree index system and building method | |
US8548976B2 (en) | Balancing load requests and failovers using a UDDI proxy | |
CN105025053A (en) | Distributed file upload method based on cloud storage technology and system | |
US10860604B1 (en) | Scalable tracking for database udpates according to a secondary index | |
CN108881066A (en) | A kind of method of route requests, access server and storage equipment | |
US8930518B2 (en) | Processing of write requests in application server clusters | |
US20080270483A1 (en) | Storage Management System | |
CN113127526A (en) | Distributed data storage and retrieval system based on Kubernetes | |
CN101483668A (en) | Network storage and access method, device and system for hot spot data | |
Jiang et al. | A novel clustered MongoDB-based storage system for unstructured data with high availability | |
CN111294383B (en) | Internet of things service management system | |
CN114338720A (en) | Distributed file storage and transmission method, system and storage medium | |
US20210173878A1 (en) | Systems and methods of incremented aggregated data retrieval | |
Aashabegum et al. | Formation of Single and Multinode Clusters in Hadoop Distributed File System | |
CN114546580A (en) | Cache deployment system, cache deployment method, electronic device and storage medium | |
CN116260853A (en) | Connection management method and device for node equipment and storage medium | |
Raith | MySQL Cluster–Evaluation and Tests |
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 |
Application publication date: 20190514 |
|
RJ01 | Rejection of invention patent application after publication |