redis32位內存限制

這周,部署的redis服務器出現oom(out  of memory)錯誤,導致所有的寫操作都失敗,影響了所有線上部署的使用redis的相關應用。

經過分析,發現部署的32位redis實例能使用的最大內存只能爲4G(實際使用不到4G),配置文件中配置的30G沒有用。如果沒有配置最大內存,redis服務器在啓動的時候會將最大內存設置爲3G,以避免發生oom錯誤。在前期沒有調研充分以發現32位實例的這個限制,在實際使用中隨着數據的迅速增長,最終引起了該問題。

現把redis從32位實例升級到64位實例,從而解決了該問題。因爲32位實例和64位實例生成的rdb文件和aof文件在兩個實例之間是相互兼容的,因而沒有導致數據的丟失,是不幸中的萬幸,記錄此事件以吸取教訓。

(官方解釋:Redis compiled with 32 bit target uses a lot less memory per key, since pointers are small, but such an instance will be limited to 4 GB of maximum memory usage. To compile Redis as 32 bit binary usemake 32bit. RDB and AOF files are compatible between 32 bit and 64 bit instances (and between little and big endian of course) so you can switch from 32 to 64 bit, or the contrary, without problems.)

 

1.redis在收到讀寫請求時,會檢查是否設置了最大內存限制,如果設置了會嘗試釋放無用內存,如果釋放內存失敗,而且命令可能佔用大量內存,則返回錯誤command not allowed when used memory > 'maxmemory'.,對命令不予執行。

2.redis服務器在啓動從aof文件進行數據導入的時候,會按一定頻率間隔進行外來請求處理,此時所有的請求會返回錯誤Redis is loading the dataset in memory.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章