Redis - A master-slave configuration

The role of the cluster:
1, master database from a backup down to prevent the main unit
2, separate read and write, share the master pressure
work 3, separate tasks, such as backups from the server sharing

Probably synchronization principle:
1, found that need to connect master Slave start, then sync automatically synchronized at
2, master dump out a rdb file to Slave
3 new master data generated by buffer aof file
4, and then stay in touch replicationfeedsalves process;

master configuration:
1, closed rdb snapshot - backup to Slave
2, open aof

slave configuration:
1, the statement-of slave
2, the configuration code - if the master password
3, a snapshot function rdb open a slave
4, configuration is read only slave-read-only

Configuring from the server:
1. Copy the configuration file in the main library
[root @ ZFRC-YW-YJF-the TEST-370 123 Redis] # cp redis.conf redis6380.conf
[root @ ZFRC-YW-YJF-the TEST-370 123 Redis] # redis.conf redis6381.conf cp
2, 6380 configuration from the server configuration file, modify the following local
Port 6380
the PidFile /var/run/redis_6380.pid
dbfilename dump6380.rdb
slaveof localhost 6379
Slave-the Read-only yes

Configuring the profile from the server 6381, modified as follows where
Port 6381
PidFile /var/run/redis_6381.pid
Note rdb generation condition
#save 900. 1
#save 300 10
#save 60 3000

Close second slave node function aof
appendonly no

slaveof localhost 6379

3, view the environment rdb file, and aof file. Clean, delete
[root @ ZFRC-YW-YJF the TEST-370 123-dir] # RM *
RM: Regular empty the Remove File 'laoyang-appendonly.aof' the y-?

4, the primary master node is configured
to cancel rdb

#save 900 1
#save 300 10
#save 60 3000

aof file is closed
appendonly no

5, starting from the cluster master
[@ ZFRC the root-YW-370 123-YJF the TEST-Redis] # ./bin/redis-server ./redis.conf
[@ ZFRC the root-YW-370 123-YJF the TEST-Redis] ./ # bin / Redis-Server ./redis6380.conf
[@ ZFRC the root-YW-370 123-YJF the TEST-Redis] # ./bin/redis-server ./redis6381.conf

6, to verify, the master server 6379 to insert data, check 6380
[@ ZFRC the root-YW-370 123-YJF the TEST-Redis] # ./bin/redis-cli
127.0.0.1:6379> Keys *
(List empty or SET)
127.0. 0.1: 6379> the SET zhucong the ok
the OK
127.0.0.1:6379> Exit
[root @ ZFRC-YW-YJF-the TEST-370 123 Redis] # ./bin/redis-cli -p 6380
127.0.0.1:6380> GET zhucong
"the ok "
[root @ ZFRC-YW-YJF-the TEST-370 123 Redis] # ./bin/redis-cli -p 6381
127.0.0.1:6381> GET zhucong
" the ok "

Summary:
Disadvantages: After each slave is disconnected, whether active disconnection, or network failure. In connection master, must master all dump out rdb, then aof. Synchronization process must be re-run again, so remember, slave several of them do not start all at once, otherwise the master IO may soar.

Guess you like

Origin blog.51cto.com/yangjunfeng/2412137
Recommended