首页 > 解决方案 > 如何从aws弹性beantalk环境中获取堆转储

问题描述

我们正在从运行在 aws elastic beanstalk 中的 tomcat 容器内运行的 Spring Boot 应用程序中获取 OutOfMemoryError。那么我如何从弹性豆茎中获得堆转储?

https://stackoverflow.com/a/48110954/7024630 上面的答案建议了一种通过安装第三方依赖项来获取堆转储的方法,有没有办法直接从AWS Elastic Beanstalk 获取?

标签: javaspring-boottomcatout-of-memoryamazon-elastic-beanstalk

解决方案


试试这个检查 Elastic Beanstalk JVM heap的最佳方法,它对我有用。

就我而言,我使用的是 java 7:

$ which java
$ ls -lh /usr/bin/java
$ yum install java-1.7.0-openjdk-devel
$ yum --enablerepo='*-debug*' install java-1.7.0-openjdk-debuginfo
$ ps aux | grep tomcat
$ sudo -u tomcat jmap -dump:live,file=/tmp/test.hprof 12768
$ tar -czvf test.hprof.tar.gz /tmp/test.hprof
$ scp test.hprof.tar.gz xxxxxxxxxxxxx@x.y.z.w:~/

推荐阅读