Operations 9 min read

Easysearch CCR Practical Guide Part 1: Replicating Between Two Local Clusters

This article walks through Easysearch’s built‑in CCR feature, explaining why cross‑cluster replication is needed, how to set up two single‑node clusters locally, configure security, create a leader index, start replication, monitor status, and avoid common pitfalls.

Mingyi World Elasticsearch
Mingyi World Elasticsearch
Mingyi World Elasticsearch
Easysearch CCR Practical Guide Part 1: Replicating Between Two Local Clusters

1. What Is Cross‑Cluster Replication (CCR)?

CCR automatically copies an index from a leader cluster to one or more follower clusters, which are read‑only. Typical scenarios include disaster recovery, read/write separation, data migration, and multi‑active architectures.

2. Prepare Two Local Test Clusters

Run two single‑node clusters on VMware:

Leader cluster: 192.168.101.39 Follower cluster: 192.168.101.40 Configure easysearch.yml with discovery.type: single-node and distinct HTTP ports (9200 for leader, 9201 for follower). Note that single-node mode disallows initial_master_nodes.

If security is enabled, merge the ca.crt files from both nodes into a single trust-chain.pem and set security.ssl.transport.ca_file: trust-chain.pem on both clusters.

3. Core Steps to Replicate an Index

3.1 Configure Remote Connection on the Follower (Pull Mode)

PUT /_cluster/settings?pretty
{
  "persistent": {
    "cluster": {
      "remote": {
        "ccr_cluster": {
          "seeds": ["192.168.101.39:9300"]
        }
      }
    }
  }
}

Verify the connection with GET _remote/info. If connect: false, check firewall rules or mismatched trust-chain.pem.

3.2 Create a Leader Index and Load Sample Data

# Create index with mapping
PUT /products
{
  "settings": {"number_of_shards":1,"number_of_replicas":0},
  "mappings": {
    "properties": {
      "id": {"type":"keyword"},
      "name": {"type":"text"},
      "description": {"type":"text"},
      "category": {"type":"keyword"},
      "brand": {"type":"keyword"},
      "price": {"type":"float"},
      "stock": {"type":"integer"},
      "on_sale": {"type":"boolean"},
      "tags": {"type":"keyword"},
      "create_time": {"type":"date"},
      "rating": {"type":"float"}
    }
  }
}

# Bulk import sample documents
POST /products/_bulk
{ "index": { "_id": "1001" } }
{ "id":"1001","name":"Apple iPhone 16 Pro","description":"苹果最新旗舰手机,A18 Pro芯片,超视网膜XDR显示屏","category":"手机","brand":"Apple","price":9999.00,"stock":68,"on_sale":true,"tags":["旗舰","5G","iOS"],"create_time":"2025-11-01T10:00:00","rating":4.9 }
... (additional documents omitted for brevity)

3.3 Start Replication on the Follower

PUT /_replication/my-follow-index/_start?pretty
{
  "leader_alias": "ccr_cluster",
  "leader_index": "products",
  "use_roles": {
    "leader_cluster_role": "superuser",
    "follower_cluster_role": "superuser"
  }
}

Success is indicated by the creation of my-follow-index and synchronization of all data.

3.4 Check Replication Status

GET /_replication/my-follow-index/_status?pretty

A normal response shows status": "SYNCING" with matching leader_checkpoint and follower_checkpoint, meaning the index is fully synced.

3.5 Pause, Resume, or Stop Replication

# Pause
POST /_replication/my-follow-index/_pause
{}
# Resume
POST /_replication/my-follow-index/_resume
{}
# Stop (makes the follower index writable)
POST /_replication/my-follow-index/_stop
{}

4. View Global Replication Status (Production‑Ready)

On the follower cluster:

GET /_replication/all_status   # Lists all follower indices, including PAUSED/FAILED
GET /_replication/follower_stats # Detailed statistics

On the leader cluster:

GET /_replication/leader_stats   # Shows how many followers pull data and total data transferred

5. Common Pitfalls

Follower indices are read‑only; you must stop replication ( _stop) before writing.

Both clusters must run the same Easysearch version; even minor version mismatches can cause errors.

Using proxy mode instead of the default sniff mode may trigger timeout errors like “Timed out when waiting for persistent task after 30s”.

6. Final Thoughts

Easysearch’s CCR module (available since version 1.15.2 and validated on 2.0.0) is mature and suitable for large‑scale Elasticsearch/Easysearch architectures. After verifying the full workflow locally, you can safely apply the same steps in production with minimal risk.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ElasticsearchtroubleshootingCluster SetupCCREasysearchCross-Cluster ReplicationReplication Commands
Mingyi World Elasticsearch
Written by

Mingyi World Elasticsearch

The leading WeChat public account for Elasticsearch fundamentals, advanced topics, and hands‑on practice. Join us to dive deep into the ELK Stack (Elasticsearch, Logstash, Kibana, Beats).

0 followers
Reader feedback

How this landed with the community

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.