Quick Start Redis series (5) - Redis master-slave replication architecture

        As a fifth blog post series Quick Start Redis herein, this brings for everyone is the master of the Redis replication architecture .

        Codeword is not easy, praise after the first look!

Here Insert Picture Description


Redis master-slave replication architecture

        In Redis, the user can execute SLAVEOF command or set slaveof option to a server to copy (replicate) to another server, we call server to be copiedMaster server (master)And the server replication of the master server is calledFrom the server (slave),as the picture shows.

Here Insert Picture Description
        Using the master copy from this model, realized as a master node node01, node02 node03 as the slave node, and node01 all data and all synchronized to node02 node03 server.
        

The first step: node02 and node03 Redis server installation

<1> node02 node03 with the following command to install the context dependent

yum -y install gcc-c++

<2> node02 and node03 redis archive upload

Upload server redis in node02 node03 above the compressed and decompressed ~
the installation package upload / export / softwares path

cd /export/softwares

tar -zxvf redis-3.2.8.tar.gz -C ../servers/

        

<3> node02 node03 server installation and tcl

node02 node03 server and execute the following command-line installation TCL

yum -y install tcl

<4> node02 node03 and compiled server redis

node02 and node03 execute the following command to compile redis
execute the following command to compile:

cd /export/servers/redis-3.2.8/

make test && make install

<5> node02 node03 modify the configuration file server redis

node02 modify server configuration file commands are as follows

Execute the following command to modify the configuration file redis

cd /export/servers/redis-3.2.8/
mkdir -p /export/servers/redis-3.2.8/logs
mkdir -p /export/servers/redis-3.2.8/redisdata
vim redis.conf

In the local cluster corresponding plus the corresponding value

bind node02
daemonize yes
pidfile /var/run/redis_6379.pid
logfile “/export/servers/redis-3.2.8/logs/redis.log”
dir /export/servers/redis-3.2.8/redisdata
slaveof node01 6379

node03 modify server configuration file commands are as follows

Execute the following command to modify the configuration file redis

cd /export/servers/redis-3.2.8/
mkdir -p /export/servers/redis-3.2.8/logs
mkdir -p /export/servers/redis-3.2.8/redisdata
vim redis.conf

With node02, where clusters corresponding plus the corresponding value of the
fact property values will bind is not the same, other values are the same

bind node03
daemonize yes
pidfile /var/run/redis_6379.pid
logfile “/export/servers/redis-3.2.8/logs/redis.log”
dir /export/servers/redis-3.2.8/redisdata
slaveof node01 6379

Note: where the place marked red must be careful, value is the name of the corresponding node bind binding,slaveof node01 6379Indicates the current node as a slave node, it is necessary to copy the data on the primary node node01.

        

Step Two: Start node02 and node03 machine redis service

node02 execute the following command to start the service redis

cd  /export/servers/redis-3.2.8/src
redis-server  ../redis.conf

node03 execute the following command to start the service redis

cd  /export/servers/redis-3.2.8/src
redis-server  ../redis.conf

After a successful start can be achieved from the main redis replication, node01 can read and write operations, node02 and node03 only supports read operations.

The detailed operation example is as follows:
Here Insert Picture Description


        Knowledge sharing this blog on here, and interested friends attention - remember the point Zanga next blogger bring you is Redis当中的Sentinel架构to explain, so stay tuned | ू · ω · `)
Here Insert Picture Description

Published 239 original articles · won praise 1931 · Views 460,000 +

Guess you like

Origin blog.csdn.net/weixin_44318830/article/details/104907307