redis連接錯誤System Error MISCONF Redis is configured to save RDB snapshots, but XX
情況1解決辦法:
由於強制停止redis快照,不能持久化引起的。
在客戶端輸入
config set stop-writes-on-bgsave-error no
情況2解決辦法:
Redis在保存數據到硬盤時為了避免主進程假死,需要Fork一份主進程,然后在Fork進程內完成數據保存到硬盤的操作,如果主進程使用了4GB的內存,Fork子進程的時候需要額外的4GB,此時內存就不夠了,Fork失敗,進而數據保存硬盤也失敗了。
修改vm.overcommit_memory=1
// 原文:http://pydelion.com/2013/05/27/redis-cant-save-in-background-fork-cannot-allocate-memory/ If you get this error Can't save in background: fork: Cannot allocate memory it means that your current database is bigger than memory you have. To fix the issue enable vm.overcommit_memory: sysctl vm.overcommit_memory=1 To have if after reboot add this line to /etc/sysctl.cnf: vm.overcommit_memory=1
情況3解決辦法:
Permission denied持久化文件無權限,改一下文件夾權限就解決了
chmod 777 /xxx/redis_data
當然是那種情況需要先看看redis日志文件。
redis在默認情況下,是不會生成日志文件的,所以需要配置 配置方法:
1、首先找到redis的配置文件
2、打開配置文件,直接搜logfile ""
3、將路徑填入logfile后面的引號內,例如:logfile "/plus/data/redis_data/redislog/redis.log"
4、手動建立了/plus/data/redis_data/redislog文件夾,日志文件不用建,重啟redis會自動生成