Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1783385
  • 博文数量: 276
  • 博客积分: 1574
  • 博客等级: 上尉
  • 技术积分: 2894
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-26 23:23
个人简介

生活的美妙在于,不知道一下秒是惊艳还是伤神,时光流转,珍惜现在的拥有的时光

文章分类

全部博文(276)

文章存档

2017年(17)

2016年(131)

2015年(63)

2013年(2)

2012年(32)

2011年(31)

分类: 服务器与存储

2015-11-04 13:46:58

在192.168.171.139:6381的redis上手动执行了slaveof 192.168.171.140 6381 后发现没有时行数据同步,查看日志发现有报错信息:
[codis@192_168_171_139 redis_conf]$ tail -f redis6381.log
...
[26050] 04 Nov 13:30:43.785 * Connecting to MASTER 192.168.171.140:6381
[26050] 04 Nov 13:30:43.785 * MASTER <-> SLAVE sync started
[26050] 04 Nov 13:30:43.786 * Non blocking connect for SYNC fired the event.
[26050] 04 Nov 13:30:43.786 * Master replied to PING, replication can continue...
[26050] 04 Nov 13:30:43.786 * Partial resynchronization not possible (no cached master)
[26050] 04 Nov 13:30:43.787 * Full resync from master: 82332b04925c01b400707707ea3c765c32f69e7c:1
[26050] 04 Nov 13:30:43.787 # MASTER aborted replication with an error: ERR Unable to perform background save
...
master端也有ERROR日志产生
[codis@192_168_171_140 redis_conf]$ tail -f redis6381.log
[26035] 04 Nov 13:36:40.900 * Slave asks for synchronization
[26035] 04 Nov 13:36:40.900 * Full resync requested by slave.
[26035] 04 Nov 13:36:40.900 * Starting BGSAVE for SYNC
[26035] 04 Nov 13:36:40.900 # Can't save in background: fork: Cannot allocate memory
[26035] 04 Nov 13:36:40.900 * Replication failed, can't BGSAVE
多主查询原因是redis启动时有报一个warning
[codis@192_168_171_140 redis_conf]$ head redis6381.log  -n 100
...
[12680] 03 Jun 19:18:37.372 # Server started, Redis version 2.8.13
[12680] 03 Jun 19:18:37.372 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
...
操作方式日志已经说得很清楚了
添加vm.overcommit_memory = 1到/etc/sysctl.conf或者sysctl vm.overcommit_memory=1临时生效.

vm.overcommit_memory = 1这个内核参数是内存分配策略

可选值:0、1、2。
0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
2, 表示内核允许分配超过所有物理内存和交换空间总和的内存

修改完之后可以看到日志显示已经在同步中
[codis@192_168_171_140 redis_conf]$ tail -f redis6381.log
...
[26035] 04 Nov 13:47:22.879 * Slave asks for synchronization
[26035] 04 Nov 13:47:22.880 * Full resync requested by slave.
[26035] 04 Nov 13:47:22.880 * Starting BGSAVE for SYNC
[26035] 04 Nov 13:47:22.917 * Background saving started by pid 19713
...
阅读(2719) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~