Databases 3 min read

Elasticsearch Index Basics, Custom Shard and Replica Settings, and Monitoring Commands

This article explains fundamental Elasticsearch concepts such as indexes, index types, and the immutable nature of shard counts, demonstrates how to define custom shard and replica settings when creating or updating indices, and outlines essential monitoring considerations and commands for cluster health.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Elasticsearch Index Basics, Custom Shard and Replica Settings, and Monitoring Commands

1. Basic Concepts

1. Index: An index in Elasticsearch is a logical storage, analogous to a database in relational DBMS. An index can reside on a single server or be sharded across multiple servers; each index consists of one or more primary shards, each of which can have multiple replicas.

2. Index Type (index_type): In Elasticsearch, a single index can store multiple types of documents; index types differentiate objects within the same index, similar to tables in a relational database. Each type can have its own mapping, but different types cannot assign different data types to the same field.

2. Custom Shard and Replica Settings

1. Precautions

Once an index is created, the number of primary shards cannot be changed, but the number of replicas can be modified at any time.

2. Define shards and replicas when creating an index

PUT /yayayaay/
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 0
  }
}

3. Modify replica count for a single index

PUT /oldzhang/_settings/
{
  "settings": {
    "number_of_replicas": 0
  }
}

4. Modify replica count for all indices

PUT /_all/_settings/
{
  "settings": {
    "number_of_replicas": 0
  }
}

5. Recommended settings based on node count

2 nodes: default settings
3 nodes: critical data – 2 replicas; non‑critical – default
Log collection: 1 replica, 3 shards

3. Elasticsearch Monitoring

1. Monitoring considerations

0. Do not monitor only cluster health
1. Monitor node count
2. Monitor cluster health
3. Alert when either changes

2. Monitoring commands

GET _cat/nodes
GET _cat/health
monitoringElasticsearchIndexReplicasShards
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.