从 HDF5 迁移数据到 Milvus
本主题描述如何使用 VTS(专为 Milvus 数据迁移设计的开源工具)将 HDF5 文件中的数据导入到 Milvus。
前提条件
在迁移 Milvus 数据之前,您需要安装 MilvusDM。
1. 下载 YAML 文件
下载 M2H.yaml
文件。
$ wget https://raw.githubusercontent.com/milvus-io/milvus-tools/main/yamls/M2H.yaml
2. 设置参数
配置参数包括:
Parameter | Description | Example |
---|---|---|
milvus_version | Version of Milvus. | 2.0.0 |
data_path | Path to the HDF5 files. Set either data_path or data_dir . | - /Users/zilliz/float_1.h5 - /Users/zilliz/float_2.h5 |
data_dir | Directory of the HDF5 files. Set either data_path or data_dir . | '/Users/zilliz/Desktop/HDF5_data' |
dest_host | Milvus server address. | '127.0.0.1' |
dest_port | Milvus server port. | 19530 |
mode | Mode of migration, including skip , append , and overwrite . This parameter works only when the specified collection name exists in the Milvus library. skip refers to skipping data migration if the specified collection or partition already exists.append refers to appending data if the specified collection or partition already exists.overwrite refers to deleting existing data before insertion if the specified collection or partition already exists. | 'append' |
dest_collection_name | Name of the collection to import data to. | 'test_float' |
dest_partition_name (optional) | Name of the partition to import data to. | 'partition_1' |
collection_parameter | Collection-specific information including vector dimension, index file size, and similarity metric. | "dimension: 512 index_file_size: 1024 metric_type: 'HAMMING'" |
以下两个配置示例供您参考。第一个示例设置参数 data_path
,第二个设置 data_dir
。您可以根据需要设置 data_path
或 data_dir
。
示例 1
H2M:
milvus-version: 2.0.0
data_path:
- /Users/zilliz/float_1.h5
- /Users/zilliz/float_2.h5
data_dir:
dest_host: '127.0.0.1'
dest_port: 19530
mode: 'overwrite' # 'skip/append/overwrite'
dest_collection_name: 'test_float'
dest_partition_name: 'partition_1'
collection_parameter:
dimension: 128
index_file_size: 1024
metric_type: 'L2'
示例 2
H2M:
milvus_version: 2.0.0
data_path:
data_dir: '/Users/zilliz/HDF5_data'
dest_host: '127.0.0.1'
dest_port: 19530
mode: 'append' # 'skip/append/overwrite'
dest_collection_name: 'test_binary'
dest_partition_name:
collection_parameter:
dimension: 512
index_file_size: 1024
metric_type: 'HAMMING'
3. 从 HDF5 迁移数据到 Milvus
使用以下命令运行 MilvusDM 将 HDF5 文件中的数据导入到 Milvus。
$ milvusdm --yaml H2M.yaml
下一步
- 如果您有兴趣将其他形式的数据迁移到 Milvus,
- 了解如何从 Faiss 迁移数据到 Milvus。
- 如果您正在寻找如何从 Milvus 1.x 迁移数据到 Milvus 2.0 的信息,
- 了解版本迁移。
- 如果您有兴趣了解更多关于数据迁移工具的信息,
- 阅读 VTS 的概述。