Set read only Aerospike Cluster

Hi,

Is there a way I can disable writes on an existing Aerospike cluster without restarting the database?

Thanks

Set allow-nonxdr-writes to false.

Thank you for the response. I am not sure what the term means, but I ran the asinfo command to disable both xdr wrties and non-xdr writes but I was still able to insert through aql. Is that expected?

Just tested locally:

Before:

In [3]: import aerospike

In [4]: c = aerospike.Client(dict(hosts=[("174.22.0.1", 3000), ("174.22.0.2", 3000)])).connect()

In [5]: c.put(("test", "test", 1), dict(foo=1))
Out[5]: 0L

Set config:

asadm -e 'asinfo -v "set-config:context=namespace;id=test;allow-nonxdr-writes=false"'

After

In [6]: c.put(("test", "test", 1), dict(foo=1))
---------------------------------------------------------------------------
AlwaysForbidden                           Traceback (most recent call last)
<ipython-input-6-4a5fc2e2d687> in <module>()
----> 1 c.put(("test", "test", 1), dict(foo=1))

AlwaysForbidden: (10L, 'AEROSPIKE_ERR_ALWAYS_FORBIDDEN', 'src/main/client/put.c', 107, False)

I ran the above command followed by the same python code that you have written above. Does this only work in enterprise edition?

No, it should work on CE as well.

In [6]: c.put(("test", "test", 1), dict(foo=1))
---------------------------------------------------------------------------
AlwaysForbidden                           Traceback (most recent call last)
<ipython-input-6-4a5fc2e2d687> in <module>()
----> 1 c.put(("test", "test", 1), dict(foo=1))

AlwaysForbidden: (10L, 'AEROSPIKE_ERR_ALWAYS_FORBIDDEN', 'src/main/client/put.c', 107, False)

In [7]: c.info('build')
Out[7]: 
{'BB9010016AE4202': (None, '4.5.0.1-115-g2bf55f1\n'),
 'BB9020016AE4202': (None, '4.5.0.1-115-g2bf55f1\n'),
 'BB9030016AE4202': (None, '4.5.0.1-115-g2bf55f1\n')}

In [8]: c.info('edition')
Out[8]: 
{'BB9010016AE4202': (None, 'Aerospike Community Edition\n'),
 'BB9020016AE4202': (None, 'Aerospike Community Edition\n'),
 'BB9030016AE4202': (None, 'Aerospike Community Edition\n')}

We are running a heterogeneous cluster with versions (4.0.0.4 [4], 4.1.0.1 [1], 4.2.0.7 [1], 4.3.0.10 [1], 4.3.0.7 [1]). Not sure if the versions have anything to do with this. Very strange. Thanks for all the help though.

Run:

asadm -e "show config like xdr"

We have stopped the cluster now, can’t run this command on the old cluster. Thanks for your help in any case.

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