Clickhosue & ck & ch DB::Exception: Memory limit (total) exceeded
1.异常信息
<Error> ConfigReloader: void DB::ConfigReloader::run(): Code: 241, e.displayText() = DB::Exception: Memory limi t (total) exceeded: would use 19.24 GiB (attempt to allocate chunk of 5242880 bytes), maximum: 18.63 GiB, Stack trace (when copying this message, alway s include the lines below):
0. Poco::Exception::Exception(std::1::basic_string<char, std::1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x18e02790 in /usr/b in/clickhouse
1. DB::Exception::Exception(std::1::basic_string<char, std::1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0xe72fdad in /usr/bin/ clickhouse
2. ? @ 0xe71dee0 in /usr/bin/clickhouse
3. MemoryTracker::alloc(long) @ 0xe71c798 in /usr/bin/clickhouse
4. operator new[](unsigned%20long) @ 0xe71af6c in /usr/bin/clickhouse
5. Poco::XML::NamePool::NamePool(unsigned long) @ 0x18d84fca in /usr/bin/clickhouse
2.解决
1.config.xml
修改每个节点上的config.xml配置文件里的服务器使用最大RAM量
<max_server_memory_usage>xxx</max_server_memory_usage>
2.users.xml
修改每个节点上的users.xml配置文件里的,用于在单个服务器上运行查询的最大RAM量
<max_memory_usage>xxx</max_memory_usage>
3.扩展
1.max_memory_usage
含义:用于在单个服务器上运行查询的最大RAM量
默认值: 10G
内存的使用也受限于这两个参数
1)max_memory_usage_for_user
用于在单个服务器上运行用户查询的最大RAM量
默认值定义在 Settings.h (https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.h)
默认值是0, max_memory_usage_for_user = 0 表示不受限
2)max_server_memory_usage
详见 2
2.max_server_memory_usage
含义:限制ClickHouse服务器节点的总RAM使用量
默认值: 0 默认情况下的计算公式如下:
max_server_memory_usage = memory_amount(内存总量) * max_server_memory_usage_to_ram_ratio(占比分数值)
3.max_server_memory_usage_to_ram_ratio
含义:定义可用于Clickhouse服务器的总物理RAM量的一部分。如果想要服务器利用更多资源(限制ck应用在内存占用),则会将内存减少到适当的数量
默认值:0 表示Clickhouse服务器可以使用所有可用的RAM
官方建议:
在具有低RAM和交换容量的主机上,可能需要将max_server_memory_usage_to_ram_ratio设置为大于1
标签:
大数据
, clickhouse
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)