Redis问题修复
Redis问题修复
shawnplaying 发表于11个月前
Redis问题修复
  • 发表于 11个月前
  • 阅读 25
  • 收藏 1
  • 点赞 0
  • 评论 0

新睿云服务器60天免费使用,快来体验!>>>   

Redis出现如下问题

MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

Redis日志报如下错误:

16149:M 05 Apr 09:26:19.054 * 1 changes in 3600 seconds. Saving...
16149:M 05 Apr 09:26:19.054 # Can't save in background: fork: Cannot allocate memory
16149:M 05 Apr 09:26:25.085 * 1 changes in 3600 seconds. Saving...
16149:M 05 Apr 09:26:25.085 # Can't save in background: fork: Cannot allocate memory
16149:M 05 Apr 09:26:31.018 * 1 changes in 3600 seconds. Saving...
16149:M 05 Apr 09:26:31.018 # Can't save in background: fork: Cannot allocate memory

参考这篇文章:

http://blog.csdn.net/zqz_zqz/article/details/53384854

这个问题在于swap太小,当时查看swap只有200MB。解决方式是从lv_root中减掉10GB,然后增加到lv_swap中去。

问题分析,grep -i commit /proc/meminfo中看到Committed_AS>CommitLimit,而

CommitLimit = 物理内存 * overcommit_ratio(/proc/sys/vm/overcmmit_ratio,默认50,即50%) + swap大小

所以这就意味着是swap空间不够,因此方案是增加swap。

问题结果过程中重要命令如下:

[root@hadoop1 ~]# lvs
  LV           VG       Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root      VolGroup -wi-ao----  99.31g                                             
  lv_swap      VolGroup -wi-ao---- 204.00m                                             
  apphome_lv   appvg    -wi-ao----  50.00g                                             
  filevault_lv appvg    -wi-ao----  40.00g                                             
[root@hadoop1 ~]# 
[root@hadoop1 ~]# lvresize -L-10G VolGroup/lv_root
  WARNING: Reducing active and open logical volume to 89.31 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_root? [y/n]: y
  Reducing logical volume lv_root to 89.31 GiB
  Logical volume lv_root successfully resized
[root@hadoop1 ~]# lvs
  LV           VG       Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root      VolGroup -wi-ao----  89.31g                                             
  lv_swap      VolGroup -wi-ao---- 204.00m                                             
  apphome_lv   appvg    -wi-ao----  50.00g                                             
  filevault_lv appvg    -wi-ao----  40.00g     


[root@hadoop1 ~]# lvresize -L+10G VolGroup/lv_swap
  Extending logical volume lv_swap to 10.20 GiB
  Logical volume lv_swap successfully resized
[root@hadoop1 ~]# 
[root@hadoop1 ~]# 
[root@hadoop1 ~]# lvs
  LV           VG       Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root      VolGroup -wi-ao---- 89.31g                                             
  lv_swap      VolGroup -wi-ao---- 10.20g                                             
  apphome_lv   appvg    -wi-ao---- 50.00g                                             
  filevault_lv appvg    -wi-ao---- 40.00g                                             
[root@hadoop1 ~]# 


[root@hadoop1 ~]# mkswap /dev/VolGroup/lv_swap
/dev/VolGroup/lv_swap: Device or resource busy
[root@hadoop1 ~]# 

[root@hadoop1 etc]# swapoff -v /dev/VolGroup/lv_swap
swapoff on /dev/VolGroup/lv_swap
[root@hadoop1 etc]# 

[root@hadoop1 etc]# mkswap /dev/VolGroup/lv_swap
mkswap: /dev/VolGroup/lv_swap: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 10694652 KiB
no label, UUID=1f4d708f-fb1b-420c-9514-e05cb41c42cd
[root@hadoop1 etc]# 

[root@hadoop1 etc]# swapon /dev/VolGroup/lv_swap
[root@hadoop1 etc]# free
             total       used       free     shared    buffers     cached
Mem:       8061748    7206232     855516          0     130248    2434436
-/+ buffers/cache:    4641548    3420200
Swap:     10694648          0   10694648
[root@hadoop1 etc]# 
[root@hadoop1 etc]# free -g
             total       used       free     shared    buffers     cached
Mem:             7          7          0          0          0          2
-/+ buffers/cache:          4          3
Swap:           10          0         10
[root@hadoop1 etc]# free
             total       used       free     shared    buffers     cached
Mem:       8061748    7895092     166656          0     124056    3017144
-/+ buffers/cache:    4753892    3307856
Swap:     10694648          0   10694648

 

标签: redis swap
  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 14
博文 125
码字总数 70640
×
shawnplaying
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: