overview.asciidoc 5.0 KB

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