管理 CDC 任務
捕捉資料變更 (CDC) 任務可將資料從來源 Milvus 實例同步到目標 Milvus 實例。它監控來自來源的操作日誌,並即時複製資料變更,例如插入、刪除和索引操作到目標。這有助於實時災難復原或 Milvus 部署之間的主動負載平衡。
本指南涵蓋如何管理 CDC 任務,包括透過 HTTP 請求建立、暫停、恢復、擷取詳細資料、列出和刪除。
建立任務
建立 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": "*"
}
]
}
}'
用目標 Milvus 伺服器的 IP 位址取代localhost。
參數:
milvus_connect_param: 目標 Milvus 的連線參數。
host: Milvus 伺服器的主機名稱或 IP 位址。
port:Milvus 伺服器所監聽的連接埠號。
username: 用於驗證 Milvus 伺服器的使用者名稱。
password: 用於驗證 Milvus 伺服器的密碼。
enable_tls:是否使用 TLS/SSL 加密連線。
connect_timeout:建立連線的逾時時間,以秒為單位。
collection_infos:要同步的集合。目前只支援星號(*),因為 Milvus-CDC 同步處理的是群集層級,而非個別的集合。
預期回應:
{
"code": 200,
"data": {
"task_id":"xxxx"
}
}
列出任務
列出所有已建立的 CDC 任務:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type": "list"
}' http://localhost:8444/cdc
將localhost改為目標 Milvus 伺服器的 IP 位址。
預期回應:
{
"code": 200,
"data": {
"tasks": [
{
"task_id": "xxxxx",
"milvus_connect_param": {
"uri":"http://localhost:19530",
"connect_timeout": 10
},
"collection_infos": [
{
"name": "*"
}
],
"state": "Running"
}
]
}
}
暫停任務
要暫停 CDC 任務:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type":"pause",
"request_data": {
"task_id": "xxxx"
}
}' http://localhost:8444/cdc
用目標 Milvus 伺服器的 IP 位址取代localhost。
參數:
- task_id:要暫停的 CDC 任務的 ID。
預期回應:
{
"code": 200,
"data": {}
}
恢復任務
若要恢復暫停的 CDC 任務,請
curl -X POST -H "Content-Type: application/json" -d '{
"request_type":"resume",
"request_data": {
"task_id": "xxxx"
}
}' http://localhost:8444/cdc
將localhost改為目標 Milvus 伺服器的 IP 位址。
參數:
- task_id:要恢復的 CDC 任務的 ID。
預期回應:
{
"code": 200,
"data": {}
}
擷取任務詳細資訊
擷取特定 CDC 任務的詳細資訊:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type":"get",
"request_data": {
"task_id": "xxxx"
}
}' http://localhost:8444/cdc
將localhost改為目標 Milvus 伺服器的 IP 位址。
參數:
- task_id:要查詢的 CDC 任務的 ID。
預期回應:
{
"code": 200,
"data": {
"Task": {
"collection_infos": [
{
"name": "*"
}
],
"milvus_connect_param": {
"connect_timeout": 10,
"uri":"http://localhost:19530"
},
"state": "Running",
"task_id": "xxxx"
}
}
}
刪除任務
刪除 CDC 任務:
curl -X POST -H "Content-Type: application/json" -d '{
"request_type":"delete",
"request_data": {
"task_id": "30d1e325df604ebb99e14c2a335a1421"
}
}' http://localhost:8444/cdc
將localhost改為目標 Milvus 伺服器的 IP 位址。
參數:
- task_id:要刪除的 CDC 任務的 ID。
預期回應:
{
"code": 200,
"data": {}
}