Come impostare Cassandra Cluster su più nodi

⚡ Riepilogo intelligente

Cassandra Cluster groups multiple nodes so that data is distributed and no single machine holds everything. This page explains cluster components, the partitioner and token ring, prerequisites, the configuration settings that join nodes together, and how to verify the result.

  • 🧩 Cluster struttura: Nodes form data centres, and data centres form a cluster that behaves as one database.
  • 🎯 Partitioner Role: A hash of the partition key produces a token, and the token decides which node stores the row.
  • 🌱 Seed Nodes: Seeds are the contact points a new node gossips with first; they are not masters.
  • ⚙️ Impostazioni chiave: cluster_name, seeds, listen_address, and rpc_address must be set consistently in cassandra.yaml.
  • 🚀 Startup Order: Start seed nodes first, one at a time, then join the remaining nodes.
  • Verifica: nodetool status should list every node as UN with roughly even ownership.

Impostare Cassandra Cluster su più nodi

Cosa è Cassandra Cluster?

A Cassandra il cluster è una delle conchiglie nel loro insieme Cassandra Banca dati. Il Cassandra cluster contains numerous different layers of storage units, and each layer contains the other.

Grande organizzazione come Amazon, Facebook, etc. have a huge amounts of data to manage. So these organizations cannot store that huge amount of data on the single machine. This is when they use databases like Cassandra con architettura distribuita.

These organizations store that huge amount of data on multiple nodes. These nodes communicate with each other. For this purpose, Cassandra viene istituito il cluster.

  • Cluster is basically a group of nodes, so that nodes can communicate with each other easily.
  • Coordinator node is the node that receives a client request and communicates with the replicas on that client’s behalf. Any node can act as coordinator for any request.

Partizionatore

Un partizionatore determina come distribuire i dati nel cluster. Il partizionatore utilizza una funzione hash per distribuire i dati nel cluster. È necessaria la chiave di partizione per calcolare l'hash. Questo hash si chiama token. I dati vengono distribuiti sulla base di questo token.

The default partitioner is Murmur3Partitioner, which produces tokens spread evenly across a fixed range. Every node owns one or more ranges of that range, and the collection of ranges forms the token ring. Because assignment is by hash rather than by value, adding a node moves only the ranges it takes over rather than reshuffling the whole dataset.

Prerequisiti per Cassandra Cluster

Per la configurazione del cluster sono previsti i seguenti requisiti.

  1. You should have multiple machines, physical or virtual, acting as nodes.
  2. Nodes must be able to reach each other on the network. Ports 7000 for internode traffic, 7001 if TLS is enabled, and 9042 for client connections must be open between them.
  3. Linux should be installed on each node. It is the platform Cassandra is tested and supported on.
  4. Apache Cassandra must be installed on every node, at the same version. Mixed versions cannot complete a schema agreement.
  5. Un supportato JDK must be installed on each machine, with JAVA_HOME set.
  6. Clocks must be synchronised with NTP. Cassandra resolves conflicting writes by timestamp, so clock drift silently produces wrong results.

The last requirement is the one most often missed, and it causes data problems rather than startup failures.

.

Come installare Cassandra Cluster su Linux

Cassandra must be installed on each machine before any of them can join a cluster. The screenshots below come from the DataStax Enterprise graphical installer, which was the common route when this walkthrough was written. That installer is no longer distributed for community use, so the current approach is given first and the wizard follows for reference.

Current method: installare Apache Cassandra package or binary tarball on every node identically, then verify each one starts on its own before attempting to join them.

tar -xzf apache-cassandra-x.y.z-bin.tar.gz -C /opt/
export CASSANDRA_HOME=/opt/apache-cassandra-x.y.z
$CASSANDRA_HOME/bin/cassandra -f

Once a single node starts cleanly, stop it, clear its data directory, and move on to the cluster configuration section below.

Passo 1) Corri il Cassandra enterprise edition setup. On Linux terminal, run the setup. The following page will be displayed.

Installazione Cassandra Cluster su Linux

Questa pagina non fornisce alcuna informazione necessaria. Fornisce solo informazioni su Cassandra versione. Quindi passa questa pagina e premi il pulsante successivo.

Passo 2) Accept the license agreement. After pressing next button following page will be displayed.

Installazione Cassandra Cluster su Linux

Questa pagina fornisce informazioni sui pacchetti e sui sottopacchetti nel file Cassandra that is going to be installed. Below it will ask about the license. Check the checkbox ‘I accept the agreement’ and press next button.

Passo 3) Install Builder and Click Next. After pressing next button, you will see the following page.

Installazione Cassandra Cluster su Linux

