redis主从同步错误处理
背景:
之前resis只有一台服务器(redis master),现需要为其增加一台slave服务器(slave),做成一主一从
要求,不影响 master的正常情况下完成 .
1、配置slave:
在slave的配置文件中,指定master即可
slaveof <masterip> 6379
2、启动slave后,查看slave和mater日志
salve:
4724:S 30 Aug 10:49:14.687 # Server started, Redis version 3.2.6
4724:S 30 Aug 10:49:14.690 * DB loaded from append only file: 0.002 seconds
4724:S 30 Aug 10:49:14.690 * The server is now ready to accept connections on port 6379
4724:S 30 Aug 10:49:14.690 * The server is now ready to accept connections at /tmp/redis_6379.sock
4724:S 30 Aug 10:49:14.690 * Connecting to MASTER 192.168.1.82:6379
4724:S 30 Aug 10:49:14.690 * MASTER <-> SLAVE sync started
4724:S 30 Aug 10:49:14.691 * Non blocking connect for SYNC fired the event.
4724:S 30 Aug 10:49:14.691 * Master replied to PING, replication can continue...
4724:S 30 Aug 10:49:14.692 * Partial resynchronization not possible (no cached master)
4724:S 30 Aug 10:49:20.601 * Full resync from master: 471f183e04fda3047a7c4e03bf68ec03a31203c1:4198265
master:
1698:M 30 Aug 10:49:14.669 * Slave 192.100.10.88:6379 asks for synchronization
1698:M 30 Aug 10:49:14.669 * Full resync requested by slave 192.100.10.88:6379
1698:M 30 Aug 10:49:14.669 * Delay next BGSAVE for diskless SYNC
1698:M 30 Aug 10:49:20.576 * Starting BGSAVE for SYNC with target: slaves sockets
1698:M 30 Aug 10:49:20.577 # Can't save in background: fork: Cannot allocate memory
1698:M 30 Aug 10:49:20.577 # BGSAVE for replication failed
数据未能同步到slave上。
master、slave修改内核变量
vi /etc/sysctl.conf
vm.overcommit_memory=1
systctl -p
重启slave后,开始同步数据。
master:
1698:M 30 Aug 10:50:43.525 * Slave 192.168.1.88:6379 asks for synchronization
1698:M 30 Aug 10:50:43.525 * Full resync requested by slave 192.100.10.88:6379
1698:M 30 Aug 10:50:43.525 * Delay next BGSAVE for diskless SYNC
1698:M 30 Aug 10:50:49.788 * Starting BGSAVE for SYNC with target: slaves sockets
1698:M 30 Aug 10:50:49.819 * Background RDB transfer started by pid 18925
18925:C 30 Aug 10:50:49.970 * RDB: 1 MB of memory used by copy-on-write
1698:M 30 Aug 10:50:50.020 * Background RDB transfer terminated with success
1698:M 30 Aug 10:50:50.020 # Slave 192.168.1.88:6379 correctly received the streamed RDB file.
1698:M 30 Aug 10:50:50.020 * Streamed RDB transfer with slave 192.100.10.88:6379 succeeded (socket). Waiting for REPLCONF ACK from slave to enabl
e streaming
1698:M 30 Aug 10:50:50.557 * Synchronization with slave 192.100.10.88:6379 succeeded
1698:M 30 Aug 11:01:19.481 * Background append only file rewriting started by pid 31942
1698:M 30 Aug 11:01:19.581 * AOF rewrite child asks to stop sending diffs.
31942:C 30 Aug 11:01:19.581 * Parent agreed to stop sending diffs. Finalizing AOF...
31942:C 30 Aug 11:01:19.581 * Concatenating 0.00 MB of AOF diff received from parent.
31942:C 30 Aug 11:01:19.592 * SYNC append only file rewrite performed
31942:C 30 Aug 11:01:19.598 * AOF rewrite: 0 MB of memory used by copy-on-write
1698:M 30 Aug 11:01:19.688 * Background AOF rewrite terminated with success
1698:M 30 Aug 11:01:19.688 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)
1698:M 30 Aug 11:01:19.688 * Background AOF rewrite finished successfully
slave:
4849:S 30 Aug 10:50:43.536 # Server started, Redis version 3.2.6
4849:S 30 Aug 10:50:43.537 * DB loaded from append only file: 0.000 seconds
4849:S 30 Aug 10:50:43.537 * The server is now ready to accept connections on port 6379
4849:S 30 Aug 10:50:43.537 * The server is now ready to accept connections at /tmp/redis_6379.sock
4849:S 30 Aug 10:50:43.537 * Connecting to MASTER 192.168.1.82:6379
4849:S 30 Aug 10:50:43.538 * MASTER <-> SLAVE sync started
4849:S 30 Aug 10:50:43.538 * Non blocking connect for SYNC fired the event.
4849:S 30 Aug 10:50:43.539 * Master replied to PING, replication can continue...
4849:S 30 Aug 10:50:43.540 * Partial resynchronization not possible (no cached master)
4849:S 30 Aug 10:50:49.801 * Full resync from master: 471f183e04fda3047a7c4e03bf68ec03a31203c1:4349163
4849:S 30 Aug 10:50:49.845 * MASTER <-> SLAVE sync: receiving streamed RDB from master
4849:S 30 Aug 10:50:49.977 * MASTER <-> SLAVE sync: Flushing old data
4849:S 30 Aug 10:50:49.977 * MASTER <-> SLAVE sync: Loading DB in memory
4849:S 30 Aug 10:50:50.056 * MASTER <-> SLAVE sync: Finished with success
4849:S 30 Aug 10:50:50.062 * Background append only file rewriting started by pid 4900
4849:S 30 Aug 10:50:50.247 * AOF rewrite child asks to stop sending diffs.
4900:C 30 Aug 10:50:50.247 * Parent agreed to stop sending diffs. Finalizing AOF...
4900:C 30 Aug 10:50:50.247 * Concatenating 0.00 MB of AOF diff received from parent.
4900:C 30 Aug 10:50:50.248 * SYNC append only file rewrite performed
4900:C 30 Aug 10:50:50.250 * AOF rewrite: 0 MB of memory used by copy-on-write
4849:S 30 Aug 10:50:50.268 * Background AOF rewrite terminated with success
4849:S 30 Aug 10:50:50.268 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)
4849:S 30 Aug 10:50:50.268 * Background AOF rewrite finished successfully
redis主从同步错误处理的更多相关文章
- Redis系列之(二):Redis主从同步,读写分离
1. Redis主从同步 Redis支持主从同步.数据可以从主服务器向任意数量的从服务器上同步,同步使用的是发布/订阅机制. 2. 配置主从同步 Mater Slave的模式,从Slave向Maste ...
- Redis 主从配置和参数详解
安装redis 下载redis wget http://download.redis.io/releases/redis-3.0.7.tar.gz 解压redis tar -xvf redis-.ta ...
- 基于Windows服务器集群的Redis主从配置指南
前段时间一个项目因并发量大.因防止宕机做了主从备份,首页的表连接查询又非常的耗时.故此拿出利器Redis缓存这个查询结果,并随着用户操作而更新. 因官方目前只有linux版,Windows版下载: ...
- redis 主从同步
修改redis.conf配置文件 vi redis.conf 在编辑模式下 输入 /slaveof 来搜索 将slaveof启用 即 将#删除 依次配置所有 slave 并将进程 kill 掉 重启 ...
- redis主从 以及认证配置
以前用redis用的很多,各种数据类型用的飞起,算是用得很溜了.不过那都是封装好的方法,自己直接调用.以前的公司比较规范,开发只是开发,很少去做跟运维相关的事情. 换了一份工作,不过这边项目刚开始起步 ...
- Redis-cluster集群【第三篇】:redis主从
Redis主从复制原理: 通过把这个RDB文件或AOF文件传给slave服务器,slave服务器重新加载RDB文件,来实现复制的功能! 复制的话:主服务器可以有多个从服务器!!! 不仅这样从服务器还 ...
- Redis主从自动failover
Redis主从架构持久化存在一个问题,即前次测试的结论,持久化需要配置在主实例上才能跨越实例保证数据不丢失,这样以来主实例在持久化数据到硬 盘的过程中,势必会造成磁盘的I/O等待,经过实际测试,这个持 ...
- redis主从遇到的两个坑
最近在使用redis主从的时候做了下面两件事情: 1 希望redis主从从操作上分析,所有写操作都在master上写,所有读操作都在从上读. 2 由于redis的从是放在本地的,所以有的key的读写操 ...
- Redis主从配置详细过程
Redis的主从复制功能非常强大,一个master可以拥有多个slave,而一个slave又可以拥有多个slave,如此下去,形成了强大的多级服务器集群架构.下面楼主简单的进行一下配置. 1.上面安装 ...
随机推荐
- C++问题--fread文件读不完整问题解决
今天突然遇到一个问题,用fwrite/fread读写文件,发现当fread读取文件时只能读一半, 即使用foef()查看是否读到文件结尾,也是显示文件已经读取到文件末尾,查看文件的返回值发现文件只读取 ...
- nios ii 13 主程序的函数可以用Open Declaration 查看,但是编译的时候却说 undefined reference to 。。。这是为什么?
在做12864 ip 核试验时,写了三个文件第一个是时序文件QC12864.v第二个是QC12864.H这个文件主要包括声明和宏定义,第三个文件是QC12864.c这个文件包含函数的定义.详细的请看 ...
- Java安全(加密、摘要、签名、证书、SSL、HTTPS)
对于一般的开发人员来说,很少需要对安全领域内的基础技术进行深入的研究,但是鉴于日常系统开发中遇到的各种安全相关的问题,熟悉和了解这些安全技术的基本原理和使用场景还是非常必要的.本文将对非对称加密.数字 ...
- 互联网IT当线上出现 bug 时,是怎么处理的?
线上BUG说处理方法:1.关于线上BUG问题,目前公司有一整套线上故障流程规范,包括故障定义.定级.处理流程.故障处理超时升级机制.故障处理小组.故障处罚(与故障存在时长有关)等:2.最主要的是,线上 ...
- go语言规范之方法集
Go语言规范里定义的方法集的规则 Values Methods Receivers ----------------------------------------------- T (t T) *T ...
- Python 调用系统命令的模块 Subprocess
Python 调用系统命令的模块 Subprocess 有些时候需要调用系统内部的一些命令,或者给某个应用命令传不定参数时可以使用该模块. 初识 Subprocess 模块 Subprocess 模块 ...
- linux后台运行nodejs项目
1.安装pm2,这里默认你已经安装了node.js和npm npm install pm2 -g 2.创建软连接 1)全局path路径 echo $PATH 2)pm2安装路径 安装pm2时,可看到p ...
- Sublime Markdown预览插件安装流程
使用方法 在sublime中已编辑好的markdown使用快捷键 Alt+M 即可在浏览器预览效果. 需要安装的插件 Markdown Editting:主要用来做 Markdown 编辑时的语法高亮 ...
- SpringBoot/SpringMVC 下载本地文件
页面代码: <!DOCTYPE html> <html lang="utf-8"> <meta http-equiv="Content-Ty ...
- Gokit微服务-服务链路追踪
https://mp.weixin.qq.com/s/gjKOy4SDpsjUXDC3Q1YdFw Gokit微服务-服务链路追踪 原创: 兮一昂吧 兮一昂吧 2月28日