Cassandra集群管理-替换异常节点
Cassandra集群管理-替换异常节点
替换异常集群节点,使用JVM启动标志 Dcassandra.replace_address_first_boot =
如果替换过程所需的时间超过max_hint_window_in_ms,那么您必须运行repair以使所放置的节点再次保持一致,因为它在引导期间错过了正在进行的写入。
注意:
本文档只是体系文档中的一部分,前面文档信息详见:
测试准备+下线正常节点:https://blog.51cto.com/michaelkang/2419518
节点异常重启:https://blog.51cto.com/michaelkang/2419524
添加新节点:https://blog.51cto.com/michaelkang/2419521
删除异常节点:https://blog.51cto.com/michaelkang/2419525
查看集群状态
[root@kubm-01 ~]# nodetool status Datacenter: dc1-- Address Load Tokens Owns Host ID Rack.......异常节点状态为DNDN 172.20.101.166 76.83 MiB 256 ? 88e16e35-50dd-4ee3-aa1a-f10a8c61a3eb rack1
替换节点-注意事项
参考 "## Cassandra 集群添加节点"
https://blog.51cto.com/michaelkang/2419521
修改配置文件
vi /etc/cassandra/conf/jvm.options 如果要替换已死亡的节点,请在其位置重新启动指定死节点地址的新节点。 新节点的数据目录中不得包含任何数据.47行#-Dcassandra.replace_address=listen_address or broadcast_address of dead node修改配置文件:-Dcassandra.replace_address=172.20.101.166
清理无用数据、启动服务
执行前删除下列文件夹及内容:- data/- commitlog/- saved_caches/
rm -rf /var/lib/cassandra/启动:/etc/init.d/cassandra start
等待集群数据恢复完成,验证集群状态:
[root@kubnode-02 cassandra]# nodetool statusDatacenter: dc1===============Status=Up/Down|/ State=Normal/Leaving/Joining/Moving-- Address Load Tokens Owns Host ID Rack UN 172.20.101.164 68.13 MiB 256 ? dcbbad83-fe7c-4580-ade7-aa763b8d2c40 rack1 UN 172.20.101.165 59.21 MiB 256 ? b985de23-6ad1-40b9-a252-dbaeb5d4cb12 rack1恢复=》UN 172.20.101.166 154.7 KiB 256 ? f9a72fb2-55bd-40ec-b8e7-717404b80f19 rack1 UN 172.20.101.167 71.93 MiB 256 ? 8808aaf7-690c-4f0c-be9b-ce655c1464d4 rack1 UN 172.20.101.160 66.23 MiB 256 ? 57cc39fc-e47b-4c96-b9b0-b004f2b79242 rack1 UN 172.20.101.157 55.23 MiB 256 ? 091ff0dc-415b-48a7-b4ce-e70c84bbfafc rack1
验证查询
cqlsh 172.20.101.157 -u cassandra -p cassandra cassandra@cqlsh> SELECT * from kevin_test.t_users; user_id | emails | first_name | last_name---------+---------------------------------+------------+----------- 6 | {'k6-6@gmail.com', 'k6@pt.com'} | kevin6 | kang 7 | {'k7-7@gmail.com', 'k7@pt.com'} | kevin7 | kang 9 | {'k9-9@gmail.com', 'k9@pt.com'} | kevin9 | kang 4 | {'k4-4@gmail.com', 'k4@pt.com'} | kevin4 | kang 3 | {'k3-3@gmail.com', 'k3@pt.com'} | kevin3 | kang 5 | {'k5-5@gmail.com', 'k5@pt.com'} | kevin5 | kang 0 | {'k0-0@gmail.com', 'k0@pt.com'} | kevin0 | kang 8 | {'k8-8@gmail.com', 'k8@pt.com'} | kevin8 | kang 2 | {'k2-2@gmail.com', 'k2@pt.com'} | kevin2 | kang 1 | {'k1-1@gmail.com', 'k1@pt.com'} | kevin1 | kang
测试结果:
反复重启节点,查询表内容正常。
参考信息:
https://blog.csdn.net/yuanjian0814/article/details/78768889
https://www.jianshu.com/p/1dcca8f19894
http://cassandra.apache.org/doc/latest/tools/nodetool/nodetool.html?highlight=setstreamthroughput
https://zhaoyanblog.com/archives/684.html
https://blog.csdn.net/yuanjian0814/article/details/78777735
https://blog.csdn.net/iteye_19004/article/details/82648737