aws-quickstart / quickstart-aerospike

AWS Quick Start Team
Apache License 2.0
6 stars 8 forks source link

move script back to LaunchConfig #14

Closed sourabh3b closed 3 years ago

sourabh3b commented 3 years ago

Tested 2 nodes successfully Screen Shot 2021-06-16 at 11 53 16 AM

Test after second commit

[ec2-user@ip-10-0-19-151 ~]$ cd /opt/aerospike/cft_scripts/
[ec2-user@ip-10-0-19-151 cft_scripts]$ ls
aerospike_cluster  aerospike_init  aerospike_mesh.conf  aerospike_start
[ec2-user@ip-10-0-19-151 cft_scripts]$ cat aerospike_cluster
#!/bin/bash
echo ClusterInstancesScriptStart > /var/log/awsuserdatascript
PRIVATE_IP=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)
CONF=/etc/aerospike/aerospike.conf
sed -i "s/port 3000/port 3000\n\t\taccess-address $PRIVATE_IP virtual\n/g" $CONF

###Point to all instances using the mesh-address config option
sleep 60 # wait for AWS to provision
FILTER=Name=tag-key,Values=StackID
PRIVATEIP=$(aws ec2 describe-instances --filter $FILTER  Name=tag-value,Values=arn:aws:cloudformation:us-east-1:040921035827:stack/tCaT-aerospike-single-region-ca35af-AerospikeServerStack-1QCV6M60CT24L/07a311b0-ced7-11eb-9f70-0a8534d05dcd --output=text --region=us-east-1 | grep PRIVATEIPADDRESSES | awk '{print $4}')
echo $PRIVATEIP >> /var/log/awsuserdatascript
sed -i '/.*mesh-seed-address-port/d' $CONF
for i in $PRIVATEIP; do
    sed -i "/interval/i \\\t\tmesh-seed-address-port $i 3002\n" $CONF
done

# Check if namespace file in input
CODE=$(curl -Is  | head -n 1 | cut -d$' ' -f2)
if [ "$CODE" != "200" ]; then echo 'Namespace File not found' >> /var/log/awsuserdatascript
else sed -i '/namespace test/,$d' $CONF
curl -s  >> $CONF; fi
systemctl restart aerospike

echo OtherInstancesScriptFinish >> /var/log/awsuserdatascript
(crontab -l 2>/dev/null; echo '*/5 * * * * /opt/aerospike/poll_sqs') | crontab -
if [[ no == "yes" ]]; then
(crontab -l 2>/dev/null; echo '*/5 * * * * /opt/aerospike/cloudwatch') | crontab -
fi
[ec2-user@ip-10-0-19-151 cft_scripts]$ cat /etc/aerospike/aerospike.conf

# Aerospike database configuration file for deployments using mesh heartbeats with systemd.

service {
    paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
    proto-fd-max 15000
}

logging {
    console {
        context any info
    }
}

network {
    service {
        address any
        port 3000
        access-address 10.0.19.151 virtual

    }

    heartbeat {
        mode mesh
        port 3002 # Heartbeat port for this node.

        # List one or more other nodes, one ip-address & port per line:

        mesh-seed-address-port 10.0.19.151 3002

        mesh-seed-address-port 10.0.41.191 3002

        interval 250
        timeout 10
    }

    fabric {
        port 3001
    }

    info {
        port 3003
    }
}

namespace test {
    replication-factor 2
    memory-size 4G

    storage-engine memory
}

namespace bar {
    replication-factor 2
    memory-size 4G

    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/bar.dat
#       filesize 16G
#       data-in-memory true # Store data in memory in addition to file.
#   }
}
[ec2-user@ip-10-0-19-151 cft_scripts]$ asadm
Seed:        [('127.0.0.1', 3000, None)]
Config_file: /home/ec2-user/.aerospike/astools.conf, /etc/aerospike/astools.conf
Aerospike Interactive Shell, version 2.0.1

Found 2 nodes
Online:  10.0.19.151:3000, 10.0.41.191:3000

Admin> exit
[ec2-user@ip-10-0-19-151 cft_scripts]$ aql
Seed:         127.0.0.1
User:         None
Config File:  /etc/aerospike/astools.conf /home/ec2-user/.aerospike/astools.conf
Aerospike Query Client
Version 5.0.1
C Client Version 4.6.17
Copyright 2012-2020 Aerospike. All rights reserved.
aql> exit
sourabh3b commented 3 years ago

Can we remove the S3 permissions from the ClusterRole now as well please?

Done