Skip to main content

使用迁移API

使用场景

  • 如您的Nasu Copy部署环境无法通过浏览器访问,可以使用API的方式进行操作。
  • 您也可以脱离纳速云集群完全将其视作一个工具,自行指定集群间的复制。

Nasu Copy Rest-API

1. 测试数据源连接

用于快速测试源集群及目标集群的可连接性。

1.1 简单集群

POST /api/test
{
"endpoint":"http://localhost:9200"
}

返回

{
"connected": true,
"health": {
"cluster_name": "elasticsearch",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 14,
...
},
"version": "7.8.0"
}

1.2 Basic Auth 安全认证集群

POST /api/test
{
"endpoint":"https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyyy"
}

2. 拷贝

2.1 索引全量复制

POST /api/copy/index
{
"source": {
"endpoint": "http://localhost:9200"
},
"dest": {
"endpoint": "https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyy"
}
}

2.2 索引自定义复制-对等复制

POST /api/copy/index
{
"source": {
"endpoint": "http://localhost:9200"
},
"dest": {
"endpoint": "https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyy"
},
"filter": ["foo","bar","log*"]
}
  • filter: 指定需要复制的索引,支持通配符。

2.3 索引自定义复制-合并索引

POST /api/copy/index?shards=1&destIndex=merge_one_index
{
"source": {
"endpoint": "http://localhost:9200"
},
"dest": {
"endpoint": "https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyy"
},
"filter": ["foo","bar","log*"]
}
  • filter: 指定需要复制的索引,支持通配符。
  • destIndex: 合并的目标索引
  • shards: 合并目标索引的分片数

2.4 拷贝Pipeline

POST /api/copy/pipeline
{
"source": {
"endpoint": "http://localhost:9200"
},
"dest": {
"endpoint": "https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyy"
},
"filter": ["foo","bar","log*"]
}
  • filter: 指定需要复制的pipeline,支持通配符。

2.5 拷贝Template

POST /api/copy/template
{
"source": {
"endpoint": "http://localhost:9200"
},
"dest": {
"endpoint": "https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyy"
},
"filter": ["foo","bar","log*"]
}
  • filter: 指定需要复制的template,支持通配符。

3. 状态信息

3.1 查看对等索引

查看源集群和目标集群的索引列表

POST /api/indices
{
"source": {
"endpoint": "http://localhost:9200"
},
"dest": {
"endpoint": "https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyy"
}
}

3.2 查看对等pipeline

查看源集群和目标集群的Pipeline列表

POST /api/pipelines
{
"source": {
"endpoint": "http://localhost:9200"
},
"dest": {
"endpoint": "https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyy"
}
}

3.3 查看对等Template

查看源集群和目标集群的Template列表

POST /api/templates
{
"source": {
"endpoint": "http://localhost:9200"
},
"dest": {
"endpoint": "https://router.nasuyun.com:9200",
"username":"xxx",
"password":"yyy"
}
}

3.4 查看运行期任务状态

查看所有正在运行的后台任务

GET /api/state

3.5 查看根据状态过滤的运行任务

查看根据状态过滤的运行任务

GET /api/state/{status}

status 参数

  • wait: 等待中
  • running: 运行中
  • completed: 已完成
  • failed: 已失败

3.6 查看历史任务

查看已完成的任务列表

GET /api/state_history

3.7 查看配置

查看服务的核心配置

GET /api/config