CassandraのUnrechableNodesが残ってしまっている時の対応方法
ググっては細かい流れを忘れるのでメモ。
この辺のブログとかがソース。
http://nartax.com/2012/09/assassinate-cassandra-node/
http://tumblr.doki-pen.org/post/22654515359/assassinating-cassandra-nodes
cassandraノードがHW障害等でダウンした時に一度removetoken等でクラスタから外した時にそのノード情報がnodetool ringでは問題無いがstorage proxyのmbeanを見るとUnrechableNodesに残っている時がある。で、これが残っていると余計な処理とかメモリとか色々と良いことが一個も無いのでAssassinateしないといけない。
方法としてはvisualVMとかであれば接続したノードのorg.apache.cassandra.db:type=StorageServiceにあるUnreachableNodesを格納されているIPを確認し、消してしまっても良いIPをorg.apache.cassandra.net:type=GossiperのOperationにあるunsafeAssassinateEndpointに引数にIPを入れて実行すれば良い。
もしjolokiaを使っている場合は192.168.0.1を削除したい場合
curl http://localhost:${jolokia_port}/jolokia/exec/org.apache.cassandra.net:type=Gossiper/unsafeAssassinateEndpoint/192.168.0.1
でOK。
余談
で、テストで存在しないIPを入れて実施すると何故かunsafeAssassinateEndpoint自体は正常だが存在しないtokenをremoveしたというログも出る。1.1.5だがソースを読むとGossiper.javaで
public void unsafeAssassinateEndpoint(String address) throws UnknownHostException 内の 486行目から if (token == null) token = StorageService.instance.getBootstrapToken(); // do not pass go, do not collect 200 dollars, just gtfo epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.left(token, computeExpireTime())); handleMajorStateChange(endpoint, epState); try
となっていて、もしtokenが存在しないnodeだった場合はbootstrapで生成されるtokenをとりあえず入れて削除処理を実行している様子。