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.上面安装 ...
随机推荐
- CF812C Sagheer and Nubian Market 二分+贪心
模拟赛给他们出T1好了~ code: #include <bits/stdc++.h> #define ll long long #define N 100006 #define setI ...
- Ubuntu14.04 打开关闭图形桌面
使用 Ctrl+Alt+t 打开命令行界面 #关闭桌面 sudo service lightdm stop #恢复桌面 sudo service lightdm start Ctrl+Alt+F1 可 ...
- shell 统计行数,单词个数,字符个数
如果我们想知道1.txt中有多少行,多少个单词,多少个字符.我们可以使用wc命令.选项与参数-l:今列出行-w:今列出多少字(英文单词)-m:多少字符[zhang@localhost ~]$ cat ...
- Jmeter随机参数各种搭配
参数配置应该有三种场景,具体其他的我还没想到 一.两个固定值之间随机生成一个值,应用场景没有限制 1.最简单的两个值之间随机产生一个整数作为值,打开函数助手 2.选择函数 __Random 然后我想要 ...
- jenkins的任务卡住
今天做jenkins任务的时候,发现一个启动后,一直卡住,在那转圈圈,其实这个时候,任务已经执行完了. 经过分析,因为这个任务是启动一个web服务,直接在机器上执行时,直接占用一个终端. 解决办法,放 ...
- Java微信公众号开发梳理
Java微信公众号开发梳理 现在微信公众平台的开发已经越来越普遍,这次开发需要用到微信公众平台.因此做一个简单的记录,也算是给那些没踩过坑的童鞋一些启示吧.我将分几块来简单的描述一下,之后会做详细的说 ...
- Linux 配置eth0网卡
缘由: 最近要复习docker,电脑没有centos7,于是下载了一个最新版的centos7,迫于强迫症没有eth0网卡,为了将ens33改为eth0于是寻求方法. 1.编辑网卡的配置文件 vi /e ...
- Pro*C编程研究一:从.pc到.exe
[第一步]在Windows下编辑一个.pc程序(Pro*C源程序,作者用到:C:\proctest\exam1.pc),其内容如下: #include <stdio.h> #include ...
- 为什么使用 Web Services?
最重要的事情是协同工作 由于所有主要的平台均可通过 Web 浏览器来访问 Web,不同的平台可以借此进行交互.为了让这些平台协同工作,Web 应用程序被开发了出来. Web 应用程序是运行在 Web ...
- 文件上传对servlet的要求
request.getParamter(String name)方法不能再使用了 需要使用request.getInputStream()获取输入流对象然后在进行读取数据 解析数据 ServletIn ...