🚀 免費嘗試 Zilliz Cloud,完全托管的 Milvus,體驗速度提升 10 倍!立即嘗試

milvus-logo
LFAI
主頁

從 Faiss

本指南提供了從 Faiss 遷移數據到 Milvus 2.x 的全面、逐步的過程。按照本指南,您將能夠有效地傳輸您的數據,利用 Milvus 2.x 先進的功能和改進的性能。

先決條件

設定遷移

將遷移配置範例檔保存為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.nameMilvus 集合的名稱。
    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.endpointMilvus 2.x 儲存的端點。
    target.remote.region雲端儲存區域。如果您使用本機 MinIO,它可以是任何值。
    target.remote.bucket儲存資料的 Bucket 名稱。該值必須與 Milvus 2.x 中的 config 相同。如需詳細資訊,請參閱系統組態
    target.remote.akMilvus 2.x 儲存的存取金鑰。
    target.remote.skMilvus 2.x 儲存的保密金鑰。
    target.remote.useIAM是否使用 IAM 角色進行連接。
    target.remote.useSSL連線至 Milvus 2.x 時是否啟用 SSL。如需詳細資訊,請參閱傳輸中加密
    target.remote.checkBucket是否檢查指定的儲存桶是否存在於物件儲存空間。
    target.milvus2x.endpoint目標 Milvus 伺服器的位址。
    target.milvus2x.usernameMilvus 2.x 伺服器的使用者名稱。如果您的 Milvus 伺服器啟用使用者驗證,則必須使用此參數。如需詳細資訊,請參閱啟用驗證
    target.milvus2x.passwordMilvus 2.x 伺服器的密碼。如果您的 Milvus 伺服器啟用使用者驗證,則必須使用此參數。如需更多資訊,請參閱啟用驗證

啟動遷移工作

  1. 使用以下命令啟動遷移工作。將{YourConfigFilePath} 改為配置檔案migration.yaml 所在的本機目錄。

    ./milvus-migration  dump  --config=/{YourConfigFilePath}/migration.yaml
    

    上述命令會將 Faiss 索引資料轉換成 NumPy 檔案,然後使用bulkInsert作業將資料寫入目標資料桶。

  2. 生成 NumPy 檔案後,使用下列指令將這些檔案匯入 Milvus 2.x。將{YourConfigFilePath} 改為配置檔案migration.yaml 所在的本機目錄。

    ./milvus-migration  load  --config=/{YourConfigFilePath}/migration.yaml
    

驗證結果

一旦執行轉移任務,您可以呼叫 API 或使用 Attu 檢視轉移的實體數量。如需詳細資訊,請參閱Attuget_collection_stats()

免費嘗試托管的 Milvus

Zilliz Cloud 無縫接入,由 Milvus 提供動力,速度提升 10 倍。

開始使用
反饋

這個頁面有幫助嗎?