从 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 迁移: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存储数据的桶名。该值必须与 Milvus 2.x 中的配置相同。更多信息,请参阅系统配置。 target.remote.ak用于 Milvus 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 服务器启用了用户身份验证,则需要使用此参数。有关详细信息,请参阅启用身份验证。
启动迁移任务
使用以下命令启动迁移任务。将
{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()。