跳到主要内容
版本:3.10.0

更新 悦数图数据库 集群的配置

悦数图数据库 集群中 Meta、Storage、Graph 服务都有各自的默认配置。NebulaGraph Operator 支持自定义集群服务的配置。本文介绍如何修改 悦数图数据库 集群的默认配置。

备注

暂不支持通过 Helm 自定义 悦数图数据库 集群的配置参数。

前提条件

已使用 NebulaGraph Operator 创建一个集群。具体步骤,参见创建 悦数图数据库 集群

配置方式

集群服务的配置在创建集群的 YAML 文件中,通过spec.<metad|graphd|storaged>.config参数指定。NebulaGraph Operator 会将config中的配置写入到对应服务的 ConfigMap 中,然后在服务启动时将 ConfigMap 挂载到服务的配置文件目录/usr/local/nebula/etc/下。

config结构如下:

Config map[string]string `json:"config,omitempty"`

例如,修改 Graph 服务的enable_authorize参数的配置,可以在创建集群时或者之后,通过spec.graphd.config参数指定。

apiVersion: apps.nebula-graph.io/v1alpha1
kind: NebulaCluster
metadata:
name: nebula
namespace: default
spec:
graphd:
...
config: // 为 Graph 服务自定义参数。
"enable_authorize": "true" // 启用授权。默认值为 false。
...

如果需要为 Meta 服务和 Storage 服务配置config,则在spec.metad.configspec.storaged.config中添加对应的配置项。

可配置的参数

config字段下可配置的参数详情,请分别参见:

参数更新与 Pod 重启规则

集群服务的配置参数分为两类:一类是必需重启服务才能更新的配置;另一类是可以在服务运行时动态更新的配置,在服务运行时更新的配置不会被持久化,重启服务后,配置会恢复到配置文件中的值。

关于服务的配置参数是否支持运行时动态更新,请查看上述服务配置参数详情页各个表格中是否支持运行时动态修改一列;或者查看 Dynamic runtime flags

在更新集群服务的配置时,需要注意以下几点:

  • 如果config下更新的参数均为支持运行时动态更新的参数,则不会触发服务 Pod 的重启,并且配置参数的更新不会被持久化。
  • 如果config下更新的参数包含一个或多个不支持运行时动态更新的参数,则会触发服务 Pod 的重启,并且只有不支持运行时动态参数的更新才会被持久化。
备注

若要在集群运行时动态修改参数配置且不触发 Pod 重启,请确保当前修改的参数全部支持运行时动态修改。

自定义端口配置

本示例演示如何自定义 Meta、Storage、Graph 服务的端口配置。

可以在config字段中添加portws_http_port参数,从而配置自定义的端口。这两个参数的详细信息,请参见Meta 服务配置参数Storage 服务配置参数Graph 服务配置参数的 networking 配置一节。

备注
  • 自定义portws_http_port参数配置后,会触发 Pod 重启,并在重启后生效。
  • 在集群启动后,不建议修改port参数。
  1. 修改集群配置文件。

  2. 打开集群配置文件。

kubectl edit nc nebula
  1. 修改配置文件,添加config字段,配置自定义端口。
apiVersion: apps.nebula-graph.io/v1alpha1
kind: NebulaCluster
metadata:
name: nebula
namespace: default
spec:
graphd:
config: # 为 Graph 服务自定义端口配置。
port: "3669"
ws_http_port: "8080"
resources:
requests:
cpu: "200m"
memory: "500Mi"
limits:
cpu: "1"
memory: "1Gi"
replicas: 1
image: vesoft/nebula-graphd
version: v3.12.0
metad:
config: # 为 Meta 服务自定义端口配置。
ws_http_port: 8081
resources:
requests:
cpu: "300m"
memory: "500Mi"
limits:
cpu: "1"
memory: "1Gi"
replicas: 1
image: vesoft/nebula-metad
version: v3.12.0
dataVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: local-path
storaged:
config: # 为 Storage 服务自定义端口配置。
ws_http_port: 8082
resources:
requests:
cpu: "300m"
memory: "500Mi"
limits:
cpu: "1"
memory: "1Gi"
replicas: 1
image: vesoft/nebula-storaged
version: v3.12.0
dataVolumeClaims:
- resources:
requests:
storage: 2Gi
storageClassName: local-path
enableAutoBalance: true
reference:
name: statefulsets.apps
version: v1
schedulerName: default-scheduler
imagePullPolicy: IfNotPresent
imagePullSecrets:
- name: nebula-image
enablePVReclaim: true
topologySpreadConstraints:
- topologyKey: kubernetes.io/hostname
whenUnsatisfiable: "ScheduleAnyway"
  1. 保存配置文件。

配置文件保存后,NebulaGraph Operator 会自动更新集群配置。

  1. Esc键退出编辑模式。

  2. 输入:wq保存配置文件并退出。

  3. 验证配置已经生效。

kubectl get svc

返回示例:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nebula-graphd-headless ClusterIP None <none> 3669/TCP,8080/TCP 10m
nebula-graphd-svc ClusterIP 10.102.13.115 <none> 3669/TCP,8080/TCP 10m
nebula-metad-headless ClusterIP None <none> 9559/TCP,8081/TCP 11m
nebula-storaged-headless ClusterIP None <none> 9779/TCP,8082/TCP,9778/TCP 11m

可以看到,Graph 服务的 RPC 守护进程监听端口已经变为3669(默认9669),HTTP 端口已经变为8080(默认19669);Meta 服务的 HTTP 端口已经变为8081(默认19559);Storage 服务的 HTTP 端口已经变为8082(默认19779)。