Redis database master-slave configuration

The master database (master)
-data writing from the database (slave)-database reading
By configuring the master-slave database to achieve read and write database separation (the site's read and write ratio is generally 10: 1)
master and slave are both redis instance

1. Configure the main database

(1) Configuration file
etc / redis / redis.conf file

bin 0.0.0.0 # 或者修改成本机IP

(2) Open the host service

src / redis-server redis.conf

2. Configure slave database
(1), copy etc / redis / redis.conf file

cp redis conf slave.conf

(2), modify the redis / save.conf file

vim slave.conf

bind 192.168.154.131 # 主机IP
slaveof 192.168.154.131 6379 # 主机IP + 端口
port 6378 # 从机端口

3. Open the host service

src / redis-server slave.conf

4. Data operation
Execute info command in master and slave respectively, view the output information and enter the main client

src / redis -cli -h 192.168.154.131 -p 6379

Enter the client from

src / redis -cli -h 192.168.154.131 -p 6378

Automatic master-slave database synchronization

# 主数据库
set name lcl
# 从数据库
get name
Published 50 original articles · Likes3 · Visits 1797

Guess you like

Origin blog.csdn.net/weixin_43056654/article/details/104746156
Recommended