Elasticsearch: Cross-cluster replication Cross-cluster replication (CCR)

Cross-cluster replication (CCR) function supports copying remote cluster to the local cluster index. You can use this feature in the production of some of the common use cases:

  • Disaster recovery (DR) / High Availability (HA): primary cluster if a fault occurs, the disaster recovery. Secondary cluster can be used as a hot spare
  • Location: Elasticsearch to copy data closer to the user or application server, thus reducing latency. Reading services can be provided locally
  • Central Report: copy data from a large number of smaller clusters to report back to a central cluster

Note : CCR is a 6.7 from a platinum function.


CCR is based indexing

Replication is configured for each index. For copy each configuration, there

  • Copy source index called the leader index
  • Copy target index called follower Index

A cluster can contain leader and follower index index at the same time:

 

Replication is active - passive relationship

You can use the leader index to read or write, the index exists in the remote cluster, but you can only read the index for the follower. follower index exist in the local cluster.

Replication is based on pull

Followers of each slice corresponding slice from its leader index pulled changed. The same number of fragments its leader index of the index follower

  • All operations by the copy follower
  • Copy almost in real time

           - Operation is pulled follower fragmented and bulk index

           - multiple requests at the same time, changes can be made at the same time

 

CCR prerequisite

Before CCR, we look at some of the conditions that must be met:

  • Cross-cluster replication requires remote cluster .
  • Elasticsearch version of the local cluster and a remote cluster must be the same or newer than the remote cluster. If a newer version of these must also be compatible version outlined in the following matrix.

  • Like the above talking about it, because CCR is a platinum function, you have to buy the copyright, or you can try a free test

If the elastic security is enabled, then you need to have the appropriate user rights. When we use the elastic username, require special attention, because it has the superuser role, you may inadvertently make a major change.

  • Cluster user on the remote cluster, you will need to have read_ccr privileges, and follower index must have permission to read and monitor and
  • On the local cluster, users will need the same cluster manage_ccr permission. follower index must have permission to monitor, read, write and manage_follow_index of

Hands

In this experiment, we first of all according to my previous article " elasticsearch: Cross-Cluster Cluster Search Search Cross (CCS )" to install our two clusters. However, there are two small differences:

  1. We open the security for each cluster. We can follow my previous article " : elasticsearch Elastic account security settings to set the security of our two clusters." For convenience, we will use the elastic user to operate, although we need special care
  2. Since this function is a function of platinum, in the absence of purchase, we can try to test this feature. To this end, we have the following installed to open this function:

In the above, we choose " Start Trial " button, and accept the conditions. Next, we can begin our testing.

cluster_1

We create an index called the twitter following on cluster_1:

POST _bulk
{"index":{"_index":"twitter","_id":1}}
{"user":"张三","message":"今儿天气不错啊,出去转转去","uid":2,"age":20,"city":"北京","province":"北京","country":"中国","address":"中国北京市海淀区","location":{"lat":"39.970718","lon":"116.325747"}, "DOB": "1999-04-01"}
{"index":{"_index":"twitter","_id":2}}
{"user":"老刘","message":"出发,下一站云南!","uid":3,"age":22,"city":"北京","province":"北京","country":"中国","address":"中国北京市东城区台基厂三条3号","location":{"lat":"39.904313","lon":"116.412754"}, "DOB": "1997-04-01"}
{"index":{"_index":"twitter","_id":3}}
{"user":"李四","message":"happy birthday!","uid":4,"age":25,"city":"北京","province":"北京","country":"中国","address":"中国北京市东城区","location":{"lat":"39.893801","lon":"116.408986"}, "DOB": "1994-04-01"}
{"index":{"_index":"twitter","_id":4}}
{"user":"老贾","message":"123,gogogo","uid":5,"age":30,"city":"北京","province":"北京","country":"中国","address":"中国北京市朝阳区建国门","location":{"lat":"39.718256","lon":"116.367910"}, "DOB": "1989-04-01"}
{"index":{"_index":"twitter","_id":5}}
{"user":"老王","message":"Happy BirthDay My Friend!","uid":6,"age":26,"city":"北京","province":"北京","country":"中国","address":"中国北京市朝阳区国贸","location":{"lat":"39.918256","lon":"116.467910"}, "DOB": "1993-04-01"}
{"index":{"_index":"twitter","_id":6}}
{"user":"老吴","message":"好友来了都今天我生日,好友来了,什么 birthday happy 就成!","uid":7,"age":28,"city":"上海","province":"上海","country":"中国","address":"中国上海市闵行区","location":{"lat":"31.175927","lon":"121.383328"}, "DOB": "1991-04-01"}

cluster_2

We conducted the following operations on cluster_2:

We click on " the Add A Remote Cluster ":

We fill in the relevant information of the corresponding name and seed, and click on " the Save ":

When we finished click on " the Save after", will appear on the screen, indicating a successful connection has been our remote_twitter. In the above we click on the " use Close ." We then click on " Cross-Cluster Replication ":

We click on the " the Create A follower index ":

We fill in the appropriate information. Notice above how we define a named twitter_copy the follower index. When we fill in the information after the above, we click " the Create " button:

We can see the status twitter_copy just created after a very short period of time from the paused become active, that our index is created successfully.

We click on the Dev Tools, and enter the following command:

We can see twitter_copy this newly created index. We can search for this index:

We can see that we have 7 results. We can in our cluster_1 add a new document:

We twitter index added a new document in cluster_1 in. id This document is 8. Next, we'll come in cluster_2 in check:

We can see that we recently added an id document 8 has been successful in visible cluster_2. This shows that our automatic replication already at work.

reference:

【1】https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-ccr.html

Published 512 original articles · won praise 124 · views 900 000 +

Guess you like

Origin blog.csdn.net/UbuntuTouch/article/details/104598588