Skip to content

Instantly share code, notes, and snippets.

@pauliusuza
Forked from jenschelkopf/hot-cloud-swap-script.md
Last active August 29, 2015 14:16
Show Gist options
  • Save pauliusuza/64a6ab8c3dd2dbda2bf8 to your computer and use it in GitHub Desktop.
Save pauliusuza/64a6ab8c3dd2dbda2bf8 to your computer and use it in GitHub Desktop.

Cheat Sheet for the FoundationDB 'Hot Cloud Swap' Screencast

Initial Cluster Setup on Digital Ocean

Grab the client and server packages from the FoundationDB website

ansible -i inventory digital_ocean -a "wget https://foundationdb.com/downloads/f-nbxofdxnoxocd/I_accept_the_FoundationDB_Community_License_Agreement/key-value-store/2.0.9/foundationdb-clients_2.0.9-1_amd64.deb https://foundationdb.com/downloads/f-nbxofdxnoxocd/I_accept_the_FoundationDB_Community_License_Agreement/key-value-store/2.0.9/foundationdb-server_2.0.9-1_amd64.deb"

Install the client and server packages

ansible -i inventory digital_ocean -a "sudo dpkg -i foundationdb-clients_2.0.9-1_amd64.deb foundationdb-server_2.0.9-1_amd64.deb"

Run the included make_public script, which uses the machine's interfaces to find the public IP address

ansible -i inventory digital_ocean -a "python /usr/lib/foundationdb/make_public.py"

Grab the cluster file from one of the machines

scp root@104.236.38.62:/etc/foundationdb/fdb.cluster .

Stop the service

ansible -i inventory digital_ocean -a "service foundationdb stop"

Copy the cluster file up to all the machines, joining them into a single cluster

ansible -i inventory digital_ocean -m copy -a "src=fdb.cluster dest=/etc/foundationdb/fdb.cluster" --sudo

Start the service

ansible -i inventory digital_ocean -a "service foundationdb start"

Setup triple replication

ssh root@104.236.38.62 "fdbcli --exec 'configure triple'"

Automatically configure coordinators (used for fault-tolerance)

ssh root@104.236.38.62 "fdbcli --exec 'coordinators auto'"

Check the status

ssh root@104.236.38.62 "fdbcli --exec 'status details'"

Moving the Cluster to AWS

Grab the client and server packages from the FoundationDB website

ansible -i inventory aws -a "wget https://foundationdb.com/downloads/f-nbxofdxnoxocd/I_accept_the_FoundationDB_Community_License_Agreement/key-value-store/2.0.9/foundationdb-clients_2.0.9-1_amd64.deb https://foundationdb.com/downloads/f-nbxofdxnoxocd/I_accept_the_FoundationDB_Community_License_Agreement/key-value-store/2.0.9/foundationdb-server_2.0.9-1_amd64.deb"

Install the client and server packages

ansible -i inventory aws -a "sudo dpkg -i foundationdb-clients_2.0.9-1_amd64.deb foundationdb-server_2.0.9-1_amd64.deb"

Stop the service

ansible -i inventory aws -a "sudo service foundationdb stop"

I need to modify the public and listen address in the configuration files. Unfortunately aws machines doesn't have access to this information internally, so I'm using the meta-data url to grab it.

ansible -i inventory aws -m shell -a 'public_ip=$(curl http://169.254.169.254/latest/meta-data/public-ipv4) ; sudo sed -i "s/auto/$public_ip/" /etc/foundationdb/foundationdb.conf'

ansible -i inventory aws -m shell -a 'private_ip=$(curl http://169.254.169.254/latest/meta-data/local-ipv4) ; sudo sed -i "s/listen_address = public/listen_address = $private_ip:\\$ID/" /etc/foundationdb/foundationdb.conf'

Take a look at the configuration file

ssh ubuntu@ec2-54-234-163-74.compute-1.amazonaws.com "sudo cat /etc/foundationdb/foundationdb.conf"

Grab the cluster file from one of the machines

scp root@104.236.38.62:/etc/foundationdb/fdb.cluster .

Copy the cluster file up to all the machines, joining them into a single cluster

ansible -i inventory aws -m copy -a "src=fdb.cluster dest=/etc/foundationdb/fdb.cluster" --sudo

Start the process

ansible -i inventory aws -a "sudo service foundationdb start"

Check the status: now you'll see 10 machines!

ssh ubuntu@ec2-54-234-163-74.compute-1.amazonaws.com "fdbcli --exec 'status details'"

Exclude the Digital Ocean machines

ssh ubuntu@ec2-54-234-163-74.compute-1.amazonaws.com "fdbcli --exec 'exclude 104.236.38.62 104.236.32.172 104.236.26.156 104.236.26.157 104.236.26.158'"

The Key-Value Store uses coordinators to maximize the fault tolerance of the cluster. Now that we've excluded the digital ocean machines, let's tell the database to choose new coordinators.

ssh ubuntu@ec2-54-234-163-74.compute-1.amazonaws.com "fdbcli --exec 'coordinators auto'"

And let's take a look at the status again.

ssh ubuntu@ec2-54-234-163-74.compute-1.amazonaws.com "fdbcli --exec 'status details'"

Now I can shutdown the digital ocean servers:

ansible -i inventory digital_ocean -a "sudo shutdown now"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment