Prevent Cassandra from dumping hprof files

I would like to stop Cassandra from dropping hprof files since I do not require their use.

I also have very limited disk space (50 GB of 100 GB is used for data) and these files consume all of the disk space before I can say stop.

How can I do it?

Is there a shell script I could use to erase these files from time to time?

+6
source share
3 answers

This is because Cassandra starts with the -XX:+HeapDumpOnOutOfMemoryError Java option. This is good material if you want to analyze. Also, if you get a lot of dump heaps that indicate that you should probably tune the memory available for Cassandra.

I have not tried. But to block this option, comment out the next line in $CASSANDRA_HOME/conf/cassandra-env.sh

 JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError" 

If you wish, you can also comment on this block, but I do not think that this is really not required. I think this block is available in version 1.0+. I can not find it in 0.7.3.

 # set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof" fi 

Let me know if this worked.


Update

... I guess this is the JVM, throwing it when Cassandra crashes / turns off. Any way to prevent this?

If you want to completely disable the JVM heap, see here how to disable java heap dump creation after VM crashes?

+7
source

I admit that I did not use Cassandra, but from what I can say, it should not dump any hprof files unless you include it at compile time or if the program throws an OutofMemoryException. Try to look there.

in terms of a shell script, if files are dumped to a specific location, you can use this command to delete all * .hprof files.

 find /my/location/ -name *.hprof -delete 

this uses the -delete directive from find , which deletes all files matching the search. Take a look at the man page for more search options if you need to narrow it down more.

You can use cron to run the script at a given time, which satisfies the β€œfrom time to time” requirement, most Linux distributions have cron installed and work with the crontab file. You can learn more about crontab using man crontab

+1
source

Even if you update cassandra-env.sh to point to the heapdump path, it still won't work. The reason was that from the upstart script / etc / init.d / cassandra there is this line that creates the default HeapDump path

 start-stop-daemon -S -c cassandra -a /usr/sbin/cassandra -b -p "$PIDFILE" -- \ -p "$PIDFILE" -H "$heap_dump_f" -E "$error_log_f" >/dev/null || return 2 

I'm not an upstart specialist, but what I did was just delete the parameter that creates the duplicate. Another strange observation is also when checking the cassandra process through ps aux, you will notice that you will see that some parameters are written twice. If you select cassandra-env.sh and type $ JVM_OPTS, you will notice that these variables are fine.

0
source

Source: https://habr.com/ru/post/907462/


All Articles