Redis replication (Master / Slave), separated from the master copy, read and write

1. What is Redis replication

  Jargon: what we call the master-slave replication, master data updates based on the configuration and policy automatically synchronized to the master backup machine / slave mechanism, Mater mainly to write, slave read-mostly.

2, can you do

  2.1, separate read and write

  2.2, disaster recovery

3, how to use

  3.1, with the (library) unworthy master (library)

  3.2, from the library configuration: slave main library main library IP port

  3.3, modify the configuration file details of operation

  3.4 commonly used three measures

    3.4.1, a main two servant

      1、init

      2, a two Master Slave

      3, Log Viewer

      4, the main problem from the demo

    3.4.2 Passing the torch

    3.4.3, become masters

4, the implementation process

  1, create three hosts, each initialization

127.0.0.1:6381> info replication
# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6381> 

  2, the host 6379 setter

127.0.0.1:6380> set k1 v1
OK
127.0.0.1:6380> set k2 v2
OK
127.0.0.1:6380> set k3 v3
OK

  3, the backup

127.0.0.1:6379> slaveof 127.0.0.1 6379
OK

  4, direct access to the value (hereinafter, may also be inserted directly)

127.0.0.1:6380> get k1
"v1"

 

 

Note: Note dead, standby slave or slave, slave place. Slave died, the slave alive, he is the host, and the need to re-establish relations. Unless you are in the configuration file into the redis.conf

Guess you like

Origin www.cnblogs.com/karrya/p/11279903.html