Remove Namespace: Removing Namespace

The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.

Question:

How do I remove a namespace from a cluster? We have one namespace which has been allocated space on the disk and we are not using it. We want to use that data for other namespaces. Can removal of namespace be done dynamically without taking the whole cluster down?

namespace ns1 {
    memory-size 21474836480
	replication-factor 2
	allow-versions false
	single-bin false
	default-ttl 2592000

    storage-engine device {
	    device /dev/sdb
		load-at-startup true
		data-in-memory false
		write-block-size 131072
	}
}

Answer:

For server versions 3.13.0.1 (with updated clustering protocol) and above

Confirm that you have upgraded to the Paxos v5 clustering protocol. See [1] for reference.

Admin> show config like paxos-protocol
~~~~~~~~~~~~~~~~~~~~Service Configuration~~~~~~~~~~~~~~~~~~~~
NODE          :   192.168.100.xxx:3000   192.168.100.yyy:3000   
paxos-protocol:   v5                     v5        

Removing (and adding) of a namespace can then be done by rolling restart of the Aerospike cluster nodes:

Note: If running version 4.3.1 or later, configuring migrate-fill-delay to allow for the time it takes to get to the subsequent node (a few minutes should do) would reduce unnecessary migrations throughout the process.

  1. Stop Aerospike service

sudo service aerospike stop

  1. Update Aerospike configuration by removing (or adding if relevant) the appropriate namespace configuration in the aerospike.conf file.

  2. Start Aerospike service.

  3. Repeat steps 1-3 on all nodes in the cluster keeping 5-10 second window between each nodes restarts to avoid any race condition on multiple nodes trying to join the cluster at the same time.

Workaround for server versions prior to 3.13.0.1

Unfortunately, there is no way to add or remove a namespace without taking the whole cluster down if you are running server versions prior to 3.13.0.1. We would recommend upgrading to a newer version [1]. However, to avoid downtime, you should be able to change the namespace to data-in-memory and do a rolling restart to claim the space taken by the namespace. You could also make sure the namespace will not be used further by blocking all write requests against it by setting both allow-xdr-writes and allow-nonxdr-writes to false:

  1. Change the configuration of the namespace as such:

  2. Recommended configuration change is as follows:

     namespace ns1 {
         memory-size 1G
         allow-xdr-writes false
         allow-nonxdr-writes false
         storage-engine memory        
     }
    
  3. Perform a rolling restart on your cluster.

  4. At a later time, when you can afford downtime, remove the above from all configs and do a full the cluster shutdown (stop all nodes, then restart all nodes).

Note:

[1] See here for upgrade instructions: http://www.aerospike.com/docs/operations/upgrade/cluster_to_3_13

Timestamp

06/06/2017

Is there any difference in the steps involved when removing a namespace with strong consistency?

namespace n_conf {
        replication-factor 2
        memory-size 1G
        default-ttl 0 
        migrate-order 4
        strong-consistency true

       storage-engine device {
               file /opt/aerospike/data/n_conf.dat
               filesize 1G
               max-write-cache 256M
               data-in-memory true 
       }
}