设为首页 收藏本站
查看: 1894|回复: 0

[经验分享] Redis主从同步

[复制链接]
发表于 2018-11-6 07:44:29 | 显示全部楼层 |阅读模式
################################# 主从复制 #################################  

  
# 主从复制。使用 slaveof 来让一个 redis 实例成为另一个reids 实例的副本。
  
# 注意这个只需要在 slave 上配置。
  
#
  
# slaveof  
  

  
# 如果 master 需要密码认证,就在这里设置
  
# masterauth
  

  
# 当一个 slave 与 master 失去联系,或者复制正在进行的时候,
  
# slave 可能会有两种表现:
  
#
  
# 1) 如果为 yes ,slave 仍然会应答客户端请求,但返回的数据可能是过时,
  
#    或者数据可能是空的在第一次同步的时候
  
#
  
# 2) 如果为 no ,在你执行除了 info he salveof 之外的其他命令时,
  
#    slave 都将返回一个 "SYNC with master in progress" 的错误,
  
#
  
slave-serve-stale-data yes
  

  
# 你可以配置一个 slave 实体是否接受写入操作。
  
# 通过写入操作来存储一些短暂的数据对于一个 slave 实例来说可能是有用的,
  
# 因为相对从 master 重新同步数而言,据数据写入到 slave 会更容易被删除。
  
# 但是如果客户端因为一个错误的配置写入,也可能会导致一些问题。
  
#
  
# 从 redis 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.
  
# 注意:只读的 slaves 没有被设计成在 internet 上暴露给不受信任的客户端。
  
# 它仅仅是一个针对误用实例的一个保护层。
  
slave-read-only yes
  

  
# Slaves 在一个预定义的时间间隔内发送 ping 命令到 server 。
  
# 你可以改变这个时间间隔。默认为 10 秒。
  
#slave 发送pings到master的实际间隔。默认为10秒
  
# repl-ping-slave-period 10
  

  
# The following option sets the replication timeout for:
  
# 设置主从复制过期时间
  
#
  
# 1) Bulk transfer I/O during SYNC, from the point of view of slave.
  
# 2) Master timeout from the point of view of slaves (data, pings).
  
# 3) Slave timeout from the point of view of masters (REPLCONF ACK pings).
  
#
  
# It is important to make sure that this value is greater than the value
  
# specified for repl-ping-slave-period otherwise a timeout will be detected
  
# every time there is low traffic between the master and the slave.
  
# 这个值一定要比 repl-ping-slave-period 大
  
#设置主从复制过期时间
  
# repl-timeout 60
  

  
# Disable TCP_NODELAY on the slave socket after SYNC?
  
#
  
# If you select "yes" Redis will use a smaller number of TCP packets and
  
# less bandwidth to send data to slaves. But this can add a delay for
  
# the data to appear on the slave side, up to 40 milliseconds with
  
# Linux kernels using a default configuration.
  
#
  
# If you select "no" the delay for data to appear on the slave side will
  
# be reduced but more bandwidth will be used for replication.
  
#
  
# By default we optimize for low latency, but in very high traffic conditions
  
# or when the master and slaves are many hops away, turning this to "yes" may
  
# be a good idea.
  
repl-disable-tcp-nodelay no
  

  
# 设置主从复制容量大小。这个 backlog 是一个用来在 slaves 被断开连接时
  
# 存放 slave 数据的 buffer,所以当一个 slave 想要重新连接,通常不希望全部重新同步,
  
# 只是部分同步就够了,仅仅传递 slave 在断开连接时丢失的这部分数据。
  
#
  
# The biggest the replication backlog, the longer the time the slave can be
  
# disconnected and later be able to perform a partial resynchronization.
  
# 这个值越大,salve 可以断开连接的时间就越长。
  
#
  
# The backlog is only allocated once there is at least a slave connected.
  
#
  
# repl-backlog-size 1mb
  

  
# After a master has no longer connected slaves for some time, the backlog
  
# will be freed. The following option configures the amount of seconds that
  
# need to elapse, starting from the time the last slave disconnected, for
  
# the backlog buffer to be freed.
  
# 在某些时候,master 不再连接 slaves,backlog 将被释放。
  
#当master 和slave 断开了。backlog多长时间被释放
  
# A value of 0 means to never release the backlog.
  
# 如果设置为 0 ,意味着绝不释放 backlog 。
  
#
  
# repl-backlog-ttl 3600
  

  
# 当 master 不能正常工作的时候,Redis Sentinel 会从 slaves 中选出一个新的 master,
  
# 这个值越小,就越会被优先选中,但是如果是 0 , 那是意味着这个 slave 不可能被选中。
  
#
  
# 默认优先级为 100。
  
slave-priority 100
  

  
# It is possible for a master to stop accepting writes if there are less than
  
# N slaves connected, having a lag less or equal than M seconds.
  
#
  
# The N slaves need to be in "online" state.
  
#
  
# The lag in seconds, that must be

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-631262-1-1.html 上篇帖子: 高性能网站架构设计之缓存---redis集群搭建 下篇帖子: redis——安装与配置( How To Install Redis in Ubuntu)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表