redis : Can't save in background: fork: Cannot allocate memory
redis : Can't save in background: fork: Cannot allocate memory
JAVA程式報錯資訊:
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日誌:
18793:S 02 Dec 10:02:02.069 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:08.088 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:14.006 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:20.021 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:26.038 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:32.054 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:38.067 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:44.086 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:50.002 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:02:56.017 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:03:02.037 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:03:08.056 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:03:14.073 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:03:20.091 # Can't save in background: fork: Cannot allocate memory
18793:S 02 Dec 10:03:26.007 # Can't save in background: fork: Cannot allocate memory
資料回寫分同步和非同步兩種方式:
同步回寫(SAVE), 主程式直接向磁碟迴寫資料. 在資料量大的情況下會導致系統假死很長時間
非同步回寫(BGSAVE), 主程式fork後, 複製自身並透過這個新的程式回寫磁碟, 回寫結束後新程式自行關閉
由於 BGSAVE 不需要主程式阻塞, 系統也不會假死, 一般會採用 BGSAVE 來實現資料回寫.
redis在dump資料的時候會啟動fork子程式,由於記憶體不夠,導致無法持久化落盤
redis有個預設的選項:
stop-writes-on-bgsave-error yes
這個選項預設情況下,如果在RDB snapshots持久化過程中出現問題,設定該引數後,Redis是不允許使用者進行任何更新操作。
不徹底的解決方式是,將這個選項改為false
stop-writes-on-bgsave-error false
但是這樣只是當redis寫硬碟快照出錯時,可以讓使用者繼續做更新操作,但是寫硬碟仍然是失敗的
徹底解決方案:直接修改核心引數 vm.overcommit_memory = 1
編輯檔案 /etc/sysctl.conf 新增:
vm.overcommit_memory=1
執行sysctl -p使其生效
Linux核心會根據引數vm.overcommit_memory引數的設定決定是否放行。
vm.overcommit_memory = 1,直接放行
vm.overcommit_memory = 0:則比較 此次請求分配的虛擬記憶體大小和系統當前空閒的實體記憶體加上swap,決定是否放行。
vm.overcommit_memory = 2:則會比較程式所有已分配的虛擬記憶體加上此次請求分配的虛擬記憶體和系統當前的空閒實體記憶體加上swap,決定是否放行。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-2666454/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- fork failed - Cannot allocate memoryAI
- Redis 寫磁碟出錯 Cannot allocate memoryRedis
- VM warning: INFO: OS::commit_memory Cannot allocate memoryMIT
- 關閉tomcat報錯Cannot allocate memoryTomcat
- cenots7.6系統報“fork:Cannot allocate memory” 報錯的解決方法(實操)
- Ubuntu Cannot allocate memory 錯誤解決方案Ubuntu
- 阿里雲 Redis 報出You can't read against a non-read redis.解決方案阿里RedisAI
- TypeError: can‘t concat str to bytesError
- Can't open file: (errno: 24)
- Supervisor 解決 can't find command *
- Mongoose can't update timestampGo
- 【ASK_ORACLE】檢查點錯誤“Cannot allocate new log”和“Checkpoint not complete”Oracle
- Incorrect MEMORY_MAX_TARGET (> Available RAM) Can Lead To Database HangsAIDatabase
- eslint --fix 報錯 can't not find modulesEsLint
- mysql遇到Variable can’t be set to the value of ‘NULL’MySqlNull
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- Can't load IA 32-bit .dll on a
- multiprocessing pool AttributeError: Can't get attribute 'func'Error
- 【Redis】slaveof 報錯 Background transfer errorRedisError
- org.hibernate.TransientObjectException: object references an unsaved transient instance - save the tObjectException
- Python——UnicodeEncodeError: 'ascii' codec can't encode/decode charactersPythonUnicodeErrorASCII
- redis.conf之save配置項解讀Redis
- Non-static method 'save(java.long.Object)' cannot be referenced from a static context.JavaObjectContext
- FILESTREAM feature can't be enabled if you use cluster shared volumes
- WIN配置git 配置後失敗 can't be establishedGit
- Error:Can't connect to SOCKS proxy:Connection refused (Connection refused)Error
- Python報錯:UnicodeDecodeError: 'gbk' codec can't decode byte ...PythonUnicodeError
- Mysql:Variable 'XXXt' can't be set to the value of 'NULL'解決MySqlNull
- You can‘t specify target table ‘Person‘ for update in FROM clause
- 完美解決stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.ErrorPython
- golang,interface轉換型別 cannot convert t (typGolang型別
- Fatal error: can't check configuration file '/home/watt/proxy/dError
- 解決ERROR 1231 (42000): Variable 'time_zone' can'tError
- python cx_Oracle: UnicodeEncodeError: 'ascii' codec can't encode charactersPythonOracleUnicodeErrorASCII
- why this draw call can‘t be batched with the previous one for Unity2019.4+BATUnity
- MYSQL報1022錯誤:Can't write;duplicate key in table '.....'MySql
- mysql中You can’t specify target table for update in FROM clMySql
- redis4.0之MEMORY命令詳解Redis