Programmatically flush data to cassandra every time before cassandra shut down

StackOverflow https://stackoverflow.com/questions/20520839

  •  31-08-2022
  •  | 
  •  

Вопрос

I am using embedded Cassandra. When I shut down and restart my Cassandra service data is lost. I think decent data are not properly flushed into the disk. So I tried using nodetool to flush data manually and check if data are available. But nodetool doesn't seem to work properly for embedded Cassandra service. I get the following error:

c:\vijay\cassandra\bin>nodetool -host 192.168.2.86 -p 7199 drain

Starting NodeTool

Failed to connect to '192.168.2.86:7199': Connection refused: connect

I tried setting jmx properties still I am getting error. I added following lines to my code:

System.setProperty("com.sun.management.jmxremote", "true");
System.setProperty("com.sun.management.jmxremote.port", "7197");
System.setProperty("com.sun.management.jmxremote.authenticate", "false");
System.setProperty("com.sun.management.jmxremote.ssl", "false");
System.setProperty("java.rmi.server.hostname", "my ip");

So, is there any way to manually flush data to Cassandra without using nodetool?

Edit 1:
After hours of trying I am now able to run nodetool (instead of adding jmx configurations to the code I added to Eclipse debug configurations and it worked). I ran drain command now the data is properly flushed to the disk. So now my question is: why isn't data properly flushed? Every time when I restart Cassandra service recent changes are gone.

Это было полезно?

Решение 2

Commitlogs are not properly flushed in cassandra versions 1.1.0 to 1.1.4 This is a open issue. Please refer the following jira ticket.

Commitlog not replayed after restart

Другие советы

How are you stopping and starting the Cassandra server? The call to stopServer on the Cassandra daemon should be flushing any outstanding writes to the commit log. The thread will continue to do some processing even after the method returns, so if you're killing the JVM after stopServer() then you might be preventing the data from being written.

Most likely because of your commitlog settings. If you are using periodic mode, try reducing the sync window or your use batch. Batch will make writes slightly slower.

https://github.com/apache/cassandra/blob/trunk/conf/cassandra.yaml#L231

It may be that a flush is issued but is failing. Flushing should be recorded in the logs. Verify that you are not flushing. If you are flushing and it is failing, there should be some indication of why flush failed.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top