Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

wdeng avatar image
wdeng asked ·

我想看一下commitlog文件中的内容,但是没有发现可行的方案,想问一下该怎么办?

我看了看nodetool和jmx,并没有找到相关的功能,但是不确定是不是自己漏掉了。

commitlog
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

wdeng avatar image
wdeng answered ·

读取Commitlog内容的开源代码,很久以前Apache Cassandra Committer的圈子里提到过这个:https://github.com/carloscm/cassandra-commitlog-extract。但是这个现在没法直接拿来用,因为是Cassandra的史前时代(2012年)写的。只能看看有没有借鉴意义。


新一点的代码里,CDC(Change Data Capture)也需要读CommitLog,可以看看这里的函数调用:https://github.com/apache/cassandra/blob/e31e216234c6b57a531cae607e0355666007deb2/src/java/org/apache/cassandra/db/commitlog/CommitLogReplayer.java#L132-L140,有一个叫org.apache.cassandra.db.commitlog.CommitLogReader的类可以直接拿来用。CDC的这个文档里有提及:http://cassandra.apache.org/doc/latest/operating/cdc.html#reading-commitlogsegments

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.