背景:

之前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. 020_统计 13:30 到 14:30 所有访问 apache 服务器的请求有多少个

    统计 13:30 到 14:30 所有访问 apache 服务器的请求有多少个 #!/bin/bash#awk 使用-F 选项指定文件内容的分隔符是/或者:#条件判断$7:$8 大于等于 13:30, ...

  2. luogu P4859 已经没有什么好害怕的了

    嘟嘟嘟 题中给的\(k\)有点别扭,我们转换成\(a > b\)的对数是多少,这个用二元一次方程解出来是\(\frac{n + k}{2}\). 然后考虑dp,令\(dp[i][j]\)表示前\ ...

  3. 解决百度文字识别SDK拍照不回调问题

    在使用百度文字识别SDK的时候,发现点了拍照后camera.takePicture(ShutterCallback shutter, PictureCallback raw,PictureCallba ...

  4. Leetcode题目287.寻找重复数(中等)

    题目描述: 给定一个包含 n + 1 个整数的数组 nums,其数字都在 1 到 n 之间(包括 1 和 n),可知至少存在一个重复的整数.假设只有一个重复的整数,找出这个重复的数. 示例 1: 输入 ...

  5. SpringBoot RestTemplate接收文件,并将文件发送到另外一个程序进行存储

    最近有个需求,接收用户上报的证书,并且保存起来,证书大小不到1M,但该证书的保存必须在另外一个程序进行,所以想到使用springboot接收上传文件后,再通过RestTemplate将文件发送给另外一 ...

  6. mysql数据库学习二

    最近又复习了mysql中的一些概念:视图,触发器,存储过程,函数,事务,记录下. 1.视图 视图是一个虚拟表,本身并不存储数据,当sql在操作视图时所有数据都是从其他表中查出来的,因此其本质是:根据S ...

  7. 2.5 Go语言基础之map

    Go语言中提供的映射关系容器为map, Go中内置类型,其内部使用散列表(hash)实现,为引用类型. 无序键值对(key-value)集合,通过key(类似索引)快速检索数据 必须初始化才能使用. ...

  8. Java csv

    CsvWriter csvWriter = new CsvWriter("data2019052803.csv", ',', Charset.forName("UTF-8 ...

  9. 阶段5 3.微服务项目【学成在线】_day04 页面静态化_20-页面静态化-静态化测试-填写页面DataUrl

    启动前端和后端.轮播图的数据url可以在这里修改. 找到列表页面的轮播图,然后点击编辑 随便更新一个地址测试 提交后数据再次编辑 发现url没有变化 在pageService里面update方法把更新 ...

  10. 加载selenium库

    一.maven的下载.解压以及环境变量配置 1.下载maven: 官网下载地址:http://maven.apache.org/download.cgi 在Files下面下载对应的maven版本(官网 ...