检查所有 cassandra 节点的健康状况

Checking health of all cassandra nodes

我正在编写测试来检查 cassandra 键空间和表的元数据信息。 我还想检查集群中哪个节点启动或关闭。我该怎么做?

nodetool 实用程序可让您访问诊断和操作信息。

nodetool ring

将为您提供环中节点及其状态的列表。

您还可以从 node.js 驱动程序中获取信息。 Client has a hosts attribute. Each host has a isUp function you can use. An example 显示使用元数据:

"use strict";
const cassandra = require('cassandra-driver');

const client = new cassandra.Client({ contactPoints: ['127.0.0.1'] });
client.connect()
  .then(function () {
    console.log('Connected to cluster with %d host(s): %j', client.hosts.length);
    client.hosts.forEach(function (host) {
      console.log('Host %s v%s on rack %s, dc %s, isUp: %s', host.address, host.cassandraVersion, host.rack, host.datacenter, host.isUp());
    });
    console.log('Shutting down');
    return client.shutdown();
  })
  .catch(function (err) {
    console.error('There was an error when connecting', err);
    return client.shutdown();
  });