簡體   English   中英

從cassandra cli刪除行鍵

[英]delete row key from cassandra cli

我將列族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仍然存在?

當您在Cassandra中刪除行時,不會立即刪除該行。 而是用墓碑標記。 效果是,您仍然可以獲得該鍵的結果,但是不會傳遞任何列。 需要墓碑是因為

  1. 一旦Cassandra數據文件“已滿”,它們將變為只讀; 邏輯刪除將添加到包含已刪除行的當前打開的數據文件中。
  2. 您必須給集群一個機會,將刪除傳播到持有該行副本的所有節點。

對於要移除的行及其墓碑,需要壓實。 此過程將重新組織數據文件,並且在執行此操作時會修剪已刪除的行。 也就是說,如果已經達到墓碑的GC寬限期。 對於單節點(!)群集,可以將寬限期設置為0是可以的,因為不必將刪除傳播到任何其他節點(在發布刪除的時間點可能已關閉)。

如果要強制刪除已刪除的行,則可以通過nodetool實用程序觸發刷新(與數據文件同步內存)和大型壓縮。 例如

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

壓縮完成后,刪除的行應真正消失。

默認的GC寬限期為十天(平均846000秒),以便立即刪除行鍵

UPDATE COLUMN FAMILY column_family_name with GC_GRACE= 0;

執行上述cli查詢,然后執行nodetool刷新和緊湊操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM