Skip to main content

Adding a Database Node

  • 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.

  • 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

  • Use AddDatabaseNodeOperation to add another database-instance to the database-group.
  • The node added will be a random node from the existing cluster nodes.
// Create the AddDatabaseNodeOperation
// Add a random node to 'Northwind' database-group
var addDatabaseNodeOp = new AddDatabaseNodeOperation("Northwind");

// Execute the operation by passing it to Maintenance.Server.Send
DatabasePutResult result = store.Maintenance.Server.Send(addDatabaseNodeOp);

// Can access the new topology
var numberOfReplicas = result.Topology.AllNodes.Count();

Add database node - specific

  • You can specify the node tag to add.
  • This node must already exist in the cluster topology.
// Create the AddDatabaseNodeOperation
// Add node C to 'Northwind' database-group
var addDatabaseNodeOp = new AddDatabaseNodeOperation("Northwind", "C");

// Execute the operation by passing it to Maintenance.Server.Send
DatabasePutResult result = store.Maintenance.Server.Send(addDatabaseNodeOp);

Syntax

public AddDatabaseNodeOperation(string databaseName, string nodeTag = null)
ParametersTypeDescription
databaseNamestringName of a database for which to add the node.
nodeTagstringTag of node to add.
Default: a random node from the existing cluster topology will be added.
Object returned by Send operation:
DatabasePutResult
TypeDescription
RaftCommandIndexlongIndex of the raft command that was executed
NamestringDatabase name
TopologyDatabaseTopologyThe database topology
NodesAddedToList<string>New nodes added to the cluster topology.
Will be 0 for this operation.