当前位置:网站首页>Redis master-slave configuration and sentinel mode
Redis master-slave configuration and sentinel mode
2022-07-05 12:36:00 【just4you】
Master slave configuration
- redis edition :6.2.6
- With 1 Console host ,2 Take a slave as an example .
Preparing for basic redis To configure
Create directory /opt/myredis, Replication based redis.conf This directory , And make changes .
# close AOF function
appendonly no
Configure host information
New file :redis6379.conf, Add content
# Appoint include In the current directory redis.conf
include /opt/myredis/redis.conf
pidfile /var/run/redis_6379.pid
port 6379
dbfilename dump6379.rdb
To configure 2 Slave information
create a file :redis6380.conf, Add content
include /opt/myredis/redis.conf
pidfile "/var/run/redis_6380.pid"
port 6380
dbfilename "dump6380.rdb"
create a file :redis6381.conf, Add content
include /opt/myredis/redis.conf
pidfile "/var/run/redis_6381.pid"
port 6381
dbfilename "dump6381.rdb"
Start three redis
redis-server /opt/myredis/redis6379.conf
redis-server /opt/myredis/redis6380.conf
redis-server /opt/myredis/redis6381.conf
Batch close redis-server
ps -ef | grep -v grep | grep redis | awk -F' ' '{print $2}' | xargs kill -9
Check the status
First connect to redis
redis-cli -p 6379
-p: Specify to connect to redis Which port of
stay redis-cli Use the command to view the status
info replication
Connect to 3 individual redis System , Check the status separately , You can see that every redis-server Of role All are master.
Set the slave as the master slave
stay 6380 and 6381 Of redis Execute commands respectively in , take 6379 Port of redis Set to master.
slaveof 127.0.0.1 6379
# When you are no longer a slave , Use command
slaveof no one
Review status
Re execute on the client of each port :info replication command
- You can see 6379 Port of redis Still master, There are two slave.
- 6380 and 6380 Port of redis Of role Turn into slave.
Sentinel mode sentinel
To configure
stay /opt/myredis Create document under :sentinel.conf, And add content
daemonize yes
# Sentinel port , Default 26379
# port 7505
# Log files
logfile "./sentinel.log"
# sentinel monitor Primary node alias Master node IP port Number of sentinels ( Several sentinels monitor that the master node is down and perform the transfer )
sentinel monitor mymaster 192.168.10.102 6379 1
# sentry 3s The heartbeat of the master node is not received in , It is considered that the primary node is down , Default 30 second
sentinel down-after-milliseconds mymaster 3000
# After electing a new master node , The number of slave nodes that can be connected at the same time
# sentinel parallel-syncs mymaster 1
# If 10 Seconds later ,master Still not alive , Start up failover, Default 180s
# sentinel failover-timeout mymaster 10000
# Connect redis Master password
# sentinel auth-pass mymaster 123456
start-up
Carry out orders
redis-sentinel /opt/myredis/sentinel.conf
You can see the response output information ,sentinel Default port 26379.
here , Try turning it off 6379 Port of redis after , You can see sentinel Log output , And elect a new host .
边栏推荐
- Kotlin函数
- Learn JVM garbage collection 02 - a brief introduction to the reference and recycling method area
- A new WiFi option for smart home -- the application of simplewifi in wireless smart home
- End to end neural network
- Array cyclic shift problem
- Cypher syntax of neo4j graph database
- The relationship between the size change of characteristic graph and various parameters before and after DL convolution operation
- Acid transaction theory
- Read and understand the rendering mechanism and principle of flutter's three trees
- mysql拆分字符串做条件查询
猜你喜欢
Knowledge representation (KR)
JDBC -- extract JDBC tool classes
MySQL transaction
强化学习-学习笔记3 | 策略学习
Redis's memory elimination mechanism, read this article is enough.
Distributed cache architecture - cache avalanche & penetration & hit rate
Two minutes will take you to quickly master the project structure, resources, dependencies and localization of flutter
Pytoch loads the initialization V3 pre training model and reports an error
Learn memory management of JVM 01 - first memory
Principle of universal gbase high availability synchronization tool in Nanjing University
随机推荐
Distributed solution - Comprehensive decryption of distributed task scheduling platform -xxljob
嵌入式软件架构设计-消息交互
Summary of C language learning problems (VS)
MySQL stored procedure
Pytoch monolayer bidirectional_ LSTM implements MNIST and fashionmnist data classification
Swift - enables textview to be highly adaptive
One article tells the latest and complete learning materials of flutter
Detailed structure and code of inception V3
Pytorch two-layer loop to realize the segmentation of large pictures
ZABBIX agent2 monitors mongodb templates and configuration operations
PIP command reports an error pip is configured with locations that requires tls/ssl problems
Solve the problem of cache and database double write data consistency
Understand kotlin from the perspective of an architect
MySQL transaction
Average lookup length when hash table lookup fails
MySQL constraints
Get the variable address of structure member in C language
ZABBIX 5.0 - LNMP environment compilation and installation
UNIX socket advanced learning diary - advanced i/o functions
Matlab label2idx function (convert the label matrix into a cell array with linear index)