当前位置:网站首页>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 .
边栏推荐
- MySQL installation, Windows version
- ZABBIX monitors mongodb (template and deployment operations)
- PXE startup configuration and principle
- Pytoch monolayer bidirectional_ LSTM implements MNIST and fashionmnist data classification
- ZABBIX monitors mongodb templates and configuration operations
- [figure neural network] GNN from entry to mastery
- Handwriting blocking queue: condition + lock
- Video networkstate property
- Pytoch loads the initialization V3 pre training model and reports an error
- IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
猜你喜欢
Resnet+attention project complete code learning
JDBC -- extract JDBC tool classes
Storage Basics
The relationship between the size change of characteristic graph and various parameters before and after DL convolution operation
Preliminary exploration of basic knowledge of MySQL
Redis clean cache
Detailed steps for upgrading window mysql5.5 to 5.7.36
Take you two minutes to quickly master the route and navigation of flutter
ZABBIX customized monitoring disk IO performance
July Huaqing learning-1
随机推荐
MySQL regular expression
Semantic segmentation experiment: UNET network /msrc2 dataset
Deep discussion on the decoding of sent protocol
嵌入式软件架构设计-消息交互
Seven ways to achieve vertical centering
GPS data format conversion [easy to understand]
Solve the error 1045 of Navicat creating local connection -access denied for user [email protected] (using password
MySQL log module of InnoDB engine
16 channel water lamp experiment based on Proteus (assembly language)
Basic operations of MySQL data table, addition, deletion and modification & DML
Distributed solution - Comprehensive decryption of distributed task scheduling platform -xxljob
MySQL stored procedure
MySQL data table operation DDL & data type
Solve the problem of cache and database double write data consistency
Pytoch through datasets Imagefolder loads datasets directly from files
Array cyclic shift problem
Pytoch implements tf Functions of the gather() function
Interviewer: is acid fully guaranteed for redis transactions?
Distributed solution - distributed lock solution - redis based distributed lock implementation
Instance + source code = see through 128 traps