创建关注者 API
有关最新的 API 详情,请参阅跨集群复制 API。
创建跨集群复制关注者索引。
请求
PUT /<follower_index>/_ccr/follow?wait_for_active_shards=1
{
"remote_cluster" : "<remote_cluster>",
"leader_index" : "<leader_index>"
}
前置条件
- 如果启用了 Elasticsearch 安全功能,你必须拥有关注者索引的
write、monitor和manage_follow_index索引权限。你必须拥有领导者索引的read和monitor索引权限。你还必须拥有包含关注者索引的集群的manage_ccr集群权限。有关更多信息,请参阅安全权限。
描述
此 API 创建一个新的关注者索引,配置为跟随引用的领导者索引。当此 API 返回时,关注者索引已存在,跨集群复制开始将操作从领导者索引复制到关注者索引。
路径参数
<follower_index>(必需,字符串)关注者索引的名称。
查询参数
wait_for_active_shards(可选,整数)指定在响应之前等待激活的分片数量。默认为不等待任何分片激活。分片必须从领导者索引恢复后才能激活。恢复关注者分片需要将所有远程 Lucene 段文件传输到关注者索引。
master_timeout(可选,时间单位)等待主节点的时间。如果主节点在超时到期前不可用,请求将失败并返回错误。默认为
30s。也可以设置为-1表示请求永不超时。
请求体
leader_index(必需,字符串)要跟随的领导者集群中的索引名称。
remote_cluster(必需,字符串)包含领导者索引的远程集群。
data_stream_name(可选,字符串)如果领导者索引是数据流的一部分,则本地数据流中关注索引应重命名为此名称。例如,以下请求:
PUT /.ds-logs-mysql-default_copy-2022-01-01-000001/_ccr/follow
{
"remote_cluster" : "remote_cluster",
"leader_index" : ".ds-logs-mysql-default-2022-01-01-000001",
"data_stream_name": "logs-mysql-default_copy"
}将领导者索引
.ds-logs-mysql-default-2022-01-01-000001复制到关注者索引.ds-logs-mysql-default_copy-2022-01-01-000001,并使用数据流logs-mysql-default_copy,而非原始领导者数据流名称logs-mysql-default。settings(对象)要覆盖领导者索引的设置。请注意,某些设置不能被覆盖(例如
index.number_of_shards)。max_read_request_operation_count(整数)每次从远程集群读取时拉取的最大操作数。
max_outstanding_read_requests(long)从远程集群未完成的读取请求的最大数量。
max_read_request_size(字节值)每次从远程集群拉取的一批操作的最大字节数。
max_write_request_operation_count(整数)在关注者上执行的每个批量写入请求的最大操作数。
max_write_request_size(字节值)在关注者上执行的每个批量写入请求的最大操作总字节数。
max_outstanding_write_requests(整数)关注者上未完成的写入请求的最大数量。
max_write_buffer_count(整数)可排队等待写入的最大操作数。当达到此限制时,从远程集群的读取将被推迟,直到排队操作数降至限制以下。
max_write_buffer_size(字节值)可排队等待写入的操作的最大总字节数。当达到此限制时,从远程集群的读取将被推迟,直到排队操作的总字节数降至限制以下。
max_retry_delay(时间值)重试异常失败的操作前等待的最长时间。重试时采用指数退避策略。
read_poll_timeout(时间值)当关注者索引与领导者索引同步时,等待远程集群上新操作的最长时间。当超时过后,操作轮询将返回到关注者,以便它可以更新一些统计信息。然后关注者将立即再次尝试从领导者读取。
默认值
以下来自关注信息 API 的输出描述了上述索引关注请求参数的所有默认值:
{
"follower_indices" : [
{
"parameters" : {
"max_read_request_operation_count" : 5120,
"max_read_request_size" : "32mb",
"max_outstanding_read_requests" : 12,
"max_write_request_operation_count" : 5120,
"max_write_request_size" : "9223372036854775807b",
"max_outstanding_write_requests" : 9,
"max_write_buffer_count" : 2147483647,
"max_write_buffer_size" : "512mb",
"max_retry_delay" : "500ms",
"read_poll_timeout" : "1m"
}
}
]
}
示例
此示例创建一个名为 follower_index 的关注者索引:
PUT /follower_index/_ccr/follow?wait_for_active_shards=1
{
"remote_cluster" : "remote_cluster",
"leader_index" : "leader_index",
"settings": {
"index.number_of_replicas": 0
},
"max_read_request_operation_count" : 1024,
"max_outstanding_read_requests" : 16,
"max_read_request_size" : "1024k",
"max_write_request_operation_count" : 32768,
"max_write_request_size" : "16k",
"max_outstanding_write_requests" : 8,
"max_write_buffer_count" : 512,
"max_write_buffer_size" : "512k",
"max_retry_delay" : "10s",
"read_poll_timeout" : "30s"
}
API 返回以下结果:
{
"follow_index_created" : true,
"follow_index_shards_acked" : true,
"index_following_started" : true
}