redis錯誤:redis.exceptions.ResponseError: 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錯誤:redis.exceptions.ResponseError: 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被配置為保存數據庫快照,但它目前不能持久化到硬盤。用來修改集合數據的命令不能用。請查看Redis日志的詳細錯誤信息。
解決方法:
解決方法:
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
OK
127.0.0.1:6379> lpush myColour "red"
(integer) 1
127.0.0.1:6379> SET runoobkey redis
配置文件修改:
配置文件修改:
1、修改redis.conf文件:vi打開redis-server配置的redis.conf文件,
然后使用快捷匹配模式:/stop-writes-on-bgsave-error定位到stop-writes-on-bgsave-error字符串所在位置,接著把后面的yes設置為no即可。
2、在/etc/sysctl.conf 添加一項 ‘vm.overcommit_memory = 1’ ,然后重啟(或者運行命令’sysctl vm.overcommit_memory=1’ )使其生效。)
2、在/etc/sysctl.conf 添加一項 ‘vm.overcommit_memory = 1’ ,然后重啟(或者運行命令’sysctl vm.overcommit_memory=1’ )使其生效。)
內核參數overcommit_memory
overcommit_memory是內存分配策略
設置內存分配策略(可選,根據服務器的實際情況進行設置)
/proc/sys/vm/overcommit_memory
可選值:0、1、2。
0, 表示內核將檢查是否有足夠的可用內存供應用進程使用;如果有足夠的可用內存,內存申請允許;否則,內存申請失敗,并把錯誤返回給應用進程。
1, 表示內核允許分配所有的物理內存,而不管當前的內存狀態如何。
2, 表示內核允許分配超過所有物理內存和交換空間總和的內存
有三種方式修改內核參數,但要有root權限:
編輯vim /etc/sysctl.conf ,改vm.overcommit_memory=1,然后sysctl -p 使配置文件生效
sysctl vm.overcommit_memory=1
echo 1 > /proc/sys/vm/overcommit_memory 不需要啟機器就生效
posted on 2021-01-07 10:13 Benjamin 閱讀(2429) 評論(0) 編輯 收藏 引用 所屬分類: 數據庫