Home Database Redis Redis read-write separation and sentinel mechanism configuration

Redis read-write separation and sentinel mechanism configuration

Mar 30, 2020 am 09:24 AM
redis

Redis read-write separation and sentinel mechanism configuration

1. Use the commands cp redis.conf /redis63791.conf, cp redis.conf /redis63792.conf, cp redis.conf /redis63793.conf in /etc/redis/ to The root directory is ready

1

2

3

4

5

6

7

8

9

10

11

12

vim redis63792.conf  --->修改配置文件

daemonize yes 守护进程

port 63792 端口

bind 192.168.0.3 绑定内网地址

databases 16 开启16个数据库

save ---> 每多少个文件执行一次保存

(主人不需要以下操作)

slaveof 116.196.107.20 63791 --> 作为该ip该端口的奴隶

masterauth '123456789' --> 认证主人的密码

----------------------

appendonly yes 开启这个增强数据的安全性

(以上为正常的redis.conf里面的配置文件,所有的slave都要去连接主人的服务器,只能读,不能写,自动同步数据,读写分离可以大大的增强服务器的性能能,因为在正常的数据操作中, 读的时候往往比写的时候的情况要多的多, 一般情况下主从机按1:3进行分配)

Copy after login

2. Sentinel configuration, find the sentinel.conf file in /etc/redis (if you don’t have such a configuration file), copy cp sentinel.conf /mysentinel .conf

1

2

3

4

vim mysentinel.conf

sentinel monitor mymaster 116.196.107.20 63791 1 -->分别的意思是 哨兵监听主人:116.196.107.20的 端口:63791 哨兵数量1个, 一般情况下哨兵的数量越多, 投票选举通过的几率越小, 在投票选举出新主人花费的时间就越多, 不利于快速切换主从机制

sentinel down-after-milliseconds mymaster 5000 主机掉线以后5s进行认证,如果无法连接则重新由哨兵从slave中选出新的主人

sentinel auth-pass mymaster 123456789 哨兵通过密码连接主人

Copy after login

3. After the configuration is completed, you can turn on the master-slave mechanism, separate reading and writing, and provide a sentinel mechanism. After the master is down for 5 seconds, a new master will be randomly selected from the slave. Previously After the master is connected, he can only work as a slave! !

1

2

3

4

5

redis操作命令:

redis-server redis63791.conf & -->以该配置文件在后台运行服务器

redis-cli -h 116.196.107.20 -p 63791 远程连接服务器

auth 123456789 --->在redis中验证密码

redis-server mysentinel.conf --sentinel 启动哨兵模式开始监听, 如下:

Copy after login

Redis read-write separation and sentinel mechanism configuration

For more redis knowledge, please pay attention to the redis introductory tutorial column.

The above is the detailed content of Redis read-write separation and sentinel mechanism configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution to 0x80242008 error when installing Windows 11 10.0.22000.100 Solution to 0x80242008 error when installing Windows 11 10.0.22000.100 May 08, 2024 pm 03:50 PM

Solution to 0x80242008 error when installing Windows 11 10.0.22000.100

How to change the password in redis How to change the password in redis Apr 20, 2024 am 03:00 AM

How to change the password in redis

Analyze PHP function bottlenecks and improve execution efficiency Analyze PHP function bottlenecks and improve execution efficiency Apr 23, 2024 pm 03:42 PM

Analyze PHP function bottlenecks and improve execution efficiency

Is redis a memory cache? Is redis a memory cache? Apr 20, 2024 am 05:26 AM

Is redis a memory cache?

Golang API caching strategy and optimization Golang API caching strategy and optimization May 07, 2024 pm 02:12 PM

Golang API caching strategy and optimization

Is redis a non-relational database? Is redis a non-relational database? Apr 20, 2024 am 05:36 AM

Is redis a non-relational database?

Caching mechanism and application practice in PHP development Caching mechanism and application practice in PHP development May 09, 2024 pm 01:30 PM

Caching mechanism and application practice in PHP development

Which one has better performance, erlang or golang? Which one has better performance, erlang or golang? Apr 21, 2024 am 03:24 AM

Which one has better performance, erlang or golang?

See all articles