Quick Setup Guide: Aerospike on Windows in minutes, using Docker

Nikhil K
6 min readFeb 3, 2019

--

This is a quick setup guide for running and interacting with Aerospike on your local PC. This tutorial includes the following:

  1. Setting up the Aerospike-server container.
  2. Aerospike namespace configuration.
  3. Volume mounting Aerospike configuration files and data to your local machine for data persistence.
  4. Connect to Aerospike using aql (Aerospike Query Language)

Prerequisites:

  1. Docker Desktop for Windows 10 Professional Users / (Docker Toolbox for Windows 10 Home or below) Download link

Step 1: Setting up the Aerospike-server container

Run the following command on Powershell to setup Aerospike-server:

docker run -tid --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 aerospike/aerospike-server

Once Aerospike is setup completely, check the status by using the following command:

docker ps -a
If the status of the container is Up, we’re good to go to step 2.

In my case, the container id created is 605f9cf8106d. Take note of your respective id as it would be required in the next step.

Step 2: Aerospike namespace configuration

The Aerospike namespace is configured in the aerospike.conf file. This file is located in the /etc/aerospike directory in the container.

In this tutorial we will save this locally to ensure that we don’t re create it each time a new container is spawned.

To begin with, create the following folder structure in the D Drive:

  1. Aerospike/data
  2. Aerospike/config

Once this is done, store the aerospike.conf file from the container into the config folder as created above, by running the following command(Powershell):

docker cp <containerId>:/etc/aerospike/aerospike.conf D:\Aerospike\config\

where <containerId> is your container id , in this case it is :

docker cp 605f9cf8106d:/etc/aerospike/aerospike.conf D:\Aerospike\config\

If, successful, the file will be present in the D:\Aerospike\config directory. Open the file with any text editor.

At the end of the configuration file ,a default namespace configuration will be found as follows:

namespace test {
replication-factor 2
memory-size 1G
default-ttl 30d # 5 days, use 0 to never expire/evict.
# storage-engine memory# To use file storage backing, comment out the line above and use the
# following lines instead.
storage-engine device {
file /opt/aerospike/data/test.dat
filesize 4G
data-in-memory true # Store data in memory in addition to file.
}

You can either add another one or change the existing default namespace. For this tutorial the existing namespace will be changed to “MyApp”.

The namespace has multiple parameters such as replication factor, filesize and storage options, most of which will be left as default for this tutorial.

Make the following changes to the file as shown below(marked in bold):

namespace MyApp {
replication-factor 2
memory-size 1G
default-ttl 30d # 5 days, use 0 to never expire/evict.
# storage-engine memory# To use file storage backing, comment out the line above and use the
# following lines instead.
storage-engine device {
file /opt/aerospike/data/MyApp.dat
filesize 1G
data-in-memory true # Store data in memory in addition to file.
}

Note that the filesize has been limited to 1 GB. Change these values according to your use case. Save and close the file.

Step 3: Volume mounting Aerospike configuration files and data to your local machine for data persistence

Docker by default doesn't share the D drive for volume mount. This needs to be configured as per your docker setup.

For Windows 10 Professional Users, right click docker on the task bar and enter settings. Click on shared drives and select the D Drive.

Provide the necessary permissions and restart docker if prompted.

For Windows 10 Home users and below who are using the docker toolbox and VirtualBox, change the configuration as follows:

  1. Open Oracle VM Virtualbox, click on the settings icon and then click on shared folders.

2. Add the previously created Aerospike directory as shown in the image below:

In the sub options, select Auto-mount and Make Permanent.

3. Once done, open the docker quickstart terminal and run the following command:

docker-machine restart

Once restarted, we need to run Aerospike with the new configurations. Remove the currently running container using the command (Powershell):

docker rm -f <container id>

In this example:

docker rm -f 605f9cf8106d

(Note : In the future, avoid using rm -f , use docker stop and then rm for a cleaner exit.)

Setup a new Aerospike container using the following command(Powershell):

For Windows 10 Professional Users with Docker Desktop :

docker run -tid -v D:\Aerospike\data:/opt/aerospike/data   -v D:\Aerospike\config:/opt/aerospike/etc --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 aerospike/aerospike-server /usr/bin/asd --foreground --config-file /opt/aerospike/etc/aerospike.conf

For lower windows versions using docker toolbox :

docker run -tid -v /Aerospike/data://opt/aerospike/data   -v /Aerospike/config://opt/aerospike/etc --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 aerospike/aerospike-server /usr/bin/asd --foregro
und --config-file /opt/aerospike/etc/aerospike.conf

The following command specifies the volume mounts for Aerospike (data and config respectively) using -v param and the config-file option.

Once done, run the following command to check the status (Powershell):

docker ps -a

If the status of the container is Up, then everything has been setup as expected.

Step 4: Connect to Aerospike using aql (Aerospike Query Language)

To setup aql we need to first find out the I.P of the running Aerospike container.

To fetch the I.P , run the following command to fetch the container details:

docker inspect <container id>

In this case it would be:

docker inspect 605f9cf8106d

This will print the configurations out on the console. Towards the end of the config you will find the IP address.

In this example, the command resulted in the following IP address as seen in the image (172.17.0.2)

This IP address will be used to connect to Aerospike by Aerospike Query language, which would help us get started on interacting with Aerospike via console.

To Setup aql, run the following command (Powershell):

docker run -ti --name aerospike-aql --rm aerospike/aerospike-tools aql -h <container-IP> aerospike/aerospike-server

For this example:

docker run -ti --name aerospike-aql --rm aerospike/aerospike-tools aql -h 172.17.0.2 aerospike/aerospike-server

(Make sure that the IP is as per your container’s configuration.)

Once setup correctly, the aql console will start as shown in the image:

Aerospike has a syntax similar to SQL. To check the available namespaces, run the following:

If the results are similar to the image above, the setup is successful.

Conclusion

Follow these simple steps, and you will be on your way to setting up and interacting with your first Aerospike container. The data created will be stored in the /data directory as configured previously. Any changes to the config in the local drive will reflect upon restarting the container.

Please note that there are many other ways of setup as well. Although this setup is specific to Windows, most of the commands will be similar in Linux as they're mostly related to docker.

--

--

Nikhil K

I keep stumbling upon great experiences, random issues and their solutions, so I've decided to share some of it. Hope this helps!