EventStoreDB Cluster with AWS
While EventstoreDB is just gaining its popularity, some of the AWS-certified developers have already called it one of the most useful tools for implementing the event-driven architecture. However, there is just a pinch of information online about EventstoreDB. And, considering that I don’t want to keep you in the dark, I’ve prepared a guide on setting up an EventStoreDB cluster with AWS.
The EventStoreDB cluster functions without shared disks. How does it work then? It uses the shared-nothing philosophy according to its principle you have three different physical drivers (aka nodes). The main benefit of the shared-nothing approach is that, when one node crashes, the data remains safe because each of the three nodes retains identical pieces of data.
Now that you know the basics, we can set off our installation of the EC2 instance group. This article uses Amazon free tier, so don’t hesitate to try all the steps on your own.
The First thing you want to do — is to open your AWS management console. Then go to the EC2 section and then click on Instances. After that, navigate to a beautiful orange Launch instances button.
Proceed by choosing “Ubuntu Server 20.04 LTS” as your chosen AMI.
Good job! Now select the free tier instance type.
(Instance with type t2.micro fits good for testing purpose and anyone will be able to follow along with our steps without spending money)
We need to change the number of instances to 3 because EventStoreDB uses a quorum-based replication model. So, by changing the number of instances to 3 we’ll allow the model to tolerate 1 node failure.
Within the model, the majority of nodes in the cluster must acknowledge that they commit a write to the client after they write to disk.
Make no changes on the next step to continue using a free plan.
Skip this step as well. We won’t need tags in this guide. But I strongly recommend adding tags that are very useful and informative, especially for huge infrastructure.
Create a new group titled “eventstore-example-sg”. It’ll allow us to access the instances through ssh (22), default EventStoreDB port/http (2113) and enable communication between nodes via port/http 1112.
I’ll leave the instances open for all IPs just to simplify the example. AWS development services and I personally, recommend that you set your security group rules to allow access from known IP addresses only.
Excited? You’d better be because we’ve approached the moment when we have to press the Launch button. After a new window pops up, we create a new key pair and download the “.pem” file. Without this file, you won’t be able to connect to your EC2 instances via ssh.
Press Launch instances button to create your instances. Once they’re up and running, we can proceed with the configuration of the cluster.
Now you should prepare a list of private IPs. We’ll reference them in our config files as private-ip-node-1, private-ip-node-2, private-ip-node-3.Click on the instance and open the Details tab to take a look at the instance’s private IP. To do so select one particular instance and check the private IPv4 addresses field.
Moving on! I hope you’re still with me, aren’t you? It’ll be over soon, I promise.
And now we should prepare a config file for each instance.
To make life easier for you, I’m adding a template for the config file (please, pay attention to spaces when copying, since it uses yaml format).
This template should be used for the 1st file, so keep in mind that it should be linked to 2nd and 3rd nodes via GossipSeed. The Same logic applies to the rest of the nodes.
This is a guide with simplified security configuration. To get more information about security configuration, address EventStoreDB documentation.
And if you don’t like the template, try EventStoreDB developers offer you to prepare configs using configuration wizard.
Congratulations, your configs are prepared and you can move on with configuration.
The Next thing you want to do is to simply connect to the instance and run the following commands (*repeat the action for each node):
Switch to the Connect page and follow all the necessary steps to establish ssh connection.
Once you are connected to the node, run the next commands:
- Install EventStoreDB package (currently the latest version is v21.2.0)
$ curl -s https://packagecloud.io/install/repositories/EventStore/EventStore-OSS/script.deb.sh | sudo bash
$ sudo apt-get install eventstore-oss=21.2.0
- Put eventstore config for particular instance in this file
$ sudo nano /etc/eventstore/eventstore.conf
- Start instance
$ sudo systemctl start eventstore
Do you remember our instances are accessible?
You can check whether your cluster is ready for using http://public-ip-node-1:2113/web/index.html#/clusterstatus. (The public IP is indicated right near the private IP). As you can see all the nodes are alive, with one Leader node and two Follower nodes.
And just like that, you’ve integrated EventStoreDB Cluster with AWS. Mind, however, that this isn’t a production-ready cluster, just a working example to start with.
And another subtle hint we want to remind you, Event Store Cloud is (SaaS) a delivery platform that allows developers to build and run highly available and secure web and mobile applications. It is also a proven effective tool for operating the underlying infrastructure. So if you need assistance with the provisioning EventStoreDB cluster in AWS, we got you covered.
Our AWS development services are also at your beck. Don't hesitate to contact us!
Thanks for reading! We hope you enjoyed learning about setting up EventStoreDB Cluster with AWS. Let us know if you have questions. We'll be glad to discuss. Check up more of our blogs!
Let's engineer your breakthrough
79015, Smal-Stotskoho St. 1 Ukraine
50-062, Plac Solny 15 Poland
Nieuwe keizersgracht 1 A Netherlands