初始令牌的设置
使用强大的哈希函数应该会使键均匀分散,但据说MD5不够强大。
# nodetool ring
Note: Ownership information does not include topology, please specify a keyspace.
Address DC Rack Status State Load Owns Token
161038431783640996747061834539477326541
10.10.10.1 datacenter1 rack1 Up Normal 56.08 KB 59.76% 92566278802770359146832254620092330417
10.10.10.2 datacenter1 rack1 Up Normal 60.69 KB 5.16% 101344869056471442016922121422834278883
10.10.10.3 datacenter1 rack1 Up Normal 56.18 KB 18.41% 132670840620665264014573975366691587616
10.10.10.4 datacenter1 rack1 Up Normal 60.49 KB 5.90% 142707366785106214210137953545520747214
10.10.10.5 datacenter1 rack1 Up Normal 56.18 KB 10.77% 161038431783640996747061834539477326541
由于数据未加载,需要设置initial_token。
如果可以停止进程的话,那是可以的。
首先关闭进程。
# /etc/init.d/cassandra stop
2. 刪除資料
# rm -rf /var/lib/cassandra/data/*
# rm -rf /var/lib/cassandra/commitlog/*
# rm -rf /var/lib/cassandra/aved_caches/*
计算初始令牌。
# token-generator 5
DC #1:
Node #1: 0
Node #2: 34028236692093846346337460743176821145
Node #3: 68056473384187692692674921486353642290
Node #4: 102084710076281539039012382229530463435
Node #5: 136112946768375385385349842972707284580
4. 每个节点都要设置初始令牌。
# Node1
initial_token: 0
# Node2
initial_token: 34028236692093846346337460743176821145
# Node3
initial_token: 68056473384187692692674921486353642290
# Node4
initial_token: 102084710076281539039012382229530463435
# Node5
initial_token: 136112946768375385385349842972707284580
5. 开动
# /etc/init.d/cassandra start
Starting Cassandra: [ OK ]
6. 审核戒指。
# nodetool ring
Note: Ownership information does not include topology, please specify a keyspace.
Address DC Rack Status State Load Owns Token
10.34.68.186 datacenter1 rack1 Up Normal 9.08 KB 100.00% 0
以后 (yǐ
# nodetool ring
Note: Ownership information does not include topology, please specify a keyspace.
Address DC Rack Status State Load Owns Token
34028236692093846346337460743176821145
10.10.10.1 datacenter1 rack1 Up Normal 13.51 KB 80.00% 0
10.10.10.2 datacenter1 rack1 Up Normal ? 20.00% 34028236692093846346337460743176821145
感觉不错
# nodetool ring
Note: Ownership information does not include topology, please specify a keyspace.
Address DC Rack Status State Load Owns Token
136112946768375385385349842972707284580
10.10.10.1 datacenter1 rack1 Up Normal 6.72 KB 60.00% 0
10.10.10.2 datacenter1 rack1 Up Normal 13.51 KB 20.00% 34028236692093846346337460743176821145
10.10.10.3 datacenter1 rack1 Up Normal 6.72 KB 20.00% 68056473384187692692674921486353642290
10.10.10.4 datacenter1 rack1 Up Joining 6.72 KB 0.00% 102084710076281539039012382229530463435
10.10.10.5 datacenter1 rack1 Up Joining 4.58 KB 0.00% 136112946768375385385349842972707284580
加入!! (jiā rù)
# nodetool ring
Note: Ownership information does not include topology, please specify a keyspace.
Address DC Rack Status State Load Owns Token
136112946768375385385349842972707284580
10.10.10.1 datacenter1 rack1 Up Normal 15.57 KB 20.00% 0
10.10.10.2 datacenter1 rack1 Up Normal 6.72 KB 20.00% 34028236692093846346337460743176821145
10.10.10.3 datacenter1 rack1 Up Normal 6.72 KB 20.00% 68056473384187692692674921486353642290
10.10.10.4 datacenter1 rack1 Up Normal 6.72 KB 20.00% 102084710076281539039012382229530463435
10.10.10.5 datacenter1 rack1 Up Normal 4.58 KB 20.00% 136112946768375385385349842972707284580
直译:噼里啪啦的声音
意译:一切完美、无懈可击
如果在线更改的话
在每个节点上执行nodetool move。
# nodetool -h ${NODE_IP} move ${割り当てるTOKEN}
听说要花很长时间,如果可以停下来的话,就停下来吧。