Diving into HarperDB, a distributed database platform designed for the edge, on Digital Ocean and Linode.
In a previous article, I deployed HarperDB on AWS and GCP via HarperDB Studio and Terraform. Given HarperDB’s excellent support for Docker, deploying it on any Linux VM was very trivial. To test it out on other cloud providers, I decided to deploy HarperDB on Digital Ocean and Linode as well.
You can follow along or clone each GitHub repo:
To get started, we first need to create a Digital Ocean account and download a personal access token. After signing up for a free account, navigate to API section, and click on Generate New Token.
Copy the token and set the variable in your terminal:
Now we need to set the Terraform provider for Digital Ocean:
Terraform will automatically pick up DIGITALOCEAN_ACCESS_TOKEN and pass it to the provider.
Next, we need to define a VM and firewall rules to allow ssh and access to ports 9925 and 9926.
We are creating an Ubuntu 18.04 VM in NYC1 region with predefined user_data field from harperdb.yaml file. This file essentially bootstraps users, authorized keys, Docker, and starts the HarperDB container.
Before running Terraform, we need to create an SSH key to access the VM. Otherwise adding new keys will trigger Terraform to recreate the instance.
Create a SSH key pair by running the following:
Then grab the public key (one starting with ssh-rsa ... ) and paste that under ssh_authorized_keys .
Now we’re ready to run the plan and apply!
The IP address for the Digital Ocean VM will be printed in the console via the outputs.tf file. Copy that IP address and we can interact with the DB as usual:
Deploying HarperDB onto Linode is also simple. Create a free Linode account and click on API Tokens under your profile. Click on “Create a Personal Access Token” to generate a token for Terraform to use.
To pass this token to Linode Terraform provider, we will make use of Terraform variables file. Create terraform.tfvars and paste in the following:
The root_pass field will be used to bootstrap the VM on Linode.
Then in main.tf we will configure the Linode provider:
Finally, we will create a Ubuntu 18.04 VM in us-east region and open up ssh and ports 9925–9926:
Run the plan and create the infrastructure:
Once the VM is created, navigate to the Linode console and click Launch LISH Console . Then we can log in as root with the password defined in the variables file.
Now we just need to install Docker and create a directory for persistence.
First, follow the instructions to download docker: https://docs.docker.com/engine/install/debian/#prerequisites
Then create harperdb directory and run the container:
Now we can use CURL commands to create schema like before:
Now that HarperDB is running on Digital Ocean and Linode, we can link them via HarperDB Studio as we did before with AWS and GCP. To allow HTTP connection, enable mix content on your browser.
Then click Register User-Installed Instance and fill out the information:
After registering, you should now see the schema we created via CURL. Finally, to enable clustering, navigate to the cluster button and create the same user in all the instances accordingly. Once the pub/sub topology is defined, then the changes made to one node will be synced to all subscribers in the cluster.
HarperDB Studio simplifies the management of multiple HarperDB instances running on one or more clouds. By connecting the databases we deployed to Digital Ocean and Linode via HarperDB Studio, we can set up data synchronization strategies to unlock interesting use cases. Imagine running some HarperDB instances on the edge and syncing up data on the cloud as needed.
Finally, once you are done testing, to avoid further charges, make sure to delete all created infrastructure via terraform destroy .
Note: You can find additional prebuilt templates for multi-cloud deployment, authentication, API caching, and more in the HarperDB Development Repo.