How to run multiple instances of asd with systemd

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.

How to run multiple instances of asd with systemd

Guide to run multiple instances of asd on a host.

The Aerospike server can actually have multiple instances running on the same host. This is necessary, for example, to leverage the auto-pin numa configuration which requires the asd process to be pinned to a NUMA node.

To start, refer to the Install guides for the common installation steps.

Follow the steps below to have multiple instances of the asd daemon running on systemd hosts.

Create a custom service file with parameter

The service filename needs to have the following format with the @: <service_name>@.service

The --instance parameter in the ExecStart directive is needed when running EE instances on the same host.

/usr/lib/systemd/system/aerospike_X@.service
[Unit]
Description=Aerospike Server %I
After=network.target
Wants=network.target

[Service]
LimitNOFILE=100000
TimeoutSec=15
User=root
Group=root
EnvironmentFile=/etc/sysconfig/aerospike
PermissionsStartOnly=True
ExecStartPre=/usr/bin/asd-systemd-helper
ExecStart=/usr/bin/asd $ASD_OPTIONS --config-file  /etc/aerospike/aerospike%i.conf --fgdaemon --instance %i

[Install]
WantedBy=multi-user.target

Copy config files

$ sudo cp aerospike.conf aerospike1.conf 
$ sudo cp aerospike.conf aerospike2.conf 

Set the mod-lua path on each of those files to the new locations:

aerospike1.conf

mod-lua {
     user-path /opt1/aerospike/usr/udf/lua/
}

and aerospike2.conf

mod-lua {
     user-path /opt2/aerospike/usr/udf/lua/
}

Modify the work-directory paths

work-directory in each aerospike config files should point to a different location:

  work-directory /opt1/aerospike

and

  work-directory /opt2/aerospike

Modify port settings to be unique

Modify ports to be unique between the two aerospike conf files. (ie port 3000-3003, 4000-4003)

Start Instances

sudo systemctl start aerospike_X@1.service
sudo systemctl start aerospike_X@2.service

Notes

  • systemd may need to be reloaded when editing the service files:
sudo systemctl daemon-reload
  • It is also recommended to enable rack-aware in a production environment when running multiple instances on a physical host and have asd instances on the same host be part of the same rack (rack-id).

Keywords

SYSTEMD MULTIPLE ASD NUMA ADQ AUTO-PIN

Timestamp

July 2019