从cassandra cli中删除行键

 batman@zhou 发布于 2023-02-02 18:49

我将我的列族gcgraceseconds设置为0; 但是仍然没有删除rowkey,它仍留在我的列族中

create column family workInfo123
with column_type = 'Standard'
  and comparator = 'UTF8Type'
  and default_validation_class = 'UTF8Type'
  and key_validation_class = 'UTF8Type'
  and read_repair_chance = 0.1
  and dclocal_read_repair_chance = 0.0
  and populate_io_cache_on_flush = true
  and gc_grace = 0 
  and min_compaction_threshold = 4
  and max_compaction_threshold = 32
  and replicate_on_write = true
  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
  and caching = 'KEYS_ONLY'
  and default_time_to_live = 0
  and speculative_retry = 'NONE'
  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.LZ4Compressor'}
  and index_interval = 128;

见下面的观点

[default@winoriatest] list workInfo123;
Using default limit of 100
Using default cell limit of 100
-------------------
RowKey: a
-------------------
RowKey: xx

2 Rows Returned.
Elapsed time: 17 msec(s).

我正在使用cassandra -cli我应该改变其他任何东西

更新: -

使用后 ./nodetool -host 127.0.0.1 compact

[default@winoriatest] list workInfo123;
Using default limit of 100
Using default cell limit of 100
-------------------
RowKey: xx

2 Rows Returned.
Elapsed time: 11 msec(s).

为什么xx还有?

1 个回答
  • 当您删除Cassandra中的行时,它不会立即被删除.相反,它标有墓碑.结果是,您仍然可以获得密钥的结果,但不会传递任何列.墓碑是必需的,因为

      Cassandra数据文件一旦"满"就变为只读; 墓碑将添加到包含已删除行的当前打开的数据文件中.

      您必须为群集提供将删除传播到包含该行副本的所有节点的机会.

    要删除行及其墓碑,需要进行压缩.此过程重新组织数据文件,当它执行此操作时,它会修剪已删除的行.也就是说,如果已达到墓碑的GC宽限期.对于单节点(!)群集,可以将宽限期设置为0,因为删除不必传播到任何其他节点(在您发出删除的时间点可能会下降).

    如果要强制删除已删除的行,可以通过nodetool实用程序触发刷新(与数据文件同步内存)和主要压缩.例如

    ./nodetool flush your_key_space the_column_family && ./nodetool compact your_key_space the_column_family
    

    压缩完成后,删除的行应该真的消失了.

    2023-02-02 18:51 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有