Redis Deployment Master-Slave Sentinel C # used to automate the acquisition of Redis cache instances 1

Source: Internet
Author: User
Tags redis server

Source code Sample Download
Link: https://pan.baidu.com/s/1eTA63T4 Password: un96

Achieve the goal:
One Master service under Windows installs one Salve Redis server and Sentinel mode monitoring for master-slave switching
Deploy one Sentinel Sentinel on two servers at a time

Windows https://github.com/MicrosoftArchive/redis/releases

A 10.55.8.110 B 10.55.8.111 two windows servers

1, first download the Windows version of Redis and decompression (no Windows version of the official website)
A B server A copy of the previous parties

#修改A服务器上面的redis. windows.conf file
Port 6379
Bind 10.55.8.110

#日志存放
LogFile "C:/users/administrator/desktop/redis/redis-6379.log"
#数据库存放
Dir "C:\\users\\administrator\\desktop\\redis"

Password required for #client connection
Requirepass abc12345!

#slave服务器连接需要的密码
Masterauth abc12345!
AppendOnly Yes
MaxMemory 8GB

Modify the redis.windows.conf file on Server B
Port 6379
Bind 10.55.8.111
LogFile "C:/users/administrator/desktop/redis/redis-6379.log"
Dir "C:\\users\\administrator\\desktop\\redis"
Requirepass abc12345!
Masterauth abc12345!
AppendOnly Yes
#连接到主服务器
Slaveof 10.55.8.110 6379

#slave Read-only
Slave-read-only Yes

MaxMemory 8GB


Create two 26379 folders on #A B server
#创建 the sentinel.conf configuration file and configure the following
Port 26379

#master01

Daemonize Yes
Sentinel Monitor Master01 10.55.8.110 6379 1

#sentinel认定为master失效的时间
Sentinel Down-after-milliseconds Master01 30000

Sentinel Auth-pass Master01 abc12345!

Sentinel Config-epoch Master01 3

Dir "c:\\users\\administrator\\desktop\\redis\\26379"
LogFile "C:/users/administrator/desktop/redis/26379/sentinel-26379.log"


Commands commonly used in the process
Server Redis-server.exe redis.windows.conf start up servers
Client redis-cli.exe-h 127.0.0.1-p 6379 start clients
Redis-server.exe c:\redis\26379\sentinel.conf--sentinel Launch Sentry
Info replication View master and slave device status


Install as a service
Redis-server.exe--service-install--service-name redis6379service redis.windows.conf//Installation
Redis-server--service-start--service-name redis6379service//start
Redis-server--service-stop--service-name redis6379service redis.windows.conf/Stop
Redis-server.exe--service-uninstall--service-name redis6379service redis.windows.conf//Unload

Summary and Pits:
1. Learn about the basic configuration of Redis (https://www.cnblogs.com/qq78292959/archive/2013/09/21/3331032.html)
2, the entire configuration process note two servers interoperability
3, configuration files such as add slaveof 10.55.8.110 6379 need to remove the space in front of the slaveof
Or Redis won't recognize it.
4, password verification to note, otherwise it will not be able to pass

In addition, when the host A is dropped, Sentinel monitoring will automatically switch to B, B becomes master.
Sentinel profile automatically changes to monitor B

However, after a restarts, it cannot be changed back to master, and the default becomes a subordinate of B.
Want to change a to primary server execution
Redis-cli.exe-h 10.55.8.110-p 26379
Sentinel Failover Master01

Redis Deployment Master-Slave Sentinel C # used to automate the acquisition of Redis cache instances 1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.