1

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

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仍然存在?

4

2 回答 2

5

当您在 Cassandra 中删除一行时,它不会立即被删除。相反,它标有墓碑。效果是,您仍然会得到键的结果,但不会传递任何列。墓碑是必需的,因为

  1. Cassandra 数据文件“满”后变为只读;墓碑被添加到当前打开的包含已删除行的数据文件中。
  2. 您必须让集群有机会将删除传播到所有持有该行副本的节点。

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

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

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

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

于 2014-01-15T09:35:20.110 回答
1

默认 GC 宽限期是十天(意味着 846000 秒),以便立即删除行键

UPDATE COLUMN FAMILY column_family_name with GC_GRACE= 0;

执行上面的cli查询跟随nodetool的flush和compact操作。

于 2014-07-01T12:38:40.843 回答