Reputation:
I have an Elasticsearch cluster running on ec2 amazon server. As described in this article the way to capture a heap dump from a running JVM is to use jmap:
sudo jmap -dump:format=b,file=heap.hprof {processID}
error: {processID}: well-known file is not secure
Jmap requires the user that run the process so I have to execute the command like:
sudo -u elasticsearch jmap -dump:format=b,file=heap.hprof {processID}
error:
Dumping heap to /home/ubuntu/heap.hprof ...
Permission denied
So I guess I have to use jmap like this:
sudo -u elasticsearch sh -c "sudo jmap -dump:format=b,file=heap.hprof {processID}"
[sudo] password for elasticsearch:
What is the elasticsearch user password? Is there some default value? I didn't find any solution to this...
Upvotes: 4
Views: 5326
Reputation: 56
The solution is to run jmap as root, but ensure the the file is writtable by the Java application. Think that jmap sends the dump command to the java application, the but dump is run inside it
sudo jmap -dump:format=b,file=/path/to/writable/directory/by/elastic/user/heap.hprof {processID}
That's it
Upvotes: 0
Reputation: 533820
You need to make the directory you will write to, writable as the user which will do the writing, or you can use a directory every user can write to e.g.
sudo -u elasticsearch jmap -dump:format=b,file=/tmp/es-heap.hprof {processID}
Upvotes: 6