Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis-Master-Slave configuration

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The role of the cluster:

1. Master-slave backup prevents master library from downloading

2. Separate reading and writing to share master pressure.

3. Task separation, such as sharing backup work from the server

Probably the principle of synchronization:

1Jing started and found that master needs to be connected, so sync automatically synchronizes it.

2Mastermaster dump sends a rdb file to slave

3Jing master newly generated data, by buffering aof files

4, and then keep in touch through the replicationfeedsalves process

Master configuration:

1. Close the rdb snapshot and give the backup to slave

2. Enable aof

Slave configuration:

1, declare slave-of

2. Configure password-- if master has a password

3. A certain slave opens the rdb snapshot function

4. Configure whether to read-only slave-read-only

Configure the slave server:

1, copy the relevant configuration files in the main library

[root@ZFRC-YW-YJF-TEST-370123 redis] # cp redis.conf redis6380.conf

[root@ZFRC-YW-YJF-TEST-370123 redis] # cp redis.conf redis6381.conf

2, configure from the server configuration file 6380, modify the following

Port 6380

Pidfile / var/run/redis_6380.pid

Dbfilename dump6380.rdb

Slaveof localhost 6379

Slave-read-only yes

Configure the configuration from the server profile 6381, modify it as follows

Port 6381

Pidfile / var/run/redis_6381.pid

Note rdb generation conditions

# save 900 1

# save 300 10

# save 60 3000

Turn off the aof function of the second slave node

Appendonly no

Slaveof localhost 6379

3. View the rdb file and aof file in the environment. Delete cleanly

[root@ZFRC-YW-YJF-TEST-370123 dir] # rm *

Rm: remove regular empty file 'laoyang-appendonly.aof'? Y

4, primary master node configuration

Cancel rdb

# save 900 1

# save 300 10

# save 60 3000

Aof file closed

Appendonly no

5. Start the master-slave cluster

[root@ZFRC-YW-YJF-TEST-370123 redis] #. / bin/redis-server. / redis.conf

[root@ZFRC-YW-YJF-TEST-370123 redis] #. / bin/redis-server. / redis6380.conf

[root@ZFRC-YW-YJF-TEST-370123 redis] #. / bin/redis-server. / redis6381.conf

6, verification, main server 6379 inserts data, 6380 checks

[root@ZFRC-YW-YJF-TEST-370123 redis] #. / bin/redis-cli

127.0.0.1 6379 > keys *

(empty list or set)

127.0.0.1 purl 6379 > set zhucong ok

OK

127.0.0.1 purl 6379 > exit

[root@ZFRC-YW-YJF-TEST-370123 redis] #. / bin/redis-cli-p 6380

127.0.0.1 6380 > get zhucong

"ok"

[root@ZFRC-YW-YJF-TEST-370123 redis] #. / bin/redis-cli-p 6381

127.0.0.1purl 6381 > get zhucong

"ok"

Summary:

Disadvantages: every time the slave is disconnected, whether it is active disconnection or network failure. When connecting to master, you have to master all dump out of rdb, and then aof. The synchronization process has to be done all over again, so keep in mind that multiple slave should not be started all at once, or the master may IO soar.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report