公司一批服務器突然掉電宕機,一通折騰后,發現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發現是aof文件損壞。
去redis數據目錄,將aof文件備份,用redis-check-aof工具修復
[root@db redis]# cp appendonly.aof appendonly.aof.bak [root@db redis]# redis-check-aof --fix appendonly.aof 0x c93488e5: Expected prefix ' AOF analyzed: size=3375772775, ok_up_to=3375663333, diff=109442 This will shrink the AOF from 3375772775 bytes, with 109442 bytes, to 3375663333 bytes Continue? [y/N]: y Successfully truncated AOF重新啟動,,發現redis啟動完成!
投入生產,正常使用!
本文出自 “原下” 博客,請務必保留此出處
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com