-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
PROJECT="project-id-here" | ||
MACHINE="n1-standard-1" | ||
ZONE="europe-west1-d" | ||
MACHINE="g1-small" | ||
NODE="cass2" | ||
SEED="cass1" | ||
NODE="node02" | ||
|
||
if [ $# -ge 1 ] | ||
then | ||
NODE=$1 | ||
NODE=$1 | ||
fi | ||
|
||
echo "using ${NODE} as instance name" | ||
|
||
if [ $# -ge 2 ] | ||
then | ||
SEED=$2 | ||
SEED=$2 | ||
else | ||
echo "looking for a running instance that has 'cassandra-seed' label set to 'true'" | ||
SEED=$(gcloud compute instances list --filter="labels.cassandra-seed=true" --format="value(name)") | ||
fi | ||
|
||
echo "using ${SEED} as seed instance name" | ||
|
||
gcloud compute instances create $NODE --zone $ZONE --machine-type $MACHINE --network "default" --maintenance-policy "MIGRATE" --scopes default="https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring.write","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" --image "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts" --boot-disk-size "10" --boot-disk-type "pd-standard" --boot-disk-device-name "$NODEd1" --project $PROJECT | ||
gcloud compute instances create ${NODE} --zone ${ZONE} --machine-type ${MACHINE} --maintenance-policy "MIGRATE" --image "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts" --boot-disk-size "20" --boot-disk-type "pd-standard" --boot-disk-device-name "${NODE}disk" | ||
|
||
echo "waiting for the machine to come up" | ||
sleep 30 | ||
|
||
gcloud compute ssh --project $PROJECT $NODE --zone $ZONE --command "wget -qO- https://raw.githubusercontent.com/academyofdata/cassandra-cluster/master/setup39.sh | bash" | ||
gcloud compute ssh $NODE --zone $ZONE --command "wget -qO- https://raw.githubusercontent.com/academyofdata/cassandra-cluster/master/setup39.sh | bash" | ||
|
||
|
||
IPADDR=`gcloud compute instances list --project $PROJECT --format=text $NODE | grep '^networkInterfaces\[[0-9]\+\]\.networkIP:' | sed 's/^.* //g'` | ||
SEEDIP=`gcloud compute instances list --project $PROJECT --format=text $SEED | grep '^networkInterfaces\[[0-9]\+\]\.networkIP:' | sed 's/^.* //g'` | ||
IPADDR=$(gcloud compute instances list --filter="name=${NODE}" --format="value(networkInterfaces[0].networkIP)") | ||
SEEDIP=$(gcloud compute instances list --filter="name=${SEED}" --format="value(networkInterfaces[0].networkIP)") | ||
|
||
echo "configuring cassandra after installation with $IPADDR and seed $SEEDIP" | ||
gcloud compute ssh --project $PROJECT $NODE --zone $ZONE --command "wget -qO- https://raw.githubusercontent.com/academyofdata/cassandra-cluster/master/config-cassandra.sh | bash -s $IPADDR $SEEDIP" | ||
gcloud compute ssh $NODE --zone $ZONE --command "wget -qO- https://raw.githubusercontent.com/academyofdata/cassandra-cluster/master/config-cassandra.sh | bash -s $IPADDR $SEEDIP" | ||
|
||
gcloud compute instances add-labels ${NODE} --zone ${ZONE} --labels=cassandra-cluster-name=cassandra-training |