当前位置:网站首页>Redis cluster configuration
Redis cluster configuration
2022-07-05 12:35:00 【just4you】
Create a cluster configuration
- redis edition :6.2.6
- With 6 individual redis,3 Lord 3 Take... For example .
Preparing for basic redis To configure
Create directory /opt/rediscluster, Replication based redis.conf This directory , And make changes
# close AOF function
appendonly no
Create a cluster profile
create a file :redis6379.conf, Add content :
include /opt/rediscluster/redis.conf
pidfile "/var/run/redis_6379.pid"
port 6379
dbfilename "dump6379.rdb"
# Turn on cluster mode
cluster-enabled yes
# Specify node file name
cluster-config-file nodes-6379.conf
# Specify the node timeout
cluster-node-timeout 15000
Copy redis6379.conf, Named as :
- redis6380.conf
- redis6381.conf
- redis6389.conf
- redis6390.conf
- redis6391.conf
Then modify the digital part of each document , Change the number to be the same as the number in the file name .
for example :redis6380.conf, Revised as follows :
include /opt/rediscluster/redis.conf
# modify 6379-> 6380
pidfile "/var/run/redis_6380.pid"
# modify 6379-> 6380
port 6380
# modify 6379-> 6380
dbfilename "dump6380.rdb"
# Turn on cluster mode
cluster-enabled yes
# Specify node file name
# modify 6379-> 6380
cluster-config-file nodes-6380.conf
# Specify the node timeout
cluster-node-timeout 15000
The same applies to other configuration files .
Open clusters
start-up 6 individual redis-server
redis-server /opt/rediscluster/redis6379.conf
redis-server /opt/rediscluster/redis6380.conf
redis-server /opt/rediscluster/redis6381.conf
redis-server /opt/rediscluster/redis6389.conf
redis-server /opt/rediscluster/redis6390.conf
redis-server /opt/rediscluster/redis6391.conf
After starting , View current directory , Confirm that the specified dump.rdb and nodes.conf file .
Batch close redis-server
ps -ef | grep -v grep | grep redis | awk -F' ' '{print $2}' | xargs kill -9
Create clusters
Get into redis Installation directory src Under the table of contents , perform :
redis-cli --cluster create --cluster-replicas 1 192.168.10.102:6379 192.168.10.102:6380 192.168.10.102:6381 192.168.10.102:6389 192.168.10.102:6390 192.168.10.102:6391
–cluster create: Create clusters
–cluster-relicas: Number of cluster copies . Here is 1, yes 1 host 1 Slave mode , If set to 2( namely :2 Slave machine ) Will fail . Because there must be at least 3 Host computer , So set 2 Slave machine hour , Need at least 9 Nodes .
The last parameter lists all redis host IP Address and port number .
After execution , System prompt :
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
# 6390 As 6379 Slave of
Adding replica 192.168.10.102:6390 to 192.168.10.102:6379
# 6391 As 6380 Slave of
Adding replica 192.168.10.102:6391 to 192.168.10.102:6380
# 6389 As 6381 Slave of
Adding replica 192.168.10.102:6389 to 192.168.10.102:6381
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 0e5eb18533395661e35ac4ebd5298f364e50ad04 192.168.10.102:6379
slots:[0-5460] (5461 slots) master
M: 9eda6134015f3b415df60e813613a7cf14cdd2df 192.168.10.102:6380
slots:[5461-10922] (5462 slots) master
M: 505b4fd96d38c68befe839257622cdcec1af35ca 192.168.10.102:6381
slots:[10923-16383] (5461 slots) master
S: 7d919f337875f7bafcddd3c79a8ae1510202d39d 192.168.10.102:6389
replicates 505b4fd96d38c68befe839257622cdcec1af35ca
S: b30918baa72b2aa7e564115e738f21145234b84c 192.168.10.102:6390
replicates 0e5eb18533395661e35ac4ebd5298f364e50ad04
S: a6f714fa624e02a72374f235d5562fc022b143e2 192.168.10.102:6391
replicates 9eda6134015f3b415df60e813613a7cf14cdd2df
Can I set the above configuration? (type 'yes' to accept):
Input "yes" Can be confirmed .
Access cluster
redis-cli -c -p 6379
1: -c : Cluster pattern
2:-p : Any one of the clusters redis The port number of the service
After logging into the cluster , You can use :cluster nodes Command to view the cluster status , The query results are as follows :
# 6390 yes slave, Corresponding master yes 6379
b30918baa72b2aa7e564115e738f21145234b84c 192.168.10.102:[email protected] slave 0e5eb18533395661e35ac4ebd5298f364e50ad04 0 1640854465249 1 connected
# 6391 yes slave, Corresponding master yes 6380
a6f714fa624e02a72374f235d5562fc022b143e2 192.168.10.102:[email protected] slave 9eda6134015f3b415df60e813613a7cf14cdd2df 0 1640854465000 2 connected
# master, This is the currently logged in redis, Yes myself Mark , 0-5460 yes slot Number
0e5eb18533395661e35ac4ebd5298f364e50ad04 192.168.10.102:[email protected] myself,master - 0 1640854462000 1 connected 0-5460
# master, 5461-10922 yes slot Number
9eda6134015f3b415df60e813613a7cf14cdd2df 192.168.10.102:[email protected] master - 0 1640854467291 2 connected 5461-10922
# 6389 yes slave, Corresponding master yes 6381
7d919f337875f7bafcddd3c79a8ae1510202d39d 192.168.10.102:[email protected] slave 505b4fd96d38c68befe839257622cdcec1af35ca 0 1640854463201 3 connected
# master, 10923-16383 yes slot Number
505b4fd96d38c68befe839257622cdcec1af35ca 192.168.10.102:[email protected] master - 0 1640854466271 3 connected 10923-16383
边栏推荐
- MySQL storage engine
- How can beginners learn flutter efficiently?
- One article tells the latest and complete learning materials of flutter
- Experimental design - using stack to realize calculator
- Swift - add navigation bar
- ZABBIX customized monitoring disk IO performance
- GPON other manufacturers' configuration process analysis
- Acid transaction theory
- Master-slave mode of redis cluster
- Keras implements verification code identification
猜你喜欢

