Removed credentials from ec2 script, ready for publishing.

This commit is contained in:
Russell Jurney 2013-07-02 17:17:36 -07:00
parent 8a5f4960a9
commit 86ecdc4c26
1 changed files with 15 additions and 4 deletions

View File

@ -4,9 +4,8 @@
# # Setup environment for ec2-api-tools # # Setup environment for ec2-api-tools
# export EC2_HOME=/path/to/ec2-api-tools-1.6.7.4/ # export EC2_HOME=/path/to/ec2-api-tools-1.6.7.4/
# export PATH=$PATH:$EC2_HOME/bin # export PATH=$PATH:$EC2_HOME/bin
# export AWS_ACCESS_KEY=
export AWS_ACCESS_KEY=AKIAI42EC3TWOGWFXZHQ # export AWS_SECRET_KEY=
export AWS_SECRET_KEY=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
# Check for ec2 commands we require and die if they're missing # Check for ec2 commands we require and die if they're missing
type ec2-create-keypair >/dev/null 2>&1 || { echo >&2 "I require ec2-create-keypair but it's not installed. Aborting."; exit 1; } type ec2-create-keypair >/dev/null 2>&1 || { echo >&2 "I require ec2-create-keypair but it's not installed. Aborting."; exit 1; }
@ -24,15 +23,18 @@ chmod 0600 druid-keypair
mv druid-keypair ~/.ssh/ mv druid-keypair ~/.ssh/
# Create a security group for our servers # Create a security group for our servers
echo "Creating a new security group for druid..."
ec2-create-group druid-group -d "Druid Cluster" ec2-create-group druid-group -d "Druid Cluster"
# Create rules that allow necessary services in our group # Create rules that allow necessary services in our group
echo "Creating new firewall rules for druid..."
# SSH from outside # SSH from outside
ec2-authorize druid-group -P tcp -p 22 ec2-authorize druid-group -P tcp -p 22
# Enable all traffic within group # Enable all traffic within group
ec2-authorize druid-group -P tcp -p 1-65535 -o druid-group ec2-authorize druid-group -P tcp -p 1-65535 -o druid-group
ec2-authorize druid-group -P udp -p 1-65535 -o druid-group ec2-authorize druid-group -P udp -p 1-65535 -o druid-group
echo "Booting a single small instance for druid..."
# Use ami ami-e7582d8e - Alestic Ubuntu 12.04 us-east # Use ami ami-e7582d8e - Alestic Ubuntu 12.04 us-east
INSTANCE_ID=$(ec2-run-instances ami-e7582d8e -n 1 -g druid-group -k druid-keypair --instance-type m1.small| awk '/INSTANCE/{print $2}') INSTANCE_ID=$(ec2-run-instances ami-e7582d8e -n 1 -g druid-group -k druid-keypair --instance-type m1.small| awk '/INSTANCE/{print $2}')
while true; do while true; do
@ -51,7 +53,7 @@ sleep 60
# Get hostname and ssh with the key we created, and ssh there # Get hostname and ssh with the key we created, and ssh there
INSTANCE_ADDRESS=`ec2-describe-instances|grep 'INSTANCE'|grep $INSTANCE_ID|cut -f4` INSTANCE_ADDRESS=`ec2-describe-instances|grep 'INSTANCE'|grep $INSTANCE_ID|cut -f4`
echo "Connecting to $INSTANCE_ADDRESS..." echo "Connecting to $INSTANCE_ADDRESS to prepare environment for druid..."
ssh -i ~/.ssh/druid-keypair -o StrictHostKeyChecking=no ubuntu@${INSTANCE_ADDRESS} <<\EOI ssh -i ~/.ssh/druid-keypair -o StrictHostKeyChecking=no ubuntu@${INSTANCE_ADDRESS} <<\EOI
# Install dependencies - mysql and Java, and setup druid db # Install dependencies - mysql and Java, and setup druid db
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
@ -74,6 +76,15 @@ ssh -i ~/.ssh/druid-keypair -o StrictHostKeyChecking=no ubuntu@${INSTANCE_ADDRES
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo apt-get -y install oracle-java7-installer sudo apt-get -y install oracle-java7-installer
# Automated Kafka setup
curl http://static.druid.io/artifacts/kafka-0.7.2-incubating-bin.tar.gz -o /tmp/kafka-0.7.2-incubating-bin.tar.gz
tar -xvzf /tmp/kafka-0.7.2-incubating-bin.tar.gz
cd kafka-0.7.2-incubating-bin
cat config/zookeeper.properties
nohup bin/zookeeper-server-start.sh config/zookeeper.properties &
# in a new console
nohup bin/kafka-server-start.sh config/server.properties &
# Logout # Logout
exit exit
EOI EOI