Create a Single-token DSE Cluster
Overview
Carefully generating tokens is key to maintaining overall cluster balance, and not a trivial task. Before the advent of Mission Control, using previous tools or manually allocating a token were the choices for setting a token and ensuring the best cluster balance. Even so, optimal balance is not guaranteed. Mission Control eases the task of creating single-token clusters.
- Single-token Cassandra clusters
-
each physical node owns only one token range in the token ring.
- Virtual nodes (vnodes)
-
each node in the cluster owns two or more token ranges. Vnodes mitigate the challenge of managing unbalanced clusters, where data is not distributed evenly amongst the nodes.
Historically, and by default, tokens are assigned through automatic allocation or via a token-generator tool. In Mission Control, ConfigMaps aid in implementing per node configuration changes like token assignments.
Token range recommended limits
Version | # token ranges |
---|---|
Cassandra v3.x |
256 tokens per node |
Cassandra 4.x |
256 tokens per node |
DSE 6.8 |
16 tokens per node |
Mission Control |
1 token per node |
Create a single-token cluster
This details how to set the num_tokens:
option to 1
.
Create a single-token cluster with Mission Control.
This example works with a single datacenter that has a single-rack cluster with six nodes. The replication factor (RF) is set to Mission Control’s default of 3
.
Modify the MissionControlCluster manifest to explicitly override the default of 16
in the config:cassandraYaml:num_tokens
section.
From this definition, Mission Control automatically generates initial tokens.
-
Required: Modify the
MissionControlCluster
manifest, explicitly specifyingconfig.cassandraYaml.num_tokens: 1
, as follows:apiVersion: missioncontrol.datastax.com/v1beta2 kind: MissionControlCluster metadata: name: demo spec: k8ssandra: cassandra: serverVersion: 6.8.26 serverType: dse config: cassandraYaml: num_tokens: 1 datacenters: - metadata: name: dc1 size: 6
This change necessarily overrides the default number of tokens (
16
) that DSE sets per node.Do not adjust the
initial_token
specification in theMissionControlCluster
manifest. From this manifest you cannot manually vary the configuration option based on the node to which it is applied. Let Mission Control generate the initial tokens per node for you. See Configure a DSE node. -
Issue the following command from a pod running DSE in the cluster and review the resulting cluster:
kubectl exec demo-dc1-rack1-sts-0 -c cassandra -- nodetool -u demo-superuser -pw PASSWORD ring
Replace
PASSWORD
with the password value.Sample results
Datacenter: dc1 ========== Address Rack Status State Load Owns Token 6148914691236517204 10.100.3.9 default Up Normal 144.48 KiB 50.00% -9223372036854775808 10.100.6.10 default Up Normal 209.15 KiB 50.00% -6148914691236517206 10.100.1.10 default Up Normal 118.17 KiB 50.00% -3074457345618258603 10.100.0.11 default Up Normal 209.87 KiB 50.00% -1 10.100.2.9 default Up Normal 170.66 KiB 50.00% 3074457345618258602 10.100.5.12 default Up Normal 200.67 KiB 50.00% 6148914691236517204
The result shows a perfectly balanced ring with 6 token ranges of equal size. The
Owns
column reveals that each node holds 50% of the data. This is the expected data ownership because every node is replicating 3 token ranges of ⅙ each of the whole ring.
Allowing Mission Control to assign tokens requires that you do not delete or modify the ConfigMaps that Mission Control uses to create the required per-node configuration. If you intend to use custom per-node configurations, then you must manually compute tokens per node. See Configure a DSE node. |
See also
-
Rebalancing a cluster: Assign tokens to new nodes that are joining an existing cluster.