Mesh Subnet Scan


Synopsis: Mesh Subnet Scan

In the case of a subnet where all nodes are using DHCP (i.e. AWS), it can be difficult to configure the network context in the aerospike.conf file. Should one add the entire subnet as a precaution because we do not know the IPs our nodes we will have your log will be filled with messages like these: WARNING (cf:socket): (socket.c::368) Error in delayed connect(): timed out

We can create a small command to scan the subnet and use Aerospikes tip command to help us out.

NOTE: Do not use this command if you have multiple independent cluster running in the same subnet.

#! /bin/bash
IP=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' | awk -F "." '{print $1"."$2"."$3"."}'`
for i in {1..254};do asinfo -v "tip:host=$IP$i;port=3002";done

Simply add this to an executable file and execute each time you start/restart the Aerospike Service.

As an example:

[root@localhost ~]# service aerospike restart && sleep 10 && ./findnodes

We have added a sleep 10 there to make sure the Aerospike daemon is ready which you can see in the /var/log/aerospike/aerospike.log file if you look for service ready: soon there will be cake!