Create Aerospike cluster
This page guides you through setting up networking, deploying an Aerospike cluster, and configuring access for EMR.
Set up networking
Many enterprise AWS accounts don’t have a default VPC, so this tutorial explicitly configures networking. You need a public subnet (with internet access) for the Aerospike cluster.
If you already have a public subnet in your VPC, use it.
-
Find a public subnet in your VPC.
List your subnets:
Terminal window aws ec2 describe-subnets --query 'Subnets[*].[SubnetId,VpcId,MapPublicIpOnLaunch,Tags[?Key==`Name`].Value|[0]]' --output tableLook for a subnet where
MapPublicIpOnLaunchisTrue, or one with “public” in its name. Set your subnet ID:Terminal window SUBNET_ID=YOUR_SUBNET_IDecho "SUBNET_ID=$SUBNET_ID" -
Get the VPC ID.
Terminal window VPC_ID=$(aws ec2 describe-subnets --subnet-ids $SUBNET_ID --query 'Subnets[0].VpcId' --output text)echo "VPC_ID=$VPC_ID"
If you only have private subnets, create a public subnet with internet access.
-
Get your VPC ID.
List your VPCs and choose one:
Terminal window aws ec2 describe-vpcs --query 'Vpcs[*].[VpcId,Tags[?Key==`Name`].Value|[0]]' --output tableSet your VPC ID:
Terminal window VPC_ID=YOUR_VPC_IDecho "VPC_ID=$VPC_ID" -
Find a valid CIDR for your subnet.
Check your VPC’s CIDR range and existing subnets:
Terminal window echo "VPC CIDR:"aws ec2 describe-vpcs --vpc-ids $VPC_ID --query 'Vpcs[0].CidrBlock' --output textecho "Existing subnets:"aws ec2 describe-subnets --filters "Name=vpc-id,Values=$VPC_ID" --query 'Subnets[*].CidrBlock' --output textYour subnet CIDR must start with the same numbers as your VPC CIDR and not overlap with existing subnets. Pick an unused number for the third section:
Your VPC CIDR Example subnet CIDR 10.0.x.x10.0.200.0/24172.31.x.x172.31.200.0/24 -
Create a public subnet.
Replace
YOUR_CIDRwith your chosen CIDR:Terminal window SUBNET_ID=$(aws ec2 create-subnet \--vpc-id $VPC_ID \--cidr-block YOUR_CIDR \--tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=aerospike-graph-public}]' \--query 'Subnet.SubnetId' --output text)echo "SUBNET_ID=$SUBNET_ID" -
Enable auto-assign public IPs.
Terminal window aws ec2 modify-subnet-attribute --subnet-id $SUBNET_ID --map-public-ip-on-launch -
Create an internet gateway (if your VPC doesn’t have one).
Terminal window IGW_ID=$(aws ec2 create-internet-gateway \--tag-specifications 'ResourceType=internet-gateway,Tags=[{Key=Name,Value=aerospike-graph-igw}]' \--query 'InternetGateway.InternetGatewayId' --output text)aws ec2 attach-internet-gateway --internet-gateway-id $IGW_ID --vpc-id $VPC_IDecho "IGW_ID=$IGW_ID"If you get “Resource already exists”, your VPC already has an IGW. Get its ID:
Terminal window IGW_ID=$(aws ec2 describe-internet-gateways --filters "Name=attachment.vpc-id,Values=$VPC_ID" --query 'InternetGateways[0].InternetGatewayId' --output text)echo "IGW_ID=$IGW_ID" -
Create a route table with internet access.
Terminal window RTB_ID=$(aws ec2 create-route-table \--vpc-id $VPC_ID \--tag-specifications 'ResourceType=route-table,Tags=[{Key=Name,Value=aerospike-graph-rtb}]' \--query 'RouteTable.RouteTableId' --output text)aws ec2 create-route --route-table-id $RTB_ID --destination-cidr-block 0.0.0.0/0 --gateway-id $IGW_IDaws ec2 associate-route-table --route-table-id $RTB_ID --subnet-id $SUBNET_IDecho "RTB_ID=$RTB_ID"
Create a security group
-
Create a security group.
Terminal window SG_ID=$(aws ec2 create-security-group \--group-name aerospike-graph-sg \--description "Security group for Aerospike Graph tutorial" \--vpc-id $VPC_ID \--query 'GroupId' --output text)echo "SG_ID=$SG_ID" -
Add inbound rules.
Terminal window # SSH access from your IPMY_IP=$(curl -s https://checkip.amazonaws.com)aws ec2 authorize-security-group-ingress --group-id $SG_ID --protocol tcp --port 22 --cidr ${MY_IP}/32# Aerospike port from within the security groupaws ec2 authorize-security-group-ingress --group-id $SG_ID --protocol tcp --port 3000 --source-group $SG_ID -
Save the IDs for the next steps.
Terminal window echo "Save these values:"echo " SUBNET_ID=$SUBNET_ID"echo " SG_ID=$SG_ID"
Update the scripts
The create_cluster.sh script sources set_variables.sh, so you only need to set your values in one place.
-
Update
set_variables.shwith your networking values.Open
set_variables.shin your editor and update the network settings at the end:SUBNET_ID="YOUR_SUBNET_ID"SECURITY_GROUP="YOUR_SG_ID"Replace with your actual values from the previous step.
-
Update
create_cluster.shto use the variables.Open
create_cluster.shand replace theaerolab cluster createcommand with:Terminal window aerolab cluster create --name "$name" \--count "$instance_count" \--instance-type "$aws_instance_type" \--aerospike-version "$aerospike_version" \--owner "$username" \--subnet-id "$SUBNET_ID" \--secgroup-id "$SECURITY_GROUP" \--start n -
Save both files.
Create the Aerolab cluster
-
Make the scripts executable.
Terminal window chmod +x create_cluster.sh bulkload.sh -
Run the cluster creation script.
Terminal window ./create_cluster.shCreating ClusterUsing subnet ID subnet-XXXXXUsing security group ID sg-XXXXX...Connection succeeded, continuing installation...Instance UP, continuingCLUSTER EXPIRES: Wednesday, 10-Dec-25 20:11:08 PST (in: 29h56m47s)DoneStarting ClusterDoneExample response
Configure the bulk loader properties
The bulk loader needs to know how to connect to your Aerospike cluster. You will update the properties file with your cluster’s private IP address.
-
Get the cluster private IP address.
Use Aerolab to list your clusters and retrieve the private IP:
Terminal window aerolab cluster listClusterName NodeNo ExpiresIn State PublicIP PrivateIP Owner AsdVermy-graph-cluster 1 29h41m0s running 44.243.177.28 172.31.0.110 myusername 8.0.0.7Example response Note the PrivateIP value (for example,
172.31.0.110). -
Open
bucket-files/config/bulk-loader.propertiesin your editor. -
Update the Aerospike connection settings.
Locate the core AGS connection section and update these properties:
aerospike.client.host=10.0.1.123aerospike.client.port=3000aerospike.client.namespace=testReplace
10.0.1.123with your cluster’s private IP address. -
Update the data source paths.
Locate the bulk loader source paths section and update the bucket name:
aerospike.graphloader.vertices=s3://YOUR_BUCKET_NAME/verticesaerospike.graphloader.edges=s3://YOUR_BUCKET_NAME/edgesaerospike.graphloader.temp-directory=s3://YOUR_BUCKET_NAME/tempReplace
YOUR_BUCKET_NAMEwith your actual S3 bucket name from the previous section. -
Save the file.