Questa pagina ti chiede informazioni sulle opzioni di installazione.

  1. Prima di tutto, ti verrà richiesta la directory di installazione. Per impostazione predefinita, è installato nella directory home.
  2. Successivamente, viene chiesto il tipo di installazione, selezionare Installazione semplice.
  3. Successivamente, viene chiesto informazioni sul sistema di aggiornamento, seleziona "no".
  4. Next, it asks for default interface. There are two options, you can install on the localhost or select IP address. Select IP address for installation.
  5. Premi il pulsante successivo.

Passo 4) Setup Node and Click Next. After pressing the next button the following page will be displayed.

Installazione Cassandra Cluster su Linux

Questa pagina chiede informazioni sulla configurazione del nodo.

  1. First, select Node type ‘Cassandra Node’.
  2. Successivamente, in Nome anello, inserisci il nome del tuo cluster. Cluster il nome dovrebbe essere lo stesso per tutti i nodi nello stesso cluster.
  3. Next, select the seed. Seed is the node which other non-seed nodes contact when they start.
  4. Dopo aver fornito queste informazioni, premere il pulsante successivo.

Passo 5) Install the monitoring agent. After pressing next button, the following page will be displayed. This page asks for the IP address where the agent should be installed.

  1. The agent is needed for the monitoring console, where all nodes can be observed in one place.
  2. Dopo aver fornito queste informazioni, premere il pulsante successivo.

Installazione Cassandra Cluster su Linux

Passo 6) Press next for Installation. After pressing the next button the following page will be displayed.

Installazione Cassandra Cluster su Linux

Ora il setup è pronto per l'installazione. Premere il pulsante successivo.

Passo 7) Wait for Installation Process. After pressing next button, following page will be displayed.

Installazione Cassandra Cluster su Linux

Setup will start installing.

Passo 8) Click On Finish Button. After the installation, following page will be displayed. On the same page, you will see the check mark for the option which appears by default.

Installazione Cassandra Cluster su Linux

Configuring cassandra.yaml to Join Nodes

Installation alone does not create a cluster. Nodes only find each other once four settings in cassandra.yaml agree, and this file is where most cluster setups go wrong.

cluster_name: 'Guru99 Cluster'
seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvider
    parameters:
      - seeds: "192.168.1.10,192.168.1.11"
listen_address: 192.168.1.10
rpc_address: 0.0.0.0
broadcast_rpc_address: 192.168.1.10
endpoint_snitch: GossipingPropertyFileSnitch
  • nome_cluster must match on every node. A mismatch is the most common cause of a node refusing to join.
  • semi lists the contact points a starting node gossips with. Two or three seeds per data centre is enough; making every node a seed prevents automatic bootstrapping.
  • listen_address is the address other nodes use to reach this one. It must be a real routable address, never localhost.
  • endpoint_snitch dice Cassandra the rack and data centre layout. GossipingPropertyFileSnitch is the usual choice, with values set in cassandra-rackdc.properties.

Changing the snitch or cluster name after data exists requires extra steps, so both should be decided before the first node starts.

Partenza Cassandra Nodo

Dopo l'installazione Cassandra on each node, start the servers and follow the steps below. Order matters: start the seed nodes first, one at a time, waiting for each to report as up before starting the next. Starting several nodes simultaneously can produce token range conflicts.

Passo 1) Vai Cassandra installation directory and start the server.

bin/cassandra -f

Partenza Cassandra Nodo

By executing this command, the Cassandra server will be started. Here is the screenshot where the Cassandra server is starting.

Partenza Cassandra Nodo

After roughly a minute the server will be up. Start each node server one by one. After starting all the node servers, your Cassandra il cluster è pronto per l'uso.

Passo 2) Verify that every node has joined by checking the ring from any one of them.

nodetool status
nodetool describecluster

Every node should appear with status UN, meaning Up and Normal, and the Owns column should show roughly equal percentages. A single schema version in describecluster output confirms all nodes agree on the schema.

Three symptoms cover most failures. A node that never appears usually has a mismatched cluster_name or a blocked port 7000. A node stuck at UJ, joining, is still streaming data and simply needs time on a large cluster. Wildly uneven ownership points at a snitch misconfiguration, where nodes were placed in the wrong rack or data centre.

With the ring healthy, replication settings for each keyspace decide how data spreads across it, as described in the Cassandra spazio chiave tutorial and the Cassandra architettura abbattersi.

DOMANDE FREQUENTI

Three, matching the standard replication factor of three. That allows QUORUM reads and writes to continue while one node is down for maintenance or failure.

No. Seeds only serve as contact points during startup and gossip. They store data like any other node, and losing one does not affect a running cluster.

Install the same version, point it at existing seeds, and start it. It bootstraps automatically by streaming its token ranges. Run nodetool cleanup on the other nodes afterwards.

Given data volume, replication factor, and throughput targets, AI produces a reasonable starting node count. Validate it with a load test, because compaction and repair overhead are workload specific.

Yes. Supplying system.log alongside cassandra.yaml usually surfaces the cause quickly, most often a cluster name mismatch, a blocked port, or listen_address left as localhost.

Riassumi questo post con: