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
add_database_node_op = AddDatabaseNodeOperation("Northwind")
# Execute the operation by passing it to maintenance.server.send
result = store.maintenance.server.send(add_database_node_op)
# Can access the new topology
number_of_replicas = len(result.topology.all_nodes)
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
add_database_node_op = AddDatabaseNodeOperation("Northwind", "C")
# Execute the operation by passing it to maintenance.server.send
result = store.maintenance.server.send(add_database_node_op)
Syntax
class AddDatabaseNodeOperation(ServerOperation[DatabasePutResult]):
def __init__(self, database_name: str, node_tag: str = None): ...
Parameters | Type | Description |
---|---|---|
database_name | str |
Name of a database for which to add the node. |
node_tag | str |
Tag of node to add. Default: a random node from the existing cluster topology will be added. |
Object returned by Send operation:DatabasePutResult |
Type | Description |
---|---|---|
raft_command_index | int |
Index of the raft command that was executed |
name | str |
Database name |
topology | DatabaseTopology |
The database topology |
nodes_added_to | list<str> |
New nodes added to the cluster topology. Will be 0 for this operation. |