{"id":19326,"date":"2024-10-29T16:23:27","date_gmt":"2024-10-29T10:53:27","guid":{"rendered":"https:\/\/opstree.com\/blog\/?p=19326"},"modified":"2024-10-29T20:11:52","modified_gmt":"2024-10-29T14:41:52","slug":"setup-cross-cluster-replication-for-data-migration-in-elasticsearch","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2024\/10\/29\/setup-cross-cluster-replication-for-data-migration-in-elasticsearch\/","title":{"rendered":"Setup Cross Cluster Replication for Data migration in Elasticsearch"},"content":{"rendered":"<h1 style=\"text-align: left\">\u00a0<\/h1>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-19333 aligncenter\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/20190131-elasticsearch-driver-difference-1-300x200.png\" alt=\"Elasticsearch\" width=\"467\" height=\"311\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/20190131-elasticsearch-driver-difference-1-300x200.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/20190131-elasticsearch-driver-difference-1-1024x683.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/20190131-elasticsearch-driver-difference-1-768x512.png 768w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/20190131-elasticsearch-driver-difference-1-1536x1024.png 1536w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/20190131-elasticsearch-driver-difference-1-2048x1365.png 2048w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/20190131-elasticsearch-driver-difference-1-1200x800.png 1200w\" sizes=\"(max-width: 467px) 85vw, 467px\" \/> Cross Cluster Replication (CCR) is a powerful feature in Elasticsearch that facilitates seamless data migration and disaster recovery by allowing real-time replication of data from a remote source cluster to a target cluster. In this guide, we&#8217;ll cover setting up CCR to migrate data from a <em>Remote Cluster<\/em> in Singapore to a <em>Local Cluster<\/em> in Mumbai. <!--more-->This step-by-step process involves configuring both clusters, creating follower indices, and monitoring the replication status. By the end, you\u2019ll have a reliable setup for cross-regional data replication, enhancing both data redundancy and accessibility across geographical locations.<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-19345\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.26.14\u202fPM-300x124.png\" alt=\"CCR\" width=\"752\" height=\"311\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.26.14\u202fPM-300x124.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.26.14\u202fPM-1024x423.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.26.14\u202fPM-768x317.png 768w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.26.14\u202fPM-1536x634.png 1536w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.26.14\u202fPM-1200x495.png 1200w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.26.14\u202fPM.png 1618w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\r\n<h2>Pre-requisites<\/h2>\r\n<ol>\r\n<li style=\"list-style-type: none\">\r\n<ol>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Should have \u201c<\/span><b>manage<\/b><span style=\"font-weight: 400\">\u201d cluster privilege on the local cluster\u00a0<\/span><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">A license on both the cluster that includes cross-cluster replication.\u00a0<\/span><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">In local cluster, all <\/span><b><i>master<\/i><\/b><span style=\"font-weight: 400\"> nodes should also have a <\/span><b><i>remote-cluster-client <\/i><\/b><span style=\"font-weight: 400\">role. It must also have one <\/span><b><i>data<\/i><\/b><span style=\"font-weight: 400\"> role and <\/span><b><i>remote-cluster-client <\/i><\/b><span style=\"font-weight: 400\">role.<\/span><\/li>\r\n<\/ol>\r\n<\/li>\r\n<\/ol>\r\n<h2>Steps:<\/h2>\r\n<ol>\r\n<li style=\"list-style-type: none\">\r\n<ol>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Establish trust between your clusters. This can be done in two ways: API key or TLS certificate authentication.<\/span><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">To setup API key authentication you may want to <\/span><span style=\"font-weight: 400\">Enable the remote cluster server on every node of the remote cluster. In <strong>elasticsearch.yml s<\/strong><\/span>pecify the domain of your remote cluster (singapore)<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-19335\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.27.17\u202fPM-300x28.png\" alt=\"Cross Cluster Replication\" width=\"567\" height=\"53\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.27.17\u202fPM-300x28.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.27.17\u202fPM-1024x95.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.27.17\u202fPM-768x71.png 768w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.27.17\u202fPM-1200x111.png 1200w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.27.17\u202fPM.png 1232w\" sizes=\"(max-width: 567px) 85vw, 567px\" \/><\/li>\r\n<li style=\"font-weight: 400\">Generate a certificate authority (CA) and a wildcard server certificate\/key pair that would work on all nodes of your cluster. Mention the <b>.p12 <\/b>certification in your elasticsearch.yml.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-19337\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.29.46\u202fPM-300x32.png\" alt=\"Cross Cluster Replication\" width=\"571\" height=\"61\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.29.46\u202fPM-300x32.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.29.46\u202fPM-1024x111.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.29.46\u202fPM-768x83.png 768w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.29.46\u202fPM-1200x130.png 1200w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.29.46\u202fPM.png 1238w\" sizes=\"(max-width: 571px) 85vw, 571px\" \/><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Make sure to add the SSL keystore password to the Elasticsearch keystore to keep your password secure.\u00a0<\/span><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Restart the cluster.\u00a0<\/span><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">For additional instructions, please refer to this document: <\/span><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/remote-clusters-api-key.html#remote-clusters-security-api-key-remote-action\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400\">API key authentication<\/span><\/a><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">You can check your cluster connection from <\/span><b>Stack Management &gt; Data &gt; Remote Clusters<\/b><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-19340\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.32.39\u202fPM-300x68.png\" alt=\"Cross Cluster Replication\" width=\"607\" height=\"138\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.32.39\u202fPM-300x68.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.32.39\u202fPM-1024x234.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.32.39\u202fPM-768x175.png 768w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.32.39\u202fPM-1200x274.png 1200w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.32.39\u202fPM.png 1262w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/li>\r\n<li style=\"font-weight: 400\">Configure privileges by creating separate roles on the local and remote clusters, and then create a user with the required roles.<\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Finally create a follower index in your local cluster to replicate data from a selected index in the remote cluster.<\/span><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-19341\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.37.11\u202fPM-300x131.png\" alt=\"Cross Cluster Replication\" width=\"611\" height=\"267\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.37.11\u202fPM-300x131.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.37.11\u202fPM-1024x446.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.37.11\u202fPM-768x335.png 768w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.37.11\u202fPM-1200x523.png 1200w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.37.11\u202fPM.png 1258w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/li>\r\n<li style=\"font-weight: 400\">Elasticsearch initializes the follower by transferring Lucene segment files from the leader index to follower, setting the index status to Paused, then switches to Active once replication is done.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-19342 \" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.38.09\u202fPM-300x144.png\" alt=\"Cross Cluster Replication\" width=\"515\" height=\"247\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.38.09\u202fPM-300x144.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.38.09\u202fPM-1024x492.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.38.09\u202fPM-768x369.png 768w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.38.09\u202fPM-1200x577.png 1200w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-25-at-2.38.09\u202fPM.png 1286w\" sizes=\"(max-width: 515px) 85vw, 515px\" \/><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Even if you add more data to the leader index, the follower will continue to replicate these updates as well.<\/span><\/li>\r\n<\/ol>\r\n<\/li>\r\n<\/ol>\r\n<h2>Additional Considerations for CCR<\/h2>\r\n<ul>\r\n<li style=\"list-style-type: none\">\r\n<ul>\r\n<li><b>Operational Continuity<\/b><span style=\"font-weight: 400\">:It is not required to bring down connections or stop reads and writes in the Singapore cluster to set up Cross-Cluster Replication (CCR). You can perform CCR while the Singapore cluster continues to handle multiple reads and writes.<\/span><\/li>\r\n<li><b>Replication Time:<\/b><span style=\"font-weight: 400\"> Replicating 1 GB of data typically takes around 1 minute from remote to local cluster.<\/span><\/li>\r\n<li><b>Ongoing Replication: <\/b><span style=\"font-weight: 400\">CCR continuously replicates data from the remote to the local cluster. As long as both clusters are operational, there should be no downtime. However, if there&#8217;s a network disruption or if either cluster experiences an outage, replication might temporarily pause until connectivity is restored.<\/span><\/li>\r\n<li><b>Downtime during failover:<\/b><span style=\"font-weight: 400\"> If you have pre-configured your Mumbai cluster to handle writes as soon as a failover is triggered, then the downtime can be minimized or even eliminated entirely.\u00a0<\/span><\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<h2>Versions and Instance Details:<\/h2>\r\n<ol>\r\n<li style=\"list-style-type: none\">\r\n<ol>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Elasticsearch version 8.15.0<\/span><span style=\"font-weight: 400\">8<\/span><\/li>\r\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ubuntu 22.04 (4 CPU cores, 8GB RAM, 160gb storage for each node)\u00a0<\/span><\/li>\r\n<\/ol>\r\n<\/li>\r\n<\/ol>\r\n<h2>Conclusion<\/h2>\r\n<p>By setting up CCR from the Singapore cluster to the Mumbai cluster, we ensure that data remains consistent and accessible, regardless of geographical constraints. This approach not only enhances disaster recovery capabilities but also reduces latency for region-specific data access. With Elasticsearch\u2019s flexible configuration options and secure authentication methods, CCR is an ideal choice for businesses looking to scale and maintain high data resilience. <b>Reference Links:<\/b><\/p>\r\n<ul>\r\n<li><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/ccr-getting-started-tutorial.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400\">CCR setup guide\u00a0<\/span><\/a><\/li>\r\n<li><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/ccr-managing.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400\">Managing Cross Cluster replication<\/span><\/a><\/li>\r\n<li><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/remote-clusters-api-key.html#remote-clusters-security-api-key-remote-action\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400\">API key authentication<\/span><\/a><\/li>\r\n<li><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/remote-clusters-cert.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400\">TLS certificate authentication<\/span><\/a><\/li>\r\n<\/ul>\r\n<p><strong>Blog Pundit<\/strong>: <a href=\"https:\/\/opstree.com\/blog\/author\/sandeep7c51ad81ba\/\" target=\"_blank\" rel=\"noopener\">Sandeep Rawat<\/a><\/p>\r\n<div class=\"ch bg ew ex ey ez\"><a href=\"https:\/\/www.opstree.com\/contact-us?utm_source=wordpress&amp;utm_campaign=AWS-Gateway-LoadBalancer-A-Load-Balancer-that-we-deserve&amp;utm_id=Blog\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Opstree<\/strong> <\/a>is an End to End DevOps solution provider<\/div>\r\n<div>\u00a0<\/div>\r\n<div class=\"ch bg ew ex ey ez\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/www.opstree.com\/contact-us\" target=\"_blank\" rel=\"noreferrer noopener\">CONTACT US<\/a><\/div>\r\n<div class=\"ch bg ew ex ey ez\"><!-- \/wp:paragraph -->\r\n\r\n<!-- wp:buttons -->\r\n<div class=\"wp-block-buttons\"><!-- wp:button {\"className\":\"is-style-fill\"} --><!-- \/wp:button --><\/div>\r\n<!-- \/wp:buttons -->\r\n\r\n<!-- wp:paragraph {\"align\":\"center\"} -->\u00a0\r\n<p class=\"has-text-align-center\"><strong>Connect With Us<\/strong><\/p>\r\n<\/div>\r\n<p>Connect With Us<\/p>","protected":false},"excerpt":{"rendered":"<p>\u00a0 Cross Cluster Replication (CCR) is a powerful feature in Elasticsearch that facilitates seamless data migration and disaster recovery by allowing real-time replication of data from a remote source cluster to a target cluster. In this guide, we&#8217;ll cover setting up CCR to migrate data from a Remote Cluster in Singapore to a Local Cluster &hellip; <a href=\"https:\/\/opstree.com\/blog\/2024\/10\/29\/setup-cross-cluster-replication-for-data-migration-in-elasticsearch\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setup Cross Cluster Replication for Data migration in Elasticsearch&#8221;<\/span><\/a><\/p>\n","protected":false},"author":244582683,"featured_media":19368,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[28070474],"tags":[768739308,768739310,52970],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2024\/10\/Cross-Cluster-Replication-for-Data-migration-in-Elasticsearch.png","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-51I","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/19326"}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/244582683"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=19326"}],"version-history":[{"count":14,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/19326\/revisions"}],"predecessor-version":[{"id":19369,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/19326\/revisions\/19369"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/19368"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=19326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=19326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=19326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}