postgres OOM相关问题

在尝试调整 PostgreSQL 的 work_mem 至8GB以处理大量复制数据时遇到问题,连续多次失败并触发了 Linux 的 OOM 保护机制。理论上,设置为8GB应该能够分配足够的内存给15个表,但实际操作中出现了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

测试一组copy数据

数据量比较大,调整work_mem为8G连续失败多次。查找原因log报出如下错误。





less -MN messages


想必是触发linux的OOM机制,具体触发条件测试,一会做SQL explain分析

大意上work_mem 8G理论上可以申请到8G*15 个表(120G)内存,虽然你可能并未使用,但是却触发了linux 内核安全机制。



* service[postgres-exporter] action nothing (skipped due to action :nothing) * runit_service[postgres-exporter] action enable * ruby_block[restart_service] action nothing (skipped due to action :nothing) * ruby_block[restart_log_service] action nothing (skipped due to action :nothing) * ruby_block[reload_log_service] action nothing (skipped due to action :nothing) * directory[/opt/gitlab/sv/postgres-exporter] action create (up to date) * template[/opt/gitlab/sv/postgres-exporter/run] action create (up to date) * directory[/opt/gitlab/sv/postgres-exporter/log] action create (up to date) * directory[/opt/gitlab/sv/postgres-exporter/log/main] action create (up to date) * template[/opt/gitlab/sv/postgres-exporter/log/config] action create (up to date) * ruby_block[verify_chown_persisted_on_postgres-exporter] action nothing (skipped due to action :nothing) * link[/var/log/gitlab/postgres-exporter/config] action create (up to date) * template[/opt/gitlab/sv/postgres-exporter/log/run] action create (up to date) * directory[/opt/gitlab/sv/postgres-exporter/env] action create (up to date) * ruby_block[Delete unmanaged env files for postgres-exporter service] action run (skipped due to only_if) * template[/opt/gitlab/sv/postgres-exporter/check] action create (skipped due to only_if) * template[/opt/gitlab/sv/postgres-exporter/finish] action create (skipped due to only_if) * directory[/opt/gitlab/sv/postgres-exporter/control] action create (up to date) * link[/opt/gitlab/init/postgres-exporter] action create (up to date) * file[/opt/gitlab/sv/postgres-exporter/down] action nothing (skipped due to action :nothing) * directory[/opt/gitlab/service] action create (up to date) * link[/opt/gitlab/service/postgres-exporter] action create (up to date) * ruby_block[wait for postgres-exporter service socket] action run (skipped due to not_if) * file[/var/log/gitlab/postgres-exporter/current] action touch (skipped due to only_if) (up to date) * template[/var/opt/gitlab/postgres-exporter/queries.yaml] action create (up to date) * consul_service[postgres-exporter] action delete * file[/var/opt/gitlab/consul/config.d/postgres-exporter-service.json] action delete (up to date) (up to date) Recipe: gitlab::database_reindexing_disable * crond_job[database-reindexing] action delete * file[/var/opt/gitlab/crond/database-reindexing] action delete (up to date) (up to date) [2025-07-14T15:35:11+08:00] INFO: Cinc Client Run complete in 67.143192279 seconds Running handlers: [2025-07-14T15:35:11+08:00] INFO: Running report handlers Running handlers complete [2025-07-14T15:35:11+08:00] INFO: Report handlers complete Infra Phase complete, 0/821 resources updated in 01 minutes 10 seconds [2025-07-14T15:35:11+08:00] WARN: This release of Cinc Client became end of life (EOL) on May 1st 2024. Please update to a supported release to receive new features, bug fixes, and security updates. gitlab Reconfigured!
最新发布
07-15
<think>我们注意到用户提供的是GitLab配置过程中的日志片段。从日志中可以看出,最后显示的是成功完成配置,没有错误。 之前的错误日志(在用户之前的问题中)已经处理过,而这次提供的日志显示的是成功运行的部分。 具体分析: 1. 日志中运行了与postgres-exporter相关的runit_service启用操作,所有步骤都是“up to date”或“skipped”,说明已经是最新状态,无需更改。 2. 删除了consul_service中的postgres-exporter服务配置(因为可能不再需要)。 3. 删除了定时重新索引数据库的cron任务(database-reindexing)。 4. 最后显示“gitlab Reconfigured!”,表示整个配置过程成功完成。 因此,我们可以得出结论:这次`gitlab-ctl reconfigure`命令执行成功。 但是,用户可能关心的是之前失败的问题是否已经解决。从日志看,之前的错误(如数据库迁移失败)在此次日志中未出现,说明在解决了内存问题(如增加交换空间)后,重新运行配置成功。 回答重点: - 确认本次配置成功完成。 - 提醒用户之前的问题OOM)已经通过增加交换空间等方式解决。 根据规则,我们还需要在最后提出3-5个相关问题。 注意:由于用户提供的日志是成功的,所以相关问题可以围绕成功后的验证、后续优化等。 回答结构: 1. 分析日志,指出成功完成。 2. 解释关键步骤(如postgres-exporter服务的处理、删除consul服务、删除cron任务等)。 3. 给出成功后的建议(如验证服务状态)。 4. 提出相关问题。 注意:必须用中文回答,且最后输出“§§相关问题§§”并列出3-5个问题。</think>根据提供的日志,GitLab 的 `reconfigure` 过程已**成功完成**。关键信息如下: ### 成功标志 1. **最终状态确认** ```bash Infra Phase complete, 0/821 resources updated in 01 minutes 10 seconds gitlab Reconfigured! ``` - 所有 821 个资源配置检查通过,零资源需要更新 - 总耗时 1 分 10 秒完成重配置 2. **关键组件状态** - **Postgres-Exporter 服务** ```bash runit_service[postgres-exporter] action enable (up to date) ``` 监控服务已启用且处于最新状态 - **定时任务清理** ```bash crond_job[database-reindexing] action delete (up to date) ``` 已移除数据库重索引定时任务 3. **无错误报告** ```bash Running handlers complete Report handlers complete ``` 未触发任何错误处理机制 ### 配置验证建议 ```bash # 检查核心服务状态 sudo gitlab-ctl status # 验证数据库连接 sudo gitlab-rake gitlab:db:check # 查看监控指标(Postgres-Exporter) curl http://localhost:9187/metrics ``` ### 注意事项 1. **日志末尾警告** ```bash [2025-07-14T15:35:11+08:00] WARN: This release of Cinc Client became end of life (EOL) on May 1st 2024 ``` - 需升级 Cinc Client(GitLab 的 Chef 组件)以获取安全更新 2. **初始密码安全** - 初始 root 密码仍存储在 `/etc/gitlab/initial_root_password` - 建议立即重置: ```bash sudo gitlab-rake "gitlab:password:reset[root]" ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值