快取索引檔案擴容和故障修復
索引檔案擴容
當錯誤日誌檔案 /usr/local/oredge-node/logs/error.log 中出現 “cache index database is full: MDB_MAP_FULL: Environment mapsize limit reached, considering raising the map size?” 的時候表示快取索引檔案所需大小超過了當前所配置的值。出現這個問題的時候不影響資料轉發,只會影響 HTTP 快取清理的功能。
在這種情況下,我們應該根據實際情況對 cache index 檔案進行擴容。
擴容的步驟
- 修改 nginx.conf 配置:/usr/local/oredge-node/conf/nginx.conf
cache_index_map_size 1024m;
修改大小為需要的值,如 1024m(1GB)。
- 修改 config.ini 配置:/usr/local/oredge-node/conf/config.ini
請注意:如果您使用的 OpenResty Edge 版本小於 23.6.1
,則需要在 /usr/local/oredge-node/conf/or-config.ini 中進行配置。同時,需要通知我們更新您的配置包配置,否則,後續的配置包升級將會還原您本次的修改。
[cache]
index = /usr/local/oredge-node/data/cache_index.lmdb
enabled = true
lmdb_size = 1024m
修改大小為需要的值,如 1024m(1GB)。這個配置需要和 nginx.conf 中的值一致。
- 重啟 OpenResty Edge Node
systemctl restart oredge-node
- 檢查配置是否生效:
ls -lh /usr/local/oredge-node/data/config.lmdb/usr/local/oredge-node/data/cache_index.lmdb
看到大小變為配置的大小(如 1GB),則說明配置生效。
索引檔案修復
當錯誤日誌檔案 /usr/local/oredge-node/logs/error.log 中出現 “cache index unable to seek cursor: MDB_CORRUPTED: Located page was wrong type” 的時候,
表示索引檔案已經被損壞了,這時候需要刪除索引檔案。因為把索引檔案刪除了,這會導致已經快取的檔案的 cache purge
功能失效。
出現這種問題的原因多數情況下是索引檔案的資料還沒有同步到磁碟就意外關機導致的,比如機器意外斷電。
刪除索引檔案並重啟 OpenResty Edge Node
- 刪除舊的索引檔案
sudo rm -fr /usr/local/oredge-node/data/cache_index.lmdb/*
- 重啟 OpenResty Edge Node
systemctl restart oredge-node