---
title: "Adding a Database Node"
url: "https://docs.ravendb.net/6.2/client-api/operations/server-wide/add-database-node"
version: "6.2"
language: "php"
---

# Adding a Database Node

> Client language: PHP. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/server-wide/add-database-node.md), [Python](https://docs.ravendb.net/6.2/client-api/operations/server-wide/add-database-node.python.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/server-wide/add-database-node.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - When creating a database, you can specify the number of replicas for that database.  
>   This determines the number of database instances in the database-group.
>
> - **The number of replicas can be dynamically increased** even after the database is up and running,  
>   by adding more nodes to the database-group.
>
> - The nodes added must already exist in the [cluster topology](https://docs.ravendb.net/6.2/server/clustering/rachis/cluster-topology.md).
>
> - Once a new node is added to the database-group,  
>   the cluster assigns a mentor node (from the existing database-group nodes) to update the new node.
>
> - In this page:
>   - [Add database node - random](#add-database-node---random)
>   - [Add database node - specific](#add-database-node---specific)
>   - [Syntax](#syntax)

## Add database node - random

- Use `AddDatabaseNodeOperation` to add another database-instance to the database-group.
- The node added will be a random node from the existing cluster nodes.

```php
// Create the AddDatabaseNodeOperation
// Add a random node to 'Northwind' database-group
$addDatabaseNodeOp = new AddDatabaseNodeOperation("Northwind");

// Execute the operation by passing it to Maintenance.Server.Send
/** @var DatabasePutResult $result */
$result = $store->maintenance()->server()->send($addDatabaseNodeOp);

// Can access the new topology
$numberOfReplicas = count($result->getTopology()->getMembers());
```

## Add database node - specific

- You can specify the node tag to add.
- This node must already exist in the cluster topology.

```php
// Create the AddDatabaseNodeOperation
// Add node C to 'Northwind' database-group
$addDatabaseNodeOp = new AddDatabaseNodeOperation("Northwind", "C");

// Execute the operation by passing it to Maintenance.Server.Send
/** @var DatabasePutResult $result */
$result = $store->maintenance()->server()->send($addDatabaseNodeOp);
```

## Syntax

```php
AddDatabaseNodeOperation(?string $databaseName, ?string $nodeTag = null)
```

| Parameters | Type | Description |
| - | - | - |
| **$databaseName** | `?string` | Name of a database for which to add the node. |
| **$nodeTag** | `?string` | Tag of node to add.<br />Default: a random node from the existing cluster topology will be added. |

| Object returned by Send operation:<br />`DatabasePutResult` | Type | Description |
| - | - | - |
| $name | `string` | Database name |
| $topology | `DatabaseTopology` | The database topology |
| $nodesAddedTo | `StringArray` | New nodes added to the cluster topology.<br />Will be 0 for this operation. |
| $raftCommandIndex | `int` | Raft command index |
