背景:

之前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主从同步错误处理的更多相关文章

  1. Redis系列之(二):Redis主从同步,读写分离

    1. Redis主从同步 Redis支持主从同步.数据可以从主服务器向任意数量的从服务器上同步,同步使用的是发布/订阅机制. 2. 配置主从同步 Mater Slave的模式,从Slave向Maste ...

  2. Redis 主从配置和参数详解

    安装redis 下载redis wget http://download.redis.io/releases/redis-3.0.7.tar.gz 解压redis tar -xvf redis-.ta ...

  3. 基于Windows服务器集群的Redis主从配置指南

    前段时间一个项目因并发量大.因防止宕机做了主从备份,首页的表连接查询又非常的耗时.故此拿出利器Redis缓存这个查询结果,并随着用户操作而更新. 因官方目前只有linux版,Windows版下载:  ...

  4. redis 主从同步

    修改redis.conf配置文件 vi redis.conf 在编辑模式下 输入  /slaveof 来搜索 将slaveof启用 即 将#删除 依次配置所有 slave 并将进程 kill 掉 重启 ...

  5. redis主从 以及认证配置

    以前用redis用的很多,各种数据类型用的飞起,算是用得很溜了.不过那都是封装好的方法,自己直接调用.以前的公司比较规范,开发只是开发,很少去做跟运维相关的事情. 换了一份工作,不过这边项目刚开始起步 ...

  6. Redis-cluster集群【第三篇】:redis主从

    Redis主从复制原理: 通过把这个RDB文件或AOF文件传给slave服务器,slave服务器重新加载RDB文件,来实现复制的功能! 复制的话:主服务器可以有多个从服务器!!!  不仅这样从服务器还 ...

  7. Redis主从自动failover

    Redis主从架构持久化存在一个问题,即前次测试的结论,持久化需要配置在主实例上才能跨越实例保证数据不丢失,这样以来主实例在持久化数据到硬 盘的过程中,势必会造成磁盘的I/O等待,经过实际测试,这个持 ...

  8. redis主从遇到的两个坑

    最近在使用redis主从的时候做了下面两件事情: 1 希望redis主从从操作上分析,所有写操作都在master上写,所有读操作都在从上读. 2 由于redis的从是放在本地的,所以有的key的读写操 ...

  9. Redis主从配置详细过程

    Redis的主从复制功能非常强大,一个master可以拥有多个slave,而一个slave又可以拥有多个slave,如此下去,形成了强大的多级服务器集群架构.下面楼主简单的进行一下配置. 1.上面安装 ...

随机推荐

  1. 025_自动为其他脚本添加解释器信息#!/bin/bash

    #!/bin/bash#先使用 grep 判断对象脚本是否已经有解释器信息,如果没有则使用 sed 添加解释器以及描述信息if ! grep -q "^#!" $1; then # ...

  2. python 比较运算符

    x == y x < y x <= y x >= y x  != y x is y x is not y x in y x not in y >>> "f ...

  3. Visual Studio Code:以十六进制格式显示文件内容

    造冰箱的大熊猫@cnblogs 2019/9/4 发现Visual Studio Code很好用,无论是作为源代码编辑器还是文本编辑器在Win平台下用的都很不错.但有时候需要以十六进制格式查看数据文件 ...

  4. codevs 1166 矩阵取数游戏

    二次联通门 : codevs 1166 矩阵取数游戏 /* codevs 1166 矩阵取数游戏 SB区间dp dp[l][r] = max (dp[l + 1][r] + number[l], dp ...

  5. 一台服务器配置多个mysql实例

    在公司资源紧张的情况下,需要在一台服务器上部署多个数据库实例,现在就来实战一下该情况. 需要启动两个不同的端口,分别是3306和3307 [root@node1 ~]# mkdir /u01/mysq ...

  6. docker 容器内部访问宿主机

    在宿主机执行: ifconfig 然后查看 docker0 的那个网卡的 ip 地址,比如我的是 172.18.0.1

  7. pwn学习日记Day16 pwn原理理解

    CTF-Pwn入门及栈溢出原理解释 CTF pwn 中最通俗易懂的堆入坑指南 看雪论坛

  8. 分享图片压缩上传demo,可以选择一张或多张图片也可以拍摄照片

    2016-08-05更新: 下方的代码是比较OLD的了,是通过js进行图片的剪切 旋转 再生成,效率较低. 后来又整合了一个利用native.js本地接口的压缩代码 ,链接在这 .页面中有详细的说明, ...

  9. mysql中的union操作(整理)

    mysql中的union操作(整理) 一.总结 一句话总结: union两侧的字段数和字段类型要是一样的 union可以接多个 orderby和排序可以在最后的union组合之后 1.union简单实 ...

  10. Python Docstring 风格和写法学习

    什么是Python Docstring 和Java类似,Python也通过注释形式的Docstring给程序.类.函数等建立文档.通过Docstring建立的文档不仅对人来说有更好的可读性,也能够让I ...