Get the App
SLTechnology News&Howtos  ›  Database  › 

Explanation on redis read-write Separation and Sentinel Mechanism configuration

Shulou Source: shulou.com Published: 2022-06-01 21:39:37 10月02日 Update

Today, Xiaobian shared with you the explanation of redis read-write separation and sentinel mechanism configuration. Many people don't know much about it. In order to let you know more about redis read-write separation and sentinel mechanism configuration, Xiaobian summarized the following contents for you. Let's look down together. I'm sure you'll find something.

First, in/etc/redis/use the command cp redis.conf /redis63791.conf, cp redis.conf /redis63792.conf , cp redis.conf /redis63793.conf to prepare the root directory

vim redis63792.conf ---> modify the configuration file daemonize yes daemon port 63792 bind 192.168.0.3 bind intranet addresses databases 16 open 16 databases save ---> save every number of files (the owner does not need the following)slaveof 116.196.107.20 63791 --> master auth '123456789' --> authenticate the owner password----------------appendonly yes turn on security for this enhanced data (The above is the configuration file in the normal redis.conf, all slaves have to connect to the master server, can only read, can not write, automatic synchronization of data, read and write separation can greatly enhance the performance of the server, because in normal data operations, read often more than write, in general, the master and slave machine by 1:3 allocation)

Second, the sentinel configuration, find the sentinel.conf file in/etc/redis,(if you do not find such a configuration file), copy cp sentinel.conf /mysentinel.conf

vim mysentinel.confsentinel monitor mymaster 116.196.107.20 63791 1--> respectively means sentinel monitoring master:116.196.107.20 port:63791 sentinel number 1, under normal circumstances, the more the number of sentinels, the smaller the probability of voting through the election, the more time it takes to vote for a new master, not conducive to rapid switching master-slave mechanism sentinel down-after-milliseconds mymaster 5000 host dropped 5 s after authentication, if unable to connect, then re-selected from the slave by sentinel auth-mymaster 123456789 sentinel password connection master

Third, after the configuration is completed, you can open the master-slave mechanism, read and write separation, and provide a sentry mechanism, in the master down machine 5 seconds after the random selection of a new master, the previous master can only work as a slave!

redis operation command:redis-server redis63791.conf & --> Run server redis-cli -h 116.196.107.20-p 63791 remote connection server auth 123456789 ---> Verify password redis-server mysentinel.conf --sentinel in redis Start sentinel mode and start listening, as follows:

The above is a brief introduction to the explanation of redis read-write separation and sentinel mechanism configuration. Of course, the difference between using the above in detail must be understood by everyone themselves. If you want to know more, welcome to pay attention to the industry information channel!

Tags: Sentry master configuration mechanism file data server service master-slave password situation port command quantity time more voting monitoring authentication election Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Microsoft MariaDB vpn Linux