0Pricing
Elasticsearch & Full Text Search Systems · 课时

集群健康状况与监控

学习监控集群健康状况、识别问题,并使用重要 API 深入了解集群的运行状态。

集群健康状况与监控 是 CoddyKit 上的免费 Elasticsearch & Full Text Search Systems 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Elasticsearch & Full Text Search Systems 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Elasticsearch & Full Text Search Systems 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Why Monitor Your Cluster?

Just like a car needs regular checks, your Elasticsearch cluster needs monitoring. This ensures it's running smoothly and efficiently.

Monitoring helps you catch problems early, before they affect your users. It's crucial to:

  • Prevent data loss
  • Ensure high availability
  • Optimize performance
  • Troubleshoot issues quickly

Your First Health Check

Elasticsearch provides a powerful REST API to check its health. The _cluster/health API is your go-to for a quick overview. It tells you if your cluster is alive and well.

You'd typically make an HTTP GET request to this endpoint:

GET /_cluster/health

Green, Yellow, Red: What They Mean

The _cluster/health API returns a status that's typically one of three colors:

  • Green: All primary and replica shards are allocated. Your cluster is fully operational.
  • Yellow: All primary shards are allocated, but some replica shards are not. Data is available, but you might be at risk if a node fails.
  • Red: One or more primary shards are unallocated. This means some data is unavailable. Immediate action is needed!

Beyond Just the Color

The _cluster/health API provides more than just a color. It shows important metrics like:

  • number_of_nodes: Total nodes in the cluster.
  • number_of_data_nodes: Nodes holding data.
  • active_shards: Shards currently processing data.
  • unassigned_shards: Shards that haven't been allocated to a node. These are often the cause of Yellow or Red status.

Always look for unassigned_shards if your status isn't Green.

Checking Individual Nodes

Sometimes you need to check the status of individual nodes. The _cat/nodes API gives you a compact, human-readable list of all nodes, their IP addresses, roles, and resource usage.

The ?v parameter adds column headers for easier reading:

GET /_cat/nodes?v

Diving into Shards

The _cat/shards API is crucial for understanding shard allocation. It lists every shard in your cluster, its index, primary/replica status, state (e.g., STARTED, UNASSIGNED), and which node it's on.

This helps diagnose Yellow or Red statuses by showing exactly which shards are unassigned:

GET /_cat/shards?v

Why '_cat' APIs are Handy

The _cat APIs (short for 'concise and tabular') are designed for command-line use. They provide data in a plain text format, making it easy to quickly check various aspects of your cluster without parsing complex JSON.

  • Human-readable output
  • Fast for quick checks
  • Great for scripting
  • Many _cat APIs exist (e.g., _cat/indices, _cat/health)

Common Monitoring Scenarios

When monitoring, keep an eye on:

  • Red Cluster Status: Indicates data loss or inaccessibility.
  • Yellow Cluster Status: Replica shards unassigned, risk of data loss on node failure.
  • High CPU/Memory Usage: A node might be overloaded.
  • Disk Space: Nodes running out of disk space can cause issues.
  • Unassigned Shards: Always check _cat/shards to understand why.

These are early warning signs that require attention.

Proactive Monitoring

While manual checks are good, for a production system, you need proactive monitoring. Tools like Kibana's Alerting, Prometheus & Grafana, or dedicated monitoring services can automatically notify you of issues.

Proactive monitoring helps you:

  • Automate health checks
  • Get instant notifications
  • Visualize trends over time
  • Integrate with incident management

Check Your Understanding

You've learned about Elasticsearch cluster health statuses. Let's test your knowledge!

Recap: Your Monitoring Toolkit

We've covered essential tools for monitoring your Elasticsearch cluster:

  • The _cluster/health API gives a quick overview (Green, Yellow, Red statuses).
  • _cat/nodes helps you check individual node status and resources.
  • _cat/shards is key to understanding shard allocation and diagnosing unassigned shards.

Regular monitoring and understanding these statuses are crucial for a stable and reliable Elasticsearch deployment.

常见问题解答

「集群健康状况与监控」课时是免费的吗?

是的 — 「集群健康状况与监控」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Elasticsearch & Full Text Search Systems 课程的其余内容,请升级到 CoddyKit PRO。 Elasticsearch & Full Text Search Systems 课程共包含 4 节课。

「集群健康状况与监控」这节课中我会学到什么?

学习监控集群健康状况、识别问题,并使用重要 API 深入了解集群的运行状态。 你通过在浏览器中直接运行的动手代码来练习 Elasticsearch & Full Text Search Systems,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Elasticsearch & Full Text Search Systems 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Elasticsearch & Full Text Search Systems 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。

「集群健康状况与监控」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Elasticsearch & Full Text Search Systems 课中编写并运行代码吗?

能。每节 Elasticsearch & Full Text Search Systems 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 分片与副本详解
  2. 集群健康状况与监控
  3. 节点角色与架构
  4. 分片分配与再平衡
← 返回 Elasticsearch & Full Text Search Systems