缓存索引文件扩容和故障修复

索引文件扩容

当错误日志文件 /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)。

  • 修改 /usr/local/oredge-node/conf/config.ini 配置文件,添加以下配置:

请注意:如果您使用的 OpenResty Edge 版本小于 23.6.1,则需要在 /usr/local/oredge-node/conf/or-config.ini 中进行配置。同时,需要通知我们更新您的配置包配置,否则,后续的配置包升级将会还原您本次的修改。

[cache]
lmdb_size = 1024m

修改大小为需要的值,如 1024m(1GB)。这个配置需要和 nginx.conf 中的值一致。

  • 重启 OpenResty Edge Node
systemctl start upgrade-oredge-node
  • 检查配置是否生效:
ls -lh /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 start upgrade-oredge-node