overview.asciidoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ccr-overview]]
  4. == Overview
  5. Cross-cluster replication is done on an index-by-index basis. Replication is
  6. configured at the index level. For each configured replication there is a
  7. replication source index called the _leader index_ and a replication target
  8. index called the _follower index_.
  9. Replication is active-passive. This means that while the leader index
  10. can directly be written into, the follower index can not directly receive
  11. writes.
  12. Replication is pull-based. This means that replication is driven by the
  13. follower index. This simplifies state management on the leader index and means
  14. that {ccr} does not interfere with indexing on the leader index.
  15. [float]
  16. === Configuring replication
  17. Replication can be configured in two ways:
  18. * Manually using the
  19. {ref}/ccr-put-follow.html[create follower API]
  20. * Automatically using
  21. <<ccr-auto-follow,auto-follow patterns>>
  22. NOTE: You must also <<ccr-requirements,configure the leader index>>.
  23. [float]
  24. === The mechanics of replication
  25. While replication is managed at the index level, replication is performed at the
  26. shard level. When a follower index is created, it is automatically
  27. configured to have an identical number of shards as the leader index. A follower
  28. shard task in the follower index pulls from the corresponding leader shard in
  29. the leader index by sending read requests for new operations. These read
  30. requests can be served from any copy of the leader shard (primary or replicas).
  31. For each read request sent by the follower shard task, if there are new
  32. operations available on the leader shard, the leader shard responds with
  33. operations limited by the read parameters that you established when you
  34. configured the follower index. If there are no new operations available on the
  35. leader shard, the leader shard waits up to a configured timeout for new
  36. operations. If new operations occur within that timeout, the leader shard
  37. immediately responds with those new operations. Otherwise, if the timeout
  38. elapses, the follower shard replies that there are no new operations. The
  39. follower shard task updates some statistics and immediately sends another read
  40. request to the leader shard. This ensures that the network connections between
  41. the remote cluster and the local cluster are continually being used so as to
  42. avoid forceful termination by an external source (such as a firewall).
  43. If a read request fails, the cause of the failure is inspected. If the
  44. cause of the failure is deemed to be a failure that can be recovered from (for
  45. example, a network failure), the follower shard task enters into a retry
  46. loop. Otherwise, the follower shard task is paused and requires user
  47. intervention before the it can be resumed with the
  48. {ref}/ccr-post-resume-follow.html[resume follower API].
  49. When operations are received by the follower shard task, they are placed in a
  50. write buffer. The follower shard task manages this write buffer and submits
  51. bulk write requests from this write buffer to the follower shard. The write
  52. buffer and these write requests are managed by the write parameters that you
  53. established when you configured the follower index. The write buffer serves as
  54. back-pressure against read requests. If the write buffer exceeds its configured
  55. limits, no additional read requests are sent by the follower shard task. The
  56. follower shard task resumes sending read requests when the write buffer no
  57. longer exceeds its configured limits.
  58. Mapping updates applied to the leader index are automatically retrieved
  59. as-needed by the follower index.
  60. Settings updates applied to the leader index that are needed by the follower
  61. index are automatically retried as-needed by the follower index. Not all
  62. settings updates are needed by the follower index. For example, changing the
  63. number of replicas on the leader index is not replicated by the follower index.
  64. NOTE: If you apply a non-dynamic settings change to the leader index that is
  65. needed by the follower index, the follower index will go through a cycle of
  66. closing itself, applying the settings update, and then re-opening itself. The
  67. follower index will be unavailable for reads and not replicating writes
  68. during this cycle.
  69. [float]
  70. === Inspecting the progress of replication
  71. You can inspect the progress of replication at the shard level with the
  72. {ref}/ccr-get-follow-stats.html[get follower stats API]. This API gives you
  73. insight into the read and writes managed by the follower shard task. It also
  74. reports read exceptions that can be retried and fatal exceptions that require
  75. user intervention.
  76. [float]
  77. === Pausing and resuming replication
  78. You can pause replication with the
  79. {ref}/ccr-post-pause-follow.html[pause follower API] and then later resume
  80. replication with the {ref}/ccr-post-resume-follow.html[resume follower API].
  81. Using these APIs in tandem enables you to adjust the read and write parameters
  82. on the follower shard task if your initial configuration is not suitable for
  83. your use case.
  84. [float]
  85. === Terminating replication
  86. You can terminate replication with the
  87. {ref}/ccr-post-unfollow.html[unfollow API]. This API converts a follower index
  88. to a regular (non-follower) index.