MySQL splits strings for conditional queries

July Huaqing learning-1

Matlab label2idx function (convert the label matrix into a cell array with linear index)

Implementing Yang Hui triangle with cyclic queue C language

C language structure is initialized as a function parameter
![[figure neural network] GNN from entry to mastery](/img/e2/bb045fb03bc255b8659f9ca7cdd26b.jpg)
[figure neural network] GNN from entry to mastery

Solve the problem of cache and database double write data consistency

NPM install reports an error

What is digital existence? Digital transformation starts with digital existence

ZABBIX ODBC database monitoring
随机推荐
The evolution of mobile cross platform technology
Pytoch monolayer bidirectional_ LSTM implements MNIST and fashionmnist data classification
Semantic segmentation experiment: UNET network /msrc2 dataset
Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
Constructing expression binary tree with prefix expression
Get the variable address of structure member in C language
Read and understand the rendering mechanism and principle of flutter's three trees
JDBC -- use JDBC connection to operate MySQL database
Learn JVM garbage collection 02 - a brief introduction to the reference and recycling method area
Automated test lifecycle
MySQL constraints
ZABBIX customized monitoring disk IO performance
什么是数字化存在?数字化转型要先从数字化存在开始
Distributed solution - completely solve website cross domain requests
【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
Redis clean cache
Interviewer: is acid fully guaranteed for redis transactions?
Learn the memory management of JVM 03 - Method area and meta space of JVM
Solve the error 1045 of Navicat creating local connection -access denied for user [email protected] (using password
只是巧合?苹果 iOS16 的神秘技术竟然与中国企业 5 年前产品一致!