LMDB增加map_size [英] LMDB increase map_size

查看:910
本文介绍了LMDB增加map_size的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用LMDB ++(LMDB的C ++包装器),但出现此错误:

I was working with LMDB++ (the C++ wrapper for LMDB) and I got this error:

terminate called after throwing an instance of 'lmdb::map_full_error' what(): mdb_put: MDB_MAP_FULL: Environment mapsize limit reached

terminate called after throwing an instance of 'lmdb::map_full_error' what(): mdb_put: MDB_MAP_FULL: Environment mapsize limit reached

一些谷歌搜索人员告诉我,LMDB中的默认map_size设置为低.如何增加map_size?

Some googling told me that the default map_size is set low in LMDB. How do I go about increasing map_size?

推荐答案

默认LMDB映射大小为10 MiB,对于大多数用途来说确实太小了.

The default LMDB map size is 10 MiB, which is indeed too small for most uses.

要使用 C ++包装器设置LMDB映射大小,您应在紧接之后调用lmdb::env#set_mapsize()创建您的LMDB环境,并在打开环境或创建事务之前.

To set the LMDB map size using the C++ wrapper, you ought to call lmdb::env#set_mapsize() right after creating your LMDB environment and prior to opening the environment or creating your transaction.

这是一个将地图大小增加到1 GiB的基本示例:

Here's a basic example that increases the map size to 1 GiB:

/* Create and open the LMDB environment: */
auto env = lmdb::env::create();
env.set_mapsize(1UL * 1024UL * 1024UL * 1024UL);
env.open("./example.mdb", 0, 0664);

如果您如上例中那样计算较大的地图大小,请注意在整数文字中包括适当的类型后缀(ULULL),否则您可能会遇到无声整数溢出而被遗忘的情况.想知道为什么地图尺寸没有达到您的预期.

If you are calculating a large map size as in the above example, take care to include the appropriate type suffix (UL or ULL) on your integer literals, or else you may encounter silent integer overflow and be left wondering why the map size did not increase to what you expected.

另请参阅LMDB基础C函数 mdb_env_set_mapsize() 的文档.关于地图尺寸如何工作的权威性词汇.

See also the documentation for LMDB's underlying C function mdb_env_set_mapsize() for the authoritative word on how the map size works.

这篇关于LMDB增加map_size的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