HowTo completely delete namespace data without any cluster downtime

HowTo completely delete namespace data without any cluster downtime


A namespace data is to be completely deleted and re-used without bringing down the cluster.


Aerospike Server version 3.12.1 or above

As of version 3.12.1, released in April 2017, set-delete is deprecated. Truncate the new feature of deleting all the data in a namespace or set is now supported in the database.

See the following truncate documentation:

Truncate can also be executed from the client APIs. Here is the java documentation:

In the Aerospike Enterprise Edition Server, truncation is preserved through a cold-restart.

In the Aerospike Community Edition Server, similar to record deletes, records in previously truncated sets can return through a cold-start.

Aerospike Server version 3.12.0 or below

The following steps are to be followed:

  1. Stop all client writes to the namespace.

  2. Issue a set-delete command for each set in the namespace. You can issue the command from asadm which will be administered on all the nodes in the cluster.

    In the following example, the set ‘testset’ in namespace ‘ns1’ is to be deleted:

     $ asadm
     Aerospike Interactive Shell, version 0.1.6
     Found 1 nodes
     Admin> asinfo -v "set-config:context=namespace;id=ns1;set=testset;set-delete=true;" ( returned:


  3. Verify that all the data in the namespace has been removed. For example, querying statistics for namespace ‘ns1’ should return “objects=0” in the output for all the nodes:

     $ asinfo -v 'namespace/ns1' -l | grep '^objects='

    If you have data in a namespace that is not part of a set, you will need to traverse the namespace, and delete each and every record, or you can write a User Defined Function (UDF) for the same.


  4. For each node in the cluster:

    i. Stop the ASD on the node.

    $ sudo service aerospike stop
    Stopping aerospike:                                        [  OK  ]

    ii. Zero the data on the partitions using the ‘dd’ command:

    # dd if=/dev/zero of=/dev/[device] bs=1M

    The set-delete command will remove the data from the index. With a replication factor of two, it is also important for other nodes in the cluster to know that this data does not exist anymore. The "dd" command is issued to prevent any old data from returning on a cold restart.

    iii. Start the ASD on the node.

     $ sudo service aerospike start
     Starting and checking aerospike:                           [  OK  ]

    Depending on the type of write workload, it may be preferable to wait for migrations to complete between each node. Refer: How can I tell when a migration is finished?

    As a final step, you can once again verify that there are no objects in the namespace after the ASD has started.




9 February 2017

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.