Setting Up your first Cluster

In this post, I will help you to set up your first RavenDB cluster.

To be honest, it is not a difficult task.  In fact, you do not need to be an expert to manage a RavenDB cluster (We did our best to make it mostly self-managed).

What is the point of setting up a cluster?

A RavenDB cluster is a set of machines that have been joined together. Each machine in the cluster is a node.

When you create a database, it can live on a single node (one machine in the cluster), some number of the nodes or even all the nodes. Each node will then hold a complete copy of the database and will be able to serve all queries, operations and writes (RavenDB cluster implements multi-master replication).

The primary reason for this duplicating data is to allow  high availability. If a  node goes down, the cluster will still have a copies of the data, andthe cluster can shuffle things around so clients can talk to another node without really noticing that anything happened.

The cluster can distribute the work, handle the failures and adopt recovery procedures automatically.

So, let’s set up a cluster?

In fact, assuming that you are already started the RavenDB server on your computer,  you are already using a Cluster (a cluster with a single node, but still a cluster).

The thing you need to do is to add more nodes to your cluster (I will help you)

So, could we simply add nodes to a cluster?

Yes. We Can!  But, first we need to review our license: RavenDB Community edition only allows you to set up the cluster using 3 cores (total). So, before setting a cluster, we will need to reduce the number of cores in use of the current node. You can skip this depending on your license.

In the left panel, select the option Manage Server, and then Cluster. Then, in the list of nodes (there is only one), click in Operations and Reassign Cores

Change the number of Cores in Use to 1 and click on Save.

Starting the second node

Now that the “nodes problem” is solved. Let’s simple start a second instance of the RvenDB server. Typically, you would do that on a separate machine, but to make this exercise easier, we’ll run it on the same computer. Open a new terminal session and run the following command:

Note that we specified the address as 127.0.0.2:8080. The logs directory is Logs/B and data directory is Data/B. Two servers are running on your computer.

Open the Management Studio from the first server, then, In the left panel, select the option Manage Server, and then Cluster. So, click in Add Node To Cluster. Inform the address of the second server and hit Test Connection.

Success? Hit Add.

Starting your third node

I strongly recommend you to repeat the process to create the third node (on http://127.0.0.3:8080, storing data at Data/C and logs at Logs/C). I think you are able to do that.

In a future post, you will learn that makes little sense to setup a cluster with only two nodes.

Done?! This is our result:

Some new concepts

Now that you know what is a cluster, it is time to learn some new concepts. Are you ready? Let’s go:

  • Database – the named database we’re talking about,  regardless of whether we’re speaking about a specific instance or the whole group.
  • Database Instance – exists on a single node.
  • Database Group – the grouping of all the different instances, typically used to explicitly refer to its distributed nature.
  • Database Topology – the specific nodes that all the datab ase instances in a database group reside on in a particular point in time.

Consider you have a cluster with 5 nodes. It is possible to create a database setting the replication factor to only 3. So, only 3 nodes will have instances of the database. The selected nodes will form the Database Topology and all the three instances will constitute the Database Group. Got the idea?

In the future posts I will help you to create a database and how to specify the replication factor. Also, how to define what nodes will compose the Database Topology.

Last words…

Congratulations! Now you know how to setup a cluster. That was easy right?

RavenDB Studio is so easy to learn that I could bet you can discover how to replicate your databases. If not, no problem, we will discuss about it in future posts.

Let me know if you need help.

Compartilhe este insight:

Uma resposta

  1. I am trying to do the same on my machine, however when I try starting the second node with the command you are entering I get this error:
    System.IO.IException: Unable to start tcp listener on 127.0.0.1 on port 38888. Port might be already in use.

    I am curious how do you start the first node and I am also suspicious of using 127.0.0.2 as a localhost ? Can you please help.

    Thank you,
    All the best

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Elemar Júnior

Sou fundador e CEO da EximiaCo e atuo como tech trusted advisor ajudando diversas empresas a gerar mais resultados através da tecnologia.

Elemar Júnior

Sou fundador e CEO da EximiaCo e atuo como tech trusted advisor ajudando diversas empresas a gerar mais resultados através da tecnologia.

Mais insights para o seu negócio

Veja mais alguns estudos e reflexões que podem gerar alguns insights para o seu negócio:

To write parallel code is not a trivial task. There are details to consider and rules to observe. Could you...
Poucas empresas foram tão impactadas por inovações disruptivas quanto a Encyclopaedia Britannica – empresa com mais de 250 anos. Entretanto,...
“Microservices” is a trending topic. Big companies are trying to associate their technologies with this concept – but, it is...
Nos últimos dois posts demonstrei como as alocações podem implicar em penalidades de performance. Nesse post, parto, novamente, de código...
Em minhas consultorias, quando questionado sobre escalabilidade, recorro sempre ao scale cube, compartilhado no excelente livro “The Art of Scalability”,...
A EximiaCo não vende! Quando planejei a empresa decidi que ela não teria um departamento comercial. A estratégia é buscar...
× Precisa de ajuda?