/
ec2try.sh
81 lines (62 loc) · 2.28 KB
/
ec2try.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# provide aws credentials for command line tools
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export EC2_PRIVATE_KEY=...
export EC2_CERT=...
# provide aws account id for our own use
export AWS_ACCOUNT_ID=...
# create key pair
ec2addkey doozer | tail -n +2 > doozer.pem
chmod 600 doozer.pem
# create security group
ec2addgrp doozer -d "Doozer distributed datastore"
# enable ssh access to the group
ec2auth doozer -P tcp -p 22
# enable udp traffic among the nodes on the doozer port
ec2auth doozer -P udp -p 8046 -o doozer -u $AWS_ACCOUNT_ID
# enable tcp traffic among the instances and from external users on the doozer port
ec2auth doozer -P tcp -p 8046
# enable tcp traffic from external users for web access
ec2auth doozer -P tcp -p 8047
# launch 4 64 bit instances in the security group
ec2run ami-9043bff9 -t m1.large -g doozer -k doozer -n 4
# wait for the instances to come online
watch ec2din
# ssh to the first instance
ssh -i doozer.pem ubuntu@$PUBLIC_IP_1
sudo -i
# verify that you can receive tcp traffic from outside clients
# on the instance
nc -l -p 8046
# on your machine
echo "test tcp" | nc $PUBLIC_IP_1 8046
# ssh to the second instance
ssh -i doozer.pem ubuntu@$PUBLIC_IP_1
sudo -i
# verify that you can send udp traffic among the instances
# on the first instance
nc -u -l 8046
# on the second instance
echo "test udp" | nc -u $PRIVATE_IP_1 8046
# install and start dooozerd on the first instance
cd /opt
wget --no-check-certificate https://github.com/downloads/ha/doozerd/doozer-0.6-linux-amd64.tar.gz
tar xfz doozer-0.6-linux-amd64.tar.gz
rm doozer-0.6-linux-amd64.tar.gz
cd doozer-0.6
./doozerd -l $PRIVATE_IP_1:8046 -w 0.0.0.0:8047
# indicate that we expect two more nodes to join this cluster as consensors
echo -n | ./doozer -a $PRIVATE_IP_1:8046 add /ctl/cal/1
echo -n | ./doozer -a $PRIVATE_IP_1:8046 add /ctl/cal/2
# join the other 3 nodes to the cluster
# for each N in 2,3,4
ssh -i doozer.pem ubuntu@$PUBLIC_IP_N
sudo -i
cd /opt
wget --no-check-certificate https://github.com/downloads/ha/doozerd/doozer-0.6-linux-amd64.tar.gz
tar xfz doozer-0.6-linux-amd64.tar.gz
rm doozer-0.6-linux-amd64.tar.gz
cd doozer-0.6
./doozerd -a $PRIVATE_IP_1:8046 -l $PRIVATE_IP_N:8046 -w 0.0.0.0:8047
# check the web interface for one of the public ips
open http://$PUBLIC_IP_4:8057