# Joining a server

This page is about making a cluster and adding servers to it. All of it happens in **Server Admin, Cluster**. For DMZs, see [Pairing a DMZ](DMZ-Pairing.md).

## Creating a cluster

On the first server, **Create a cluster**:

> This makes this server the first member of a new cluster. Its users and settings do not change. Other servers and DMZs are added afterwards, each with a one-time code.

| Field | Is |
|---|---|
| **Cluster name** | a name for people |
| **Cluster port** | "The port the servers of the cluster talk to each other on. It must be open between them." |
| **This server's address** | "How the other servers reach this one, host or host:port. Several are separated by commas." |

**Create the cluster**, and the dialog answers: "The cluster … exists, with this server as its first member.", with "This server's fingerprint:" and the fingerprint. Note it. It offers **Add a server** at once.

A cluster of one is a real cluster: it changes nothing about how the server works, and it is the state from which servers and DMZs are added.

## Adding a server

Two machines, two steps. The new server needs CrushMFT 27 installed and running, with an Enterprise licence, and must be able to reach the cluster port of a member.

### 1. On a server of the cluster: make a code

**Add a server**:

> This makes a one-time code for a new server. On the new server you enter this server's address and the code; the new server checks this server's key by itself. Nothing changes here until the code is used.

**Label** is optional, "for web3": it is shown in Members while the code is open, so that you know which code was for what.

**Make a code** shows:

- "On the new server open Server Admin, Cluster, Join a cluster, and enter:" the **Address** and the **Code**, each with **Copy**;
- "This server's fingerprint is …. The new server checks it by itself.";
- "The code works once, until 14:32 (30 minutes left). Closing this dialog keeps it valid.";
- "Waiting for the new server to use the code...".

**Cancel the code** makes it void: "The code is cancelled. It cannot be used any more."

### 2. On the new server: join

**Join a cluster**:

> Joining does not change this server's users or settings. On a server of the cluster, use Add a server: it shows the address and the one-time code to enter here.

| Field | Is |
|---|---|
| **Address** | "The other server's address with its cluster port, as its screen shows it." |
| **Code** | the code. When it was typed wrong: "The code was mistyped." |
| **More: this server's cluster port and address** | how the other servers reach **this** one, if not by its host name |

**Join** shows its progress: **Connecting**, **Checking**, **Proving**, **Joined**. Then:

> This server joined the cluster … through … (fingerprint …).

with "This server's fingerprint, which the other server's screen shows too:". On the first server the waiting dialog shows the new member at the same moment. Both screens show both fingerprints: compare them if the two machines are not side by side in your own network.

From then on the two servers replicate with each other, and the new server is on every server's Cluster page.

### What the code does

The code holds a part of the first server's fingerprint and a secret. The new server connects, checks that the key it meets is the one the code names, and both sides prove to each other that they know the code, without sending it. Nobody who listens on the way learns it, and nobody in between can pose as either side. See [Trust between servers](Cluster-Trust.md#how-a-node-gets-into-the-list).

A code that was used, cancelled, or is older than 30 minutes is refused: "The code has ended without being used. Make a new one." After several wrong tries the open codes are made void and an alert is raised.

## Copying what was there before

Replication carries **changes**. A server that joins today learns of every user changed from today on, and knows nothing of the thousand users that were there yesterday.

So after a join, both screens say:

> Replication carries changes made from now on. What exists on the other servers already can be copied here.

On the new server, **Copy users and settings from …** (also under **More**):

> This copies what exists on … to this server, kind by kind. Replication carries the changes made from now on; this copies what existed before.

Tick the kinds: **Users**, **Groups**, **Inheritance**, **Jobs**, **Roles**, **Job key**.

| Switch | |
|---|---|
| **Also replace the ones that exist on both with …'s (otherwise they are left as they are)** | unticked: only what is missing here is added, and nothing that exists is touched |

> Copied: users, groups, inheritance, jobs, roles and the job key. Not copied: preferences, shares, PGP keys and reports.

So the preferences of a new server are yours to set: its ports, its certificate, its mail settings. The simplest way to a second server that is like the first is to install it from a copy of the first server's settings and then join it; the copy here is for a server that grew on its own.

The **job key** is what jobs are signed with. Without the same key on both servers, the jobs of one are unsigned on the other: see [Approvals](Jobs-Approvals.md).

Never copied, on purpose: the ports of a server, its licence, and its identity.

## Approval

A code is enough to join. Whoever holds it could also read the screen that made it.

For those who want a second pair of eyes: **More, Rename the cluster, approvals** has "Each join waits for an admin to approve it on the server that made the code". With it, a join shows under **Members** as **Waiting for approval**, with **Approve** and **Refuse**, and the button reads "Members (1 waiting)".

## Servers that replicate already

Servers that were tied together the old way, by address and shared secret, keep replicating after the update. Their Cluster page offers:

> This server replicates with other servers by address and shared secret. Bring them into a cluster, so they trust each other by key.

**Bring in the servers this one replicates with** lists the peers from the replication settings, each with its state:

| State | Means |
|---|---|
| Updated, fingerprint … | it can be added |
| Member | it is one already |
| Not updated to a version with clusters: update it first | |
| Not reachable | |

> Each one added becomes a member of the cluster and trusts this server by its key. Add takes over the current link: it is proven with the replication secret and marked unverified until you compare fingerprints. A code is the safest way.

**Add** takes the peer in on the strength of the old link. **Use a code** does it the strict way. "Adding a server does not change its users or settings."

A peer that was taken over is **Unverified** until you [compare fingerprints](Cluster-Trust.md#verified-and-unverified). Do that, for each one.

When all servers are members, switch replication to keys only: [Replication](Replication.md#by-key-or-the-old-way).

## Things to know

- **A server is in one cluster.** To move it to another, it leaves the first and gets a new identity: [Changing a key, removing a server](Cluster-Changes.md).
- **Any member can make a code.** There is no "main" server.
- **Names.** A node's name is what every Cluster page shows for it. **Rename** in the node's detail changes it for all.
- **What was tried**, when the cluster was built, on test servers on one machine: three servers joined by codes; a fourth joined through **Join a cluster** in the browser, and the open **Add a server** dialog on the first said by itself that it had joined; a code made and cancelled; the take-over of a replication peer, unverified and then verified; **Copy users and settings** (8 listed, 6 copied, 2 skipped). Not run: servers on separate machines and networks, Windows. Nothing was run again for this page; the page of a single test server was read.
