在 kubernetes pod 中出现 OOM 时保留堆转储吗?

发布于 2025-01-15 20:59:44 字数 354 浏览 3 评论 0原文

当 java 进程出现 OOM 且 pod 重新启动时,我需要保留堆转储。

我在 jvm args 中添加了以下内容

-XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/dumps

...并且emptydir安装在同一路径上。

但问题是,如果 Pod 重新启动并且它被安排在不同的节点上,那么我们就会丢失堆转储。即使 pod 被安排到不同的节点,如何保留堆转储?

我们正在使用 AWS EKS,并且我们有超过 1 个 Pod 副本。

有人可以帮忙解决这个问题吗?

I need to persist the heap dump when the java process gets OOM and the pod is restarted.

I have following added in the jvm args

-XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/dumps

...and emptydir is mounted on the same path.

But the issue is if the pod gets restarted and if it gets scheduled on a different node, then we are losing the heap dump. How do I persist the heap dump even if the pod is scheduled to a different node?

We are using AWS EKS and we are having more than 1 replica for the pod.

Could anyone help with this, please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往事随风而去 2025-01-22 20:59:44

由于在您的情况下写入 EFS 太慢,因此 AWS EKS 还有另一种选择 - awsElasticBlockStore

EBS 卷的内容会被持久化,并且当 Pod 被删除时,该卷也会被卸载。这意味着 EBS 卷可以预先填充数据,并且数据可以在 Pod 之间共享。

注意:您必须先使用 aws ec2 create-volume 或 AWS API 创建 EBS 卷,然后才能使用它。

使用 awsElasticBlockStore 卷时有一些限制:

  • 运行 Pod 的节点必须是 AWS EC2 实例
  • 这些实例需要与 EBS 卷位于同一区域和可用区
  • EBS 仅支持单个 EC2 实例挂载卷

检查k8s 官方文档请访问有关此主题的页面
以及如何在 EKS 中使用持久存储

As writing to EFS is too slow in your case, there is another option for AWS EKS - awsElasticBlockStore.

The contents of an EBS volume are persisted and the volume is unmounted when a pod is removed. This means that an EBS volume can be pre-populated with data, and that data can be shared between pods.

Note: You must create an EBS volume by using aws ec2 create-volume or the AWS API before you can use it.

There are some restrictions when using an awsElasticBlockStore volume:

  • the nodes on which pods are running must be AWS EC2 instances
  • those instances need to be in the same region and availability zone as the EBS volume
  • EBS only supports a single EC2 instance mounting a volume

Check the official k8s documentation page on this topic, please.
And How to use persistent storage in EKS.

笛声青案梦长安 2025-01-22 20:59:44

您必须将堆转储保留在 Pod 之间的共享网络位置上。为了实现这一点,您需要提供持久卷声明,在 EKS 中,这可以使用安装在不同可用区域上的弹性文件系统来实现。您可以通过阅读这份关于 EFS 的指南来开始了解它 -基于PVC。

You will have to persists the heap dumps on a shared network location between the pods. In order to achieve this, you will need to provide persistent volume claims and in EKS, this could be achieved using an Elastic File System mounted on different availability zones. You can start learning about it by reading this guide about EFS-based PVCs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文