Shard cluster management and monitoring
You can scale out a shard cluster by adding new shard servers. You can also change the shard cluster's definition to change where rows or documents are distributed to.
Modifying a shard-cluster and adding or removing shard servers
To modify the servers in a shard cluster, run the cdr
change shardCollection command on one of the shard servers.
The cdr change shardCollection command performs
the following actions:
- A new sharding definition is created.
- Using the new sharding definition, existing data is distributed across the shard servers.
- The original sharding definition is deleted.
Note: You can add new servers, remove existing servers, or
modify the sharding definition, but you cannot change the type of
sharding definition. A hash-based sharding definition cannot change
to an expression-based sharding definition, and an expression-based
sharding definition cannot change to a hash-based sharding definition.
The
following example shows how to add capacity to a shard cluster that
uses a hash-based sharding definition. The original shard cluster
was defined with the following command:
cdr define shardCollection collection_1 db_1:john.customers
--type=delete --key=identifier --strategy=hash --versionCol=version
g_shard_server_1
g_shard_server_2
Run the following command to add g_shard_server_3 to
the shard cluster:
cdr change shardCollection collection_1 --add g_shard_server_3
The
following example shows how to add a new region-specific server to
a shard cluster that uses an expression-based sharding definition.
The original shard cluster was created with the following command:
cdr define shardCollection collection_2 db_2:john.clients
--type=delete --key=state --strategy=expression –-versionCol=version
g_shard_server_1 "IN ('WA','OR')"
g_shard_server_2 "IN ('CA','NV')"
g_shard_server_3 remainder
Run the following
command to add g_shard_server_4 to the shard cluster:
cdr change shardCollection collection_2 --add
g_shard_server_4 "IN ('UT','ID')"
A new sharding definition is created. Any rows or documents
that have a shard key of UT or ID are moved from g_shard_server_3 to g_shard_server_4,
and all future inserts are distributed according to the new sharding
definition.You can remove servers from a shard cluster using the --drop option or entirely replace a sharding definition with the --replace option.
Monitoring a shard cluster
To see the current
definition for a shard cluster, you can run the cdr list
shardCollection command on one of the shard servers, and
specify the definition's name. For example:
cdr list shardCollection my_collection
To see information on the shard cache, run the onstat -g shard command on one of the shard servers.
Stopping data distribution and deleting a sharding definition
To stop data distribution and delete the sharding
definition, run the cdr delete shardCollection on
one of the shard servers, and specify the definition's name. For example:
cdr delete shardCollection my_collection