您好,欢迎访问一九零五行业门户网

redis突然掉电导致aof文件损坏修复一例

公司一批服务器突然掉电宕机,一通折腾后,发现redis未开启,去服务器启动redis,其中一台在将aof文件load进内存的时候,中断,总不能开启!现象是,load一段时
公司一批服务器突然掉电宕机,一通折腾后,发现redis未开启,去服务器启动redis,其中一台在将aof文件load进内存的时候,中断,总不能开启!
现象是,load一段时间之后,redis进程自动关闭!
查看日志文件,发现有如下内容:
[2716] 28 apr 10:16:51.234 # server started, redis version 2.8.8[2716] 28 apr 10:16:51.234 # 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.[2716] 28 apr 10:17:27.915 # bad file format reading the append only file: make a backup of your aof file, then use ./redis-check-aof --fix [2761] 28 apr 10:19:40.866 * increased maximum number of open files to 10032 (it was originally set to 1024).发现是aof文件损坏。
去redis数据目录,将aof文件备份,用redis-check-aof工具修复
[root@db redis]# cp appendonly.aof appendonly.aof.bak[root@db redis]# redis-check-aof --fix appendonly.aof0xc93488e5: expected prefix 'aof analyzed: size=3375772775, ok_up_to=3375663333, diff=109442this will shrink the aof from 3375772775 bytes, with 109442 bytes, to 3375663333 bytescontinue? [y/n]: ysuccessfully truncated aof重新启动,,发现redis启动完成!
投入生产,正常使用!
本文出自 “原下” 博客,请务必保留此出处
其它类似信息

推荐信息