# How to create a Crate Cluster from two node

**URL:** <https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369>\
**Category:** Configuration\
**Created:** [February 9, 2023, 10:57am UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369 "2023-02-09T10:57:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karabo\_Gerald](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/karabo_gerald/32/809_2.png) [@Karabo\_Gerald](https://community.cratedb.com/u/Karabo_Gerald)\
**Post date:** [February 9, 2023, 10:57am UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/1 "2023-02-09T10:57:48Z")

</div>

Hi, Guys.

I know this is supposed to be simple, but I’m having trouble with it. (backstory) we have a crate node on one server and we want to create a second node on a different server to create a cluster of 2 nodes. The reason for 2 notes is that we use crate to process and temporarily store data for the day, which is used by other platforms for calculations, once they are done, other scripts run to clear the tables for the next day. so far we are happy with one node, but we would like to run another one a redundancy. and daily records are around 20-30 million in 60 tables.

---

<div class="post-metadata">

**Author:** ![hernanc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/hernanc/32/676_2.png) [@hernanc](https://community.cratedb.com/u/hernanc)\
**Post date:** [February 9, 2023, 11:14am UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/2 "2023-02-09T11:14:38Z")

</div>

Hi,  
Please check the configuration file (typically `/etc/crate/crate.yml`) of the existing CrateDB server, if the node was started without specifying the `initial_master_nodes` setting (the default configuration), or with `discovery_type` set to `single-node`, it would have been started as a standalone instance and there is not clean way to scale it into a cluster.  
If you are in that situation I would advise setting up the new cluster in parallel, taking a [snapshot](https://crate.io/docs/crate/reference/en/5.1/admin/snapshots.html) and then restoring it in the new cluster.

If `initial_master_nodes` was set, then you can add nodes to that setup.  
There are many settings you can configure, but the basic steps are to prepare a new node installing CrateDB but making sure it does not auto-boostrap as a single-node instance, you may want to either create `/etc/crate/crate.yml` using [this](https://github.com/crate/crate/blob/master/app/src/main/dist/config/crate.yml) a template in advance or use a mechanism like `policy-rcd-declarative`.  
Set `discovery.seed_hosts` in the configuration file to the full list of nodes, including the new one you are adding, and start CrateDB, if it can reach the other node on TCP port 4300 it will join the cluster.

Please note that once a cluster has 2 nodes it cannot operate with a single node as it could not know for sure if the other node is alive in a network partition and the data has moved forward, if you are looking for high availability we advise to have a minimum of 3 nodes.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![cocoa](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/cocoa/32/783_2.png) [@cocoa](https://community.cratedb.com/u/cocoa)\
**Post date:** [February 19, 2023, 1:51pm UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/3 "2023-02-19T13:51:37Z")

</div>

Hi @hernanc ,

I have a cratedb server running as a docker container.  
The server was created as a single-node,  
the command used in docker compose is :  
`command: ["crate","-Cdiscovery.type=single-node"]`

It’s not clear to me how I can scale to two or more servers from this setup.

Would it be possible to have an example of settings to use in two separate docker composes (on two different hosts)?

Thx.

Luca

---

<div class="post-metadata">

**Author:** ![proddata](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/proddata/32/1379_2.png) [@proddata](https://community.cratedb.com/u/proddata)\
**Post date:** [February 20, 2023, 2:09pm UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/4 "2023-02-20T14:09:48Z")

</div>

Hi @cocoa

A cluster started with `discovery.type=single-node` unfortunately will never join a multi-node cluster.

* * *

> Would it be possible to have an example of settings to use in two separate docker composes (on two different hosts)?

Are we talking about a Docker swarm setup or just two independent hosts?  
A docker swarm example can be found here:

> [@Docker Swarm cluster](https://community.cratedb.com/t/docker-swarm-cluster/749/8):
>
> Finally fixed it ! [image] It was a networking issue, as pointed out [in this issue](https://github.com/deviantony/docker-elk/issues/455#issuecomment-708035654). The working stack: version: '3.5' services: crate: image: crate:latest ports: - "4200:4200" environment: SLOT: "{{.Task.Slot}}" volumes: - crate-data:/data hostname: "crate-{{.Task.Slot}}" command: \> crate -Ccluster.name=swarm -Cnode.name=crate-$${SLOT} -Cnetwork.publish\_host=\_eth0\_ -Cdiscovery.type='zen' -Cdiscovery.seed\_hosts=ta…

---

<div class="post-metadata">

**Author:** ![cocoa](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/cocoa/32/783_2.png) [@cocoa](https://community.cratedb.com/u/cocoa)\
**Post date:** [February 20, 2023, 5:46pm UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/5 "2023-02-20T17:46:37Z")

</div>

Hi @proddata,

my mistake in translating the answer about setting up with single-node.

Thanks for the docker swarm example.

At this point I would need to understand if it is possible to start with a single host that is able to scale later or if it is necessary to start from the beginning, for a scalable solution, with three CrateDB servers on three different hosts.

Out of curiosity, it is possible to start with an installation with three cratedb servers on single hosts [as the docker compose example here](https://crate.io/docs/crate/tutorials/en/latest/containers/docker.html#id10) and then migrate two of these services on two different hosts?

Thx,

Luca

---

<div class="post-metadata">

**Author:** ![proddata](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/proddata/32/1379_2.png) [@proddata](https://community.cratedb.com/u/proddata)\
**Post date:** [February 22, 2023, 1:27pm UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/6 "2023-02-22T13:27:38Z")

</div>

> At this point I would need to understand if it is possible to start with a single host that is able to scale later or if it is necessary to start from the beginning, for a scalable solution, with three CrateDB servers on three different hosts.

Yes, you can start with a single CrateDB node and add more nodes later.

To quickly try it:

- Create a network:

- Start one node (with an initial master node):

- Start a 2nd node (with the initial node in the seed\_hosts):

> Out of curiosity, it is possible to start with an installation with three cratedb servers on single hosts [as the docker compose example here](https://crate.io/docs/crate/tutorials/en/latest/containers/docker.html#id10) and then migrate two of these services on two different hosts?

In theory, yes. The CrateDB nodes need to see each other on the transport port (default 4300)

---

<div class="post-metadata">

**Author:** ![cocoa](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/cocoa/32/783_2.png) [@cocoa](https://community.cratedb.com/u/cocoa)\
**Post date:** [February 22, 2023, 5:26pm UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/7 "2023-02-22T17:26:33Z")

</div>

Thanks for the hint, this is the solution to my question.

Luca

---

<div class="post-metadata">

**Author:** ![Andy\_Teasdale](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/andy_teasdale/32/927_2.png) [@Andy\_Teasdale](https://community.cratedb.com/u/Andy_Teasdale)\
**Post date:** [June 5, 2023, 9:29am UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/8 "2023-06-05T09:29:00Z")

</div>

> Please note that once a cluster has 2 nodes it cannot operate with a single node as it could not know for sure if the other node is alive in a network partition and the data has moved forward, if you are looking for high availability we advise to have a minimum of 3 nodes.

Am setting up my first cluster, have 2 nodes defined, but due to networking issues currently neither can see each other. The above would explain why I’m not able to perform any operations (e.g. crate a new user etc) on the master node I’ve defined, or do I have another issue?

---

<div class="post-metadata">

**Author:** ![hernanc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/hernanc/32/676_2.png) [@hernanc](https://community.cratedb.com/u/hernanc)\
**Post date:** [June 5, 2023, 9:44am UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/9 "2023-06-05T09:44:36Z")

</div>

> have 2 nodes defined, but due to networking issues currently neither can see each other. The above would explain why I’m not able to perform any operations (e.g. crate a new user etc) on the master node I’ve defined, or do I have another issue?

If there were only 2 nodes and they cannot see each other anymore on the network they will stop serving requests. With 3 nodes it would be different. To make sure the issue is a network partition and not something else I recommend you check the logs, you can use `docker logs` for this if you are running CrateDB on containers.  
If the messages you see on the logs are not clear feel free to share them here and we can comment on those.

---

<div class="post-metadata">

**Author:** ![Andy\_Teasdale](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/andy_teasdale/32/927_2.png) [@Andy\_Teasdale](https://community.cratedb.com/u/Andy_Teasdale)\
**Post date:** [June 6, 2023, 4:14pm UTC](https://community.cratedb.com/t/how-to-create-a-crate-cluster-from-two-node/1369/10 "2023-06-06T16:14:05Z")

</div>

Great, thanks for confirming.
