從 Faiss
本指南提供了從 Faiss 遷移數據到 Milvus 2.x 的全面、逐步的過程。按照本指南,您將能夠有效地傳輸您的數據,利用 Milvus 2.x 先進的功能和改進的性能。
先決條件
- 軟體版本:
- 所需的工具:
- Milvus-migration工具。安裝詳情請參閱安裝遷移工具。
設定遷移
將遷移配置範例檔保存為migration.yaml
,並根據實際情況修改配置。你可以自由地把配置文件放在本地的任何目錄下。
dumper: # configs for the migration job.
worker:
limit: 2
workMode: faiss # operational mode of the migration job.
reader:
bufferSize: 1024
writer:
bufferSize: 1024
loader:
worker:
limit: 2
source: # configs for the source Faiss index.
mode: local
local:
faissFile: ./testfiles/faiss/faiss_ivf_flat.index
target: # configs for the target Milvus collection.
create:
collection:
name: test1w
shardsNums: 2
dim: 256
metricType: L2
mode: remote
remote:
outputDir: testfiles/output/
cloud: aws
endpoint: 0.0.0.0:9000
region: ap-southeast-1
bucket: a-bucket
ak: minioadmin
sk: minioadmin
useIAM: false
useSSL: false
checkBucket: true
milvus2x:
endpoint: localhost:19530
username: xxxxx
password: xxxxx
下表描述了示例配置文件中的参数。如需完整的配置清單,請參考Milvus Migration:Faiss 到 Milvus 2.x.
dumper
參數 說明 dumper.worker.limit
轉移線程數。 dumper.worker.workMode
遷移工作的運作模式。從 Faiss 索引遷移時設定為 faiss。 dumper.worker.reader.bufferSize
每批從 Faiss 讀取的緩衝區大小。單位:KB:單位:KB。 dumper.worker.writer.bufferSize
每批寫入 Milvus 的緩衝區大小。單位:KB:單位:KB。 loader
參數 說明 loader.worker.limit
載入器線程數。 source
參數 說明 source.mode
指定讀取來源檔案的位置。有效值:
-local
: 從本機磁碟讀取檔案。
-remote
: 從遠端儲存讀取檔案。source.local.faissFile
來源檔案所在的目錄路徑。例如, /db/faiss.index
。target
參數 說明 target.create.collection.name
Milvus 集合的名稱。 target.create.collection.shardsNums
要在集合中建立的分片數量。有關分片的詳細資訊,請參閱「術語」。 target.create.collection.dim
向量領域的尺寸。 target.create.collection.metricType
用來衡量向量之間相似性的度量類型。如需詳細資訊,請參閱「術語」。 target.mode
轉儲檔案的儲存位置。有效值:
-local
: 在本機磁碟上儲存轉儲檔案。
-remote
: 在物件儲存上儲存轉儲檔案。target.remote.outputDir
雲端儲存桶中的輸出目錄路徑。 target.remote.cloud
雲端儲存服務提供商。範例值: aws
,gcp
,azure
。target.remote.endpoint
Milvus 2.x 儲存的端點。 target.remote.region
雲端儲存區域。如果您使用本機 MinIO,它可以是任何值。 target.remote.bucket
儲存資料的 Bucket 名稱。該值必須與 Milvus 2.x 中的 config 相同。如需詳細資訊,請參閱系統組態。 target.remote.ak
Milvus 2.x 儲存的存取金鑰。 target.remote.sk
Milvus 2.x 儲存的保密金鑰。 target.remote.useIAM
是否使用 IAM 角色進行連接。 target.remote.useSSL
連線至 Milvus 2.x 時是否啟用 SSL。如需詳細資訊,請參閱傳輸中加密。 target.remote.checkBucket
是否檢查指定的儲存桶是否存在於物件儲存空間。 target.milvus2x.endpoint
目標 Milvus 伺服器的位址。 target.milvus2x.username
Milvus 2.x 伺服器的使用者名稱。如果您的 Milvus 伺服器啟用使用者驗證,則必須使用此參數。如需詳細資訊,請參閱啟用驗證。 target.milvus2x.password
Milvus 2.x 伺服器的密碼。如果您的 Milvus 伺服器啟用使用者驗證,則必須使用此參數。如需更多資訊,請參閱啟用驗證。
啟動遷移工作
使用以下命令啟動遷移工作。將
{YourConfigFilePath}
改為配置檔案migration.yaml
所在的本機目錄。./milvus-migration dump --config=/{YourConfigFilePath}/migration.yaml
上述命令會將 Faiss 索引資料轉換成 NumPy 檔案,然後使用bulkInsert作業將資料寫入目標資料桶。
生成 NumPy 檔案後,使用下列指令將這些檔案匯入 Milvus 2.x。將
{YourConfigFilePath}
改為配置檔案migration.yaml
所在的本機目錄。./milvus-migration load --config=/{YourConfigFilePath}/migration.yaml
驗證結果
一旦執行轉移任務,您可以呼叫 API 或使用 Attu 檢視轉移的實體數量。如需詳細資訊,請參閱Attu和get_collection_stats()。