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();
// 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.SendAsync
DatabasePutResult result = await store.Maintenance.Server.SendAsync(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);
// 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.SendAsync
DatabasePutResult result = await store.Maintenance.Server.SendAsync(addDatabaseNodeOp);
Syntax
public 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. Default: a random node from the existing cluster topology will be added. |
Object returned by Send operation:DatabasePutResult |
||
---|---|---|
RaftCommandIndex | long | Index of raft command that was executed |
Name | string | Database name |
Topology | DatabaseTopology |
The database topology |
NodesAddedTo | List<string> | New nodes added to the cluster topology. Will be 0 for this operation. |