Manage CDC Tasks
A Capture Data Change (CDC) task enables the synchronization of data from a source Milvus instance to a target Milvus instance. It monitors operation logs from the source and replicates data changes such as insertions, deletions, and index operations to the target in real-time. This facilitates real-time disaster recovery or active-active load balancing between Milvus deployments.
This guide covers how to manage CDC tasks, including creation, pausing, resuming, retrieving details, listing, and deletion through HTTP requests. 捕获数据变更 (CDC) 任务允许将数据从源 Milvus 实例同步到目标 Milvus 实例。它监控源的操作日志,并实时将插入、删除和索引操作等数据变更复制到目标。这有助于在 Milvus 部署之间进行实时灾难恢复或主-主负载均衡。
本指南介绍如何通过 HTTP 请求管理 CDC 任务,包括创建、暂停、恢复、检索详细信息、列出和删除。
Create a task
创建任务
Creating a CDC task allows data change operations in the source Milvus to be synced to the target Milvus. 创建 CDC 任务允许将源 Milvus 中的数据变更操作同步到目标 Milvus。
要创建 CDC 任务:
curl -X POST http:_//localhost:8444/cdc \
-H "Content-Type: application/json" \
-d '{
"request_type": "create",
"request_data": {
"milvus_connect_param": {
"uri": "http://localhost:19530",
"token":"root:Milvus",
"connect_timeout": 10
},
"collection_infos": [
{
"name": "*"
}
]
}
}'
Replace localhost with the IP address of the target Milvus server.
Parameters: 将 localhost 替换为目标 Milvus 服务器的 IP 地址。
参数:
-
milvus_connect_param: Connection parameters of the target Milvus.
-
milvus_connect_param: 目标 Milvus 的连接参数。
-
host: Hostname or IP address of the Milvus server.
-
host: Milvus 服务器的主机名或 IP 地址。
-
port: Port number the Milvus server listens on.
-
port: Milvus 服务器监听的端口号。
-
username: Username for authenticating with the Milvus server.
-
username: 用于 Milvus 服务器身份验证的用户名。
-
password: Password for authenticating with the Milvus server.
-
password: 用于 Milvus 服务器身份验证的密码。
-
enable_tls: Whether to use TLS/SSL encryption for the connection.
-
enable_tls: 是否为连接使用 TLS/SSL 加密。
-
connect_timeout: Timeout period in seconds for establishing the connection.
-
connect_timeout: 建立连接的超时时间(秒)。
-
-
collection_infos: Collections to synchronize. Currently, only an asterisk (*) is supported, as Milvus-CDC synchronizes at the cluster level, not individual collections.
-
collection_infos: 要同步的 collection。目前仅支持星号 (*),因为 Milvus-CDC 在集群级别同步,而非单个 collection。
Expected response: 预期响应:
{
"code": 200,
"data": {
"task_id":"xxxx"
}
}
List tasks
列出任务
To list all created CDC tasks: 要列出所有已创建的 CDC 任务:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type": "list"
}' http://localhost:8444/cdc
Replace localhost with the IP address of the target Milvus server.
Expected response:
{
"code": 200,
"data": {
"tasks": [
{
"task_id": "xxxxx",
"milvus_connect_param": {
"uri":"http://localhost:19530",
"connect_timeout": 10
},
"collection_infos": [
{
"name": "*"
}
],
"state": "Running"
}
]
}
}
Pause a task
暂停任务
To pause a CDC task: 要暂停 CDC 任务:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type":"pause",
"request_data": {
"task_id": "xxxx"
}
}' http://localhost:8444/cdc
Replace localhost with the IP address of the target Milvus server.
Parameters:
- task_id: ID of the CDC task to pause.
Expected response:
{
"code": 200,
"data": {}
}
Resume a task
恢复任务
To resume a paused CDC task: 要恢复暂停的 CDC 任务:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type":"resume",
"request_data": {
"task_id": "xxxx"
}
}' http://localhost:8444/cdc
Replace localhost with the IP address of the target Milvus server.
Parameters:
- task_id: ID of the CDC task to resume.
Expected response:
{
"code": 200,
"data": {}
}
Retrieve task details
检索任务详细信息
To retrieve the details of a specific CDC task: 要检索特定 CDC 任务的详细信息:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type":"get",
"request_data": {
"task_id": "xxxx"
}
}' http://localhost:8444/cdc
Replace localhost with the IP address of the target Milvus server.
Parameters:
- task_id: ID of the CDC task to query.
Expected response:
{
"code": 200,
"data": {
"Task": {
"collection_infos": [
{
"name": "*"
}
],
"milvus_connect_param": {
"connect_timeout": 10,
"uri":"http://localhost:19530"
},
"state": "Running",
"task_id": "xxxx"
}
}
}
Delete a task
删除任务
To delete a CDC task: 要删除 CDC 任务:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type":"delete",
"request_data": {
"task_id": "30d1e325df604ebb99e14c2a335a1421"
}
}' http://localhost:8444/cdc
Replace localhost with the IP address of the target Milvus server.
Parameters:
- task_id: ID of the CDC task to delete.
Expected response:
{
"code": 200,
"data": {}
}