问题
I am using aerospike for testing. I am using community edition.The cluster has 2 nodes. I am using storage engine as device with SSD. My config file -
namespace test {
replication-factor 2
memory-size 16G
default-ttl 0
storage-engine device {
device /dev/sdb1
data-in-memory false
write-block-size 128K
}
}
I have set named data. After adding 1M record in it for testing ,now i want to delete everything in this set (if possible drop set too). I tried this command on both node-
asinfo -v "set-config:context=namespace;id=test;set=data;set-delete=true;"
It worked until i restarted my cluster (sudo /etc/init.d/aerospike restart
on both node). After restart all data came back. I went through this link http://www.aerospike.com/launchpad/deleting_sets_and_data.html but doesn't find anything convenient.
回答1:
EDIT copy pasted from @sasha's comment:
Aerospike 3.10.0 introduces [durable deletes][1] mechanism that adds the persistence to the deletion (only for Aerospike Enterprise though). It's implemented by so called Tombstone records written as the last version of the record being deleted. It guarantees no deleted record got into memory on cold start (read from disk). Then the defragmentation process eventually runs and frees memory and disk space from all the record versions including tombstone. [1]: aerospike.com/docs/guide/durable_deletes.html
回答2:
As of Aerospike 3.12, which was released in March 2017, the feature of deleting all data in a set or namespace is now supported in the database.
Please see the following documentation: http://www.aerospike.com/docs/reference/info#truncate
Which provides the command line command that looks like: asinfo truncate:namespace=;set=;lut=
It can also be truncated from the client APIs, here is the java documentation: http://www.aerospike.com/apidocs/java/com/aerospike/client/AerospikeClient.html and scroll down to the "truncate" method.
Please note that this feature can, optionally, take a time specification. This allows you to delete records, then start inserting new records. As timestamps are used, please make certain your server clocks are well synchronized.
Also notice that in the Enterprise edition, these deletes are durable and survive restart.
回答3:
In our production experience special java deletion utility works quite well even without recently introduced durable deletes. You build it from sources, put somewhere near the cluster and run this way:
java -jar delete-set-1.0.0-jar-with-dependencies.jar -h <aerospike_host> -p 3000 -s <set_to_delete> -n <namespace_name>
However in our prod environment cold restarts are quite rare events, basically when aerospike crashes. And the data flow is quite high so defragmentation kicks in earlier and we don't have this zombie record issue.
BTW asinfo
way of deletion didn't work for us. The records stayed there for couple of days so we use delete-set
utility which worked right away.
来源:https://stackoverflow.com/questions/36261601/aerospike-delete-all-record-in-a-set