Slave Replication) 详解

1. Master新增网卡,修改server端配置

IP : 192.168.40.128/24

注释: bind,支持网络连接

2. 新建虚机slave,配置网络,修改Redis配置

#slaveof <masterip> <masterport>

slaveof 192.168.40.128 6379

# masterauth <master-password>

masterauth "zcy1991"

3. 启动redis,打开日志

Slave Replication) 详解

4. 查看Replication信息

Master:

Slave Replication) 详解

Slave:

Slave Replication) 详解

Slave Replication) 详解

5.配置文件 “主从复制”部分 【翻译+理解】 (Verion 3.2.8)

################################# REPLICATION (复制) #################################

-------------------------------------------

# Master-Slave replication. Use slaveof to make a Redis instance a copy of

# another Redis server. A few things to understand ASAP about Redis replication.

#主从复制。 使用slaveof使一个Redis实例成为另一个Redis服务器的拷贝(副本)。

关于Redis复制的几个事情:

# 1) Redis replication is asynchronous, but you can configure a master to

#    stop accepting writes if it appears to be not connected with at least

#    a given number of slaves.

1) Redis复制是异步的,但是如果它看起来没有与至少给定数量的slave连接,您可以配置一个主设备停止接受写入。

# 2) Redis slaves are able to perform a partial resynchronization with the

#    master if the replication link is lost for a relatively small amount of

#    time. You may want to configure the replication backlog size (see the next

#    sections of this file) with a sensible value depending on your needs.

2) 如果复制链路丢失相对较少的时间,Redis slave能够与master执行部分重新同步。 您可能需要根据需要,使用合理的值配置replication backlog 大小(请参阅此文件的下一个操作)。

# 3) Replication is automatic and does not need user intervention. After a

#    network partition slaves automatically try to reconnect to masters

#    and resynchronize with them.

# 3) 复制是自动的,不需要用户干预。 网络分割后,slaves 自动尝试重新连接到masters 并与它们重新同步。

# slaveof <masterip> <masterport>

# If the master is password protected (using the "requirepass" configuration

# directive below) it is possible to tell the slave to authenticate before

# starting the replication synchronization process, otherwise the master will

# refuse the slave request.

#如果master使用密码保护(使用下面的“requirepass”配置指令),可以在开始复制同步过程之前,告诉slaves进行认证,否则master将拒绝slave连接请求。

# masterauth <master-password>

-------------------------------------------

# When a slave loses its connection with the master, or when the replication

# is still in progress, the slave can act in two different ways:

#当一个slave与master断开连接或复制仍在进行时,slave可以采用两种不同的方式:

# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will

#    still reply to client requests, possibly with out of date data, or the

#    data set may just be empty if this is the first synchronization.

# 如果slave-serve-stale-data设置为“yes”(默认值),则slave仍将回复客户端请求,可能使用过期数据,或者如果这是第一次同步,则数据集可能为空。

# 2) if slave-serve-stale-data is set to 'no' the slave will reply with

#    an error "SYNC with master in progress" to all the kind of commands

#    but to INFO and SLAVEOF.

#如果slave-serve-stale-data设置为“no”,除了INFO和SLAVEOF,slave将回复错误“SYNC with master in progress”给所有类型的命令。

slave-serve-stale-data yes

# You can configure a slave instance to accept writes or not. Writing against

# a slave instance may be useful to store some ephemeral data (because data

# written on a slave will be easily deleted after resync with the master) but

# may also cause problems if clients are writing to it because of a

# misconfiguration.

# 您可以配置slave实例接受写入或不接受写入。 对slave实例进行写操作对存储一些临时数据可能是有用的(因为写在slave上的数据将在与master重新同步后很容易被删除),但是如果客户端因为错误配置而写入它,也会导致问题。

#

# Since Redis 2.6 by default slaves are read-only. 自2.6之后,slaves默认只读(不可写)

#

# Note: read only slaves are not designed to be exposed to untrusted clients

# on the internet. It's just a protection layer against miSUSE of the instance.

# Still a read only slave exports by default all the administrative commands

# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve

# security of read only slaves using 'rename-command' to shadow all the

# administrative / dangerous commands.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/58b3b5a4db60b2caeb1fbc689fc5c447.html