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 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, 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 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 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:

  Recently, I asked what would be the execution result of the following code: using System.Threading.Tasks; using static System.Console; class...
Aqui, um registro da apresentação que realizei na abertura do IoT Weekend. O que você acha do que foi dito?
Pessoas diferentes têm realidades diferentes e, por isso, são impactadas pela crise de maneiras diferentes. Tenho consciência de que meu...
Como você pode se considerar um profissional se você não sabe se todo seu código funciona? Como você pode saber...
Superficialmente, direito e privilégio são conceitos que se aproximam e, eventualmente, se confundem. Mas, com um pouco de cuidado, ficam...
O banco onde sou correntista está demorando mais para processar recebimentos do que o usual. Ao conversar com meu gerente,...
× Precisa de ajuda?