配置操作员(configure_operator)

配置 Milvus 集群

在生产环境中,您需要根据机器类型和工作负载为 Milvus 集群分配资源。您可以在部署期间进行配置,也可以在集群运行时更新配置。

本主题介绍如何在使用 Milvus Operator 安装 Milvus 时配置 Milvus 集群。

本主题假定您已部署 Milvus Operator。有关更多信息,请参见部署 Milvus Operator

使用Milvus Operator配置Milvus集群包括:

  • 全局资源配置
  • 私有资源配置

私有资源配置将覆盖全局资源配置。如果同时配置全局资源并指定某个组件的私有资源,该组件将优先并首先响应私有配置。

配置全局资源

使用Milvus Operator启动Milvus集群时,需要指定一个配置文件。此处的示例使用默认的配置文件。

kubectl apply -f https://raw.githubusercontent.com/milvus-io/milvus-operator/main/config/samples/milvus_cluster_default.yaml
 

配置文件的详细信息如下:

apiVersion: milvus.io/v1beta1
kind: Milvus
metadata:
  name: my-release
  labels:
    app: milvus
spec:
  mode: cluster
  dependencies: {}
  components: {}
  config: {}
 

字段spec.components包括所有Milvus组件的全局和私有资源配置。以下是四个常用字段来配置全局资源。

如果您想配置更多字段,请参见文档此处 (opens in a new tab)

要为Milvus集群配置全局资源,请创建milvuscluster_resource.yaml文件。

示例

以下示例为Milvus集群配置全局资源。

apiVersion: milvus.io/v1beta1
kind: Milvus
metadata:
  name: my-release
  labels:
    app: milvus
spec:
  mode: cluster
  components:
    image: milvusdb/milvus:v2.1.0
    nodeSelector: {}
    tolerations: {}
    env: {}
    resources:
      limits:
        cpu: '4'
        memory: 8Gi
      requests:
        cpu: 200m
        memory: 512Mi
 

运行以下命令以应用新配置:

kubectl apply -f milvuscluster_resource.yaml
 

如果在K8s集群中存在名为my-release的Milvus集群,则集群资源将根据配置文件进行更新。否则,将创建一个新的Milvus集群。

配置私有资源

在Milvus 2.0中,Milvus集群原本包括8个组件:proxy、root coord、index coord、data coord、query coord、index node、data node和query node。然而,在Milvus 2.1.0发布时,新的组件mix coord也随之发布。Mix coord包括所有的协调器组件。因此,启动mix coord意味着不需要安装和启动其他的协调器,包括root coord、index coord、data coord和query coord。

用于配置每个组件的常见字段包括:

  • replica:每个组件的副本数量。
  • port:每个组件的监听端口号。
  • 全局资源配置中使用的4个常用字段:imageenvnodeSelectortolerationsresources(见上文)。有关更多可配置的字段,请单击此文档 (opens in a new tab)中的每个组件。

此外,在配置proxy时,还有一个额外的字段叫做serviceType。该字段定义了Milvus在K8s集群中提供的服务类型。

要为特定组件配置资源,请先在spec.componets下的字段中添加组件名称,然后配置其私有资源。

Components or dependencies Configuration purposes

以下为Milvus的参数表格和相关说明:

依赖项组件
* etcd * MinIO或S3 * Pulsar * RocksMQ* Root coord * Proxy * Query coord * Query node * Index coord * Index node * Data coord * Data node * 本地存储 * 日志 * 消息通道 * 通用 * Knowhere * 配额和限制
目的参数
性能调优 Performance tuning* queryNode.gracefulTime * rootCoord.minSegmentSizeToEnableIndex * dataCoord.segment.maxSize * dataCoord.segment.sealProportion * dataNode.flush.insertBufSize * queryCoord.autoHandoff * queryCoord.autoBalance * localStorage.enabled
数据和元数据 Data and meta* common.retentionDuration * rocksmq.retentionTimeInMinutes * dataCoord.enableCompaction * dataCoord.enableGarbageCollection * dataCoord.gc.dropTolerance
管理 Administration* log.level * log.file.rootPath * log.file.maxAge * minio.accessKeyID * minio.secretAccessKey
配额和限制 Quota and Limits* quotaAndLimits.ddl.enabled * quotaAndLimits.ddl.collectionRate * quotaAndLimits.ddl.partitionRate * quotaAndLimits.indexRate.enabled * quotaAndLimits.indexRate.max * quotaAndLimits.flushRate.enabled * quotaAndLimits.flush.max * quotaAndLimits.compation.enabled * quotaAndLimits.compaction.max * quotaAndLimits.dml.enabled * quotaAndLimits.dml.insertRate.max * quotaAndLimits.dml.deleteRate.max * quotaAndLimits.dql.enabled * quotaAndLimits.dql.searchRate.max * quotaAndLimits.dql.queryRate.max * quotaAndLimits.limitWriting.ttProtection.enabled * quotaAndLimits.limitWriting.ttProtection.maxTimeTickDelay * quotaAndLimits.limitWriting.memProtection.enabled * quotaAndLimits.limitWriting.memProtection.dataNodeMemoryLowWaterLevel * quotaAndLimits.limitWriting.memProtection.queryNodeMemoryLowWaterLevel * quotaAndLimits.limitWriting.memProtection.dataNodeMemoryHighWaterLevel * quotaAndLimits.limitWriting.memProtection.queryNodeMemoryHighWaterLevel * quotaAndLimits.limitWriting.diskProtection.enabled * quotaAndLimits.limitWriting.diskProtection.diskQuota * quotaAndLimits.limitWriting.forceDeny * quotaAndLimits.limitReading.queueProtection.enabled * quotaAndLimits.limitReading.queueProtection.nqInQueueThreshold * quotaAndLimits.limitReading.queueProtection.queueLatencyThreshold * quotaAndLimits.limitReading.resultProtection.enabled * quotaAndLimits.limitReading.resultProtection.maxReadResultRate

示例

以下示例在milvuscluster.yaml文件中配置了代理和数据节点的副本和计算资源。

apiVersion: milvus.io/v1beta1
kind: Milvus
metadata:
  name: my-release
  labels:
    app: milvus
spec:
  mode: cluster
  components:
    image: milvusdb/milvus:v2.1.0
    resources:
      limits:
        cpu: '4'
        memory: 8Gi
      requests:
        cpu: 200m
        memory: 512Mi
    rootCoord: 
      replicas: 1
      port: 8080
      resources:
        limits:
          cpu: '6'
          memory: '10Gi'
    dataCoord: {}
    queryCoord: {}
    indexCoord: {}
    dataNode: {}
    indexNode: {}
    queryNode: {}
    proxy:
      replicas: 1
      serviceType: ClusterIP
      resources:
        limits:
          cpu: '2'
          memory: 4Gi
        requests:
          cpu: 100m
          memory: 128Mi
  config: {}
  dependencies: {}
 

该示例不仅配置了全局资源,还为root coord和proxy配置了私有计算资源。使用此配置文件启动Milvus集群时,将应用私有资源配置到root coord和proxy上,而其他组件将遵循全局资源配置。

运行以下命令以应用新配置:

kubectl apply -f milvuscluster.yaml
 

下一步