aerospikeaerospike-ce

Reducing File size for disk backed aerospike


How can we reduce the file size for aerospike .dat file? our current config is

namespace test {
    memory-size 20G             # Maximum memory allocation for data and
                                    # primary and secondary indexes.
    storage-engine device {         # Configure the storage-engine to use
    file /opt/aerospike/test.dat  # Location of data file on server.
    filesize 100G                # Max size of each file in GiB.
    }
}

current file size if test.dat is 90GB as par ls -ltrh. But on AMC ui it shows 50GB is used.

I want to reduce the file size to 80GB. I tried following this doc

Decrease filesize Decreasing the size of the files with an Aerospike service restart will potentially end up deleting random data which can results in unexpected behavior on the Aerospike cluster due to the truncation, maybe even landing into low available percentage on the node. Thus, you would need to delete the file itself and let the data be migrated from the other nodes in the cluster.

  1. Stop Aerospike server.
  2. Delete the file and update the configuration with the new filesize.
  3. Start Aerospike server.

But when I start the server post data deletion, the startup fails with error

Jan 20 2022 03:44:50 GMT: WARNING (drv_ssd): (drv_ssd.c:3784) unable to open file /opt/aerospike/test.dat: No such file or directory

I have few questions wrt this

  1. Is there a way to restart process with no initial data and let it take data from other nodes in the cluster?
  2. If i wanted to reduce the size from 100G to 95G, would i still have to do the same thing? considering current file size is only 90GB. Is there still a risk of losing data?

Solution

    1. Stopping the Aerospike server, deleting the file and restarting it is the way to go. There are other ways (like cold starting empty -- cold-start-empty) but the way you have done it is the recommended one. Seems there are some permission issues preventing the server to create that file in that directory.

    2. Yes, you would have to do the same thing for reducing the file size, as mentioned in that document you referred to.