一、說明
首先說明一下我的叢集部署情況:
在三台機器上部署了包含三個節點的叢集,通過nodetool查看到的資訊如所示
現在想刪除節點10.202.67.72,在該節點中建立過Keyspace20130101,其具體參數為
create keyspace Keyspace20130101 with placement_strategy='org.apache.cassandra.locator.SimpleStrategy' and strategy_options={replication_factor:1};
由於strategy_options={replication_factor:1},所以該keyspace只在節點10.202.67.72上有資料,刪除該節點將丟失這部分資料,所以在正式的部署環境中建議採用合適的副本策略。
二、刪除操作
1、down掉節點10.202.67.72------刪除節點之前必須把要刪除節點down掉,否則提示不能刪除本身
2、使用removenode移除已經斷開的節點:
./nodetool removenode <被移除的host id>
查詢這個host id用命令:./nodetool status,如所示,節點10.202.67.72的host id是:0f57dc1e-e534-4f5f-8ff1-985538ce9691
3、完成上述刪除命令後可以查看到叢集狀態如下:ring上只有兩個節點,10.202.67.72已經被刪除
4、重新啟動節點10.202.67.72,然後查看狀態,發現此節點已經脫離上面的叢集,單獨組成了一個叢集
三、資料分析(基於副本策略)
通過cassandra-cli訪問10.202.92.92和10.202.92.93節點群組成的叢集,發現還可以看到Keyspace20130101,並且可以用命令use Keyspace20130101進入Keyspace20130101,但是當訪問裡面的資料的時候,提示錯誤,不能正確訪問資料,出現這個現象的原因就是由於我們建立Keyspace20130101時設定strategy_options={replication_factor:1},這樣伴隨著Keyspace20130101的刪除資料也脫離了原來的叢集。
PS:歡迎大家繼續補充,補充更全面的情境
參考:http://blog.chinaunix.net/uid-20104120-id-3468254.html