Even though Aerospike supports pretty much any type of maintenance without downtime or disruption to application workloads, there may be reasons an Operations team would want to prevent write transactions on a namespace but may not have direct control of applications writing to the cluster. In those circumstances, it may be desirable to put the cluster into a read-only mode. How can this be achieved?
Aerospike separates writes into those that originate from XDR and those which originate from all other clients. There are two parameters,
reject-xdr-writes that can be used to control whether or not a namespace will accept writes from these two sources. The parameters are both dynamic and can be set using an
asinfo command. Running the
asinfo command via
asadm will execute the commands on all nodes concurrently.
Commands executed in
asadm can be scripted using
The parameters to switch the namespace
test into a read-only mode are as follows:
Admin> asinfo -v "set-config:context=namespace;id=test;reject-non-xdr-writes=true" Admin> asinfo -v "set-config:context=namespace;id=test;reject-xdr-writes=true"
- Clients attempting to write when the cluster is in read-only mode will receive ‘AEROSPIKE_ERR_FAIL_FORBIDDEN’
- These commands operate at a namespace level and so if the whole cluster should be read only they should be executed for each namespace in turn.
READ-ONLY CLUSTER MAINTENANCE REJECT WRITES