更改cassandra中的commitlog目录

Changing commitlog directory in cassandra

当前 commitlog 目录指向 Directory1。我想将它更改为不同的目录 D2。应该如何迁移?

您可以更改 cassandra.yaml 中的提交日志目录(关键字:"commitlog_directory")并将所有日志复制到新目标。

https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html#reference_ds_qfg_n1r_1k__commitlog_directory

commitlog_directory

The directory where the commit log is stored. Default locations: Package installations: /var/lib/cassandra/commitlog Tarball installations: install_location/data/commitlog For optimal write performance, place the commit log be on a separate disk partition, or (ideally) a separate physical device from the data file directories. Because the commit log is append only, an HDD for is acceptable for this purpose.

我们就是这样做的。我们有一个与 Cassandra 1.1.2 通信的 load-balanced 客户端,每个客户端都存在于每个 Cassandra 节点上。

  1. 耗尽你的服务。
    • 等待负载均衡器删除节点。
  2. 停止本地节点上的服务以停止直接 Client-Cassandra 写入:systemctl stop <your service name>
  3. 此时应该没有更多的写入并且磁盘大大减少activity:
    • iostat 2 - 磁盘 activity 应该接近零
    • nodetool gossipinfo
  4. 禁用 Cassandra gossip 协议以标记节点已死亡并停止 Cassandra-Cassandra 写道:nodetool disablegossip
  5. 将提交日志的所有内容刷新到 SSTables 中:nodetool flush
  6. 清除节点——这个命令比 nodetool flush 更重要,(并且可能包括 nodetool flush 的所有行为):nodetool drain
  7. 停止cassandra进程:systemctl stop cassandra
  8. 修改 Cassandra 配置文件,例如vi /etc/cassandra/default.conf/cassandra.yaml
  9. 启动卡桑德拉:systemctl start cassandra
  10. 等待 10-20 分钟。跟踪 Cassandra 日志以跟进,例如tail -F /var/log/cassandra/system.log
  11. 在移动到下一个节点之前确认环是健康的:nodetool ring
  12. Re-start客服:systemctl start <your service here>

请注意,我们不需要自己手动复制提交日志文件。冲洗和排水解决了这个问题。然后文件慢慢地重新出现在新的 commitlog_dir 位置。