Debezium Operator
Debezium Operator
概述
Debezium Operator 是一个 Kubernetes 操作员,用于在 Kubernetes 和 OpenShift 平台上自动部署和管理 Debezium Server 实例。该操作员实现了标准的 Kubernetes 操作员模式,将用户定义的 DebeziumServer 自定义资源转换为正在运行的变化数据捕获(CDC)管道,从而将数据库变更流式传输到各种接收端系统。
使用 Helm 部署 Debezium Operator
Helm 是安装该操作员的首选方式。该操作员可在 Debezium Helm Chart 仓库中获取。您可以将操作员安装到已有的命名空间,也可以安装到新的命名空间。
输入以下命令创建一个专用命名空间:
kubectl create namespace debezium输入以下命令添加 Debezium charts 仓库并安装操作员:
helm repo add debezium https://charts.debezium.io helm install my-debezium-operator debezium/debezium-operator --version 3.2.0-final -n debezium
你可以在 Debezium Helm Chart 仓库中找到 Operator 的可用版本。
跟踪 Operator 部署进度
你可以运行命令来监控部署进度并查看 Operator 日志。
操作步骤
要监控部署进度,请运行以下命令:
kubectl get pod -n debezium --watch要监控 Operator 日志,请输入以下命令:
kubectl logs deployment/debezium-operator -n debezium -f
Operator 运行后,它会监视新增的自定义资源,并基于这些自定义资源创建 Debezium Server 实例。
DebeziumServer 自定义资源
通过在 DebeziumServer 自定义资源中声明属性,来指定 Debezium Server 实例的配置。
示例 1. Debezium Server 自定义资源的基本结构
apiVersion: debezium.io/v1alpha1
kind: DebeziumServer
metadata:
name: my-debezium-server
spec:
image: String
version: String
runtime:
environment:
vars:
- name: String
value: String
from: # EnvFromSource array
- sourceName: String
# add other EnvFromSource fields as needed
storage:
data:
type: persistent | ephemeral
claimName: String # required if type is "persistent"
external: # Volume array
- name: String
# add other Volume fields as needed
jmx:
enabled: boolean
port: int # defaults to 1099
metrics:
jmxExporter:
enabled: boolean
openTelemetry:
enabled: boolean
collector:
endpoint: String
templates:
container:
resources: ResourceRequirements
securityContext: SecurityContext
pod:
metadata:
annotations: # Map<String, String>
key: value
labels: # Map<String, String>
key: value
imagePullSecrets: # List
- name: String
affinity: Affinity
securityContext: PodSecurityContext
quarkus:
config:
# quarkus properties
format:
value:
type: String
config:
# format properties
key:
type: String
config:
# format properties
header:
type: String
config:
# format properties
transforms:
- type: String
predicate: String
negate: Boolean
config:
# transformation properties
predicates:
name:
type: String
config:
# predicate properties
sink:
type: String
config:
# sink properties
source:
class: String
config:
# source connector propertiesDebeziumServer 规范
DebeziumServer 架构参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
spec | DebeziumServerSpec | 无默认值 | Debezium Server 的规范 |
status | DebeziumServerStatus | 无默认值 | Debezium Server 实例的状态。 |
表 1. DebeziumServer 属性
DebeziumServerStatus 架构参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
conditions | List<Condition> | 无默认值 | 状态条件列表 |
observedGeneration | Long | 0 | 最近一次观察到的代(generation) |
表 2. DebeziumServerStatus 属性
Condition 模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
status | String | 无默认值 | 该条件的状态,取值为 True、False 或 Unknown。 |
message | String | 无默认值 | 描述该条件最近一次状态转换详情的可读信息。 |
type | String | 无默认值 | 条件的唯一标识符。 |
表 3. Condition 属性
DebeziumServerSpec 模式参考
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
image | String | 无默认值 | 用于 Debezium Server 容器的镜像。此属性优先于 version。 |
version | String | 与 operator 相同 | 要使用的 Debezium Server 版本。 |
sink | Sink | 无默认值 | Sink 配置。 |
source | Source | 无默认值 | Debezium source 连接器配置。 |
format | Format | 无默认值 | 消息输出格式配置。 |
quarkus | Quarkus | 无默认值 | 传递给 Debezium Server 进程的 Quarkus 配置。 |
runtime | Runtime | 无默认值 | 指定是否可以修改 Debezium Server 运行时的各个方面。 |
transforms | List<Transformation> | 无默认值 | 此 Debezium Server 实例采用的单条消息转换(Single Message Transformations)。 |
predicates | Map<String, Predicate> | 无默认值 | 此 Debezium Server 实例采用的谓词。 |
表 4. DebeziumServerSpec 属性
Sink 架构参考
表 5. Sink 属性
Source 架构参考
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
sourceClass | String | 无默认值 | 源连接器 Java 类的全限定名。 |
offset | Offset | 无默认值 | 偏移量存储配置 |
schemaHistory | SchemaHistory | 无默认值 | 模式历史存储配置 |
config | Map | 无默认值 | 源连接器配置属性。 |
表 6. Source 属性
格式模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
key | FormatType | 无默认值 | 消息键格式配置。 |
value | FormatType | 无默认值 | 消息值格式配置。 |
header | FormatType | 无默认值 | 消息头格式配置。 |
表 7. Format 属性
FormatType 架构参考
用于:Format
表 8. FormatType 属性
Quarkus 模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
config | Map | 无默认值 | Quarkus 配置属性。 |
表 9. Quarkus 属性
运行时模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
api | RuntimeApi | 无默认值 | API 配置 |
storage | RuntimeStorage | 无默认值 | 存储配置 |
environment | RuntimeEnvironment | 无默认值 | 此 Debezium Server 实例使用的附加环境变量。 |
jmx | JmxConfig | 无默认值 | JMX 配置。 |
templates | Templates | 无默认值 | Debezium Server 资源模板。 |
serviceAccount | String | 无默认值 | 用于运行 Debezium Server Pod 的现有服务账号 |
metrics | Metrics | 无默认值 | 指标配置 |
表 10. 运行时属性
RuntimeApi 模式参考
用于:Runtime
表 11. RuntimeApi 属性
RuntimeStorage 模式参考
用于:Runtime
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
data | DataStorage | 无默认值 | 此 Debezium Server 实例使用的文件存储配置。 |
external | List<Volume> | 无默认值 | 挂载到 /debezium/external 的附加卷 |
表 12. RuntimeStorage 属性
RuntimeEnvironment 模式参考
用于:Runtime
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
vars | List<ContainerEnvVar> | 无默认值 | 应用于容器的环境变量。 |
from | List<EnvFromSource> | 无默认值 | 在容器中从 ConfigMap 或 Secret 设置的额外环境变量。 |
表 13. RuntimeEnvironment 属性
JmxConfig 模式参考
用于:Runtime
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
enabled | boolean | false | 是否为此 Debezium Server 实例启用 JMX。 |
port | int | 1099 | JMX 端口。 |
authentication | JmxAuthentication | 无默认值 | JMX 认证配置。 |
表 14. JmxConfig 属性
JmxAuthentication 模式参考
用于:JmxConfig
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
enabled | boolean | false | 是否为此 Debezium Server 实例启用 JMX 认证。 |
secret | String | 无默认值 | 提供凭据文件的 Secret |
accessFile | String | jmxremote.access | JMX 访问文件名与 Secret 键 |
passwordFile | String | jmxremote.password | JMX 密码文件名与 Secret 键 |
表 15. JmxAuthentication 属性
模板(Templates)模式参考
用于:Runtime
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
container | ContainerTemplate | 无默认值 | 容器模板 |
pod | PodTemplate | 无默认值 | Pod 模板。 |
volumeClaim | PersistentVolumeClaimSpec | 无默认值 | 数据卷的 PVC 模板,仅在未指定显式声明时使用。 |
表 16. Templates 属性
Metrics 架构参考
用于:Runtime
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
jmxExporter | JmxExporter | 无默认值 | Prometheus JMX exporter 配置 |
openTelemetry | OpenTelemetry | 无默认值 | OpenTelemetry 配置 |
表 17. Metrics 属性
JmxExporter 架构参考
用于:Metrics
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
enabled | boolean | 无默认值 | 启用 JMX Prometheus 导出器 |
configFrom | ConfigMapKeySelector | 无默认值 | 配置映射键引用,其值将用作配置文件 |
表 18. JmxExporter 属性
OpenTelemetry 模式参考
用于:Metrics
启用 OpenTelemetry 后,Operator 会自动为 Debezium Server 容器配置以下环境变量:
OTEL_ENABLED—— 激活随 Debezium Server 捆绑的 OpenTelemetry Java Agent。OTEL_SDK_DISABLED—— 设置为false以确保 OpenTelemetry SDK 处于活动状态。OTEL_EXPORTER_OTLP_ENDPOINT—— OTLP 收集器端点(默认为http://localhost:4318)。OTEL_METRICS_EXPORTER—— 指标导出器类型(默认为otlp)。OTEL_SERVICE_NAME—— 设置为 DebeziumServer 资源的名称。OTEL_RESOURCE_ATTRIBUTES—— 包含service.name和debezium.connector.type属性。OTEL_JMX_CONFIG—— 指向内置的 JMX 到 OpenTelemetry 指标映射配置。
你可以通过在 spec.runtime.environment.vars 中指定任意这些环境变量来覆盖它们。用户提供的环境变量优先于 Operator 管理的默认值。
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
enabled | boolean | false | 启用 OpenTelemetry |
collector | OtelCollector | 无默认值 | OpenTelemetry 收集器配置 |
表 19. OpenTelemetry 属性
OtelCollector 架构参考
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
endpoint | String | http://localhost:4318 | OTLP 收集器端点 |
表 20. OpenTelemetry 收集器属性
Transformation 架构参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
type | String | 无默认值 | 实现该转换的 Java 类的完全限定名。 |
config | Map | 无默认值 | 转换特有的配置属性。 |
predicate | String | 无默认值 | 要应用于此转换的谓词的名称。 |
negate | boolean | false | 决定是否对所应用谓词的结果取反。 |
表 21. 转换属性
谓词模式参考
表 22. 谓词属性
ConfigMapOffsetStore 架构参考
用于:Offset
表 23. ConfigMapOffsetStore 属性
ContainerEnvVar 架构参考
表 24. ContainerEnvVar 属性
ContainerTemplate 架构参考
用于:Templates
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
resources | ResourceRequirements | 无默认值 | CPU 和内存资源需求。 |
securityContext | SecurityContext | 无默认值 | 容器安全上下文。 |
probes | Probes | 无默认值 | 容器探针配置。 |
imagePullPolicy | Always,IfNotPresent,Never | 无默认值 | 容器的镜像拉取策略。 |
表 25. ContainerTemplate 属性
CustomStore 模式参考
表 26. CustomStore 属性
DataStorage 模式参考
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
type | ephemeral,persistent | ephemeral | 存储类型。 |
claimName | String | 无默认值 | 持久化存储所使用的持久卷声明(PersistentVolumeClaim)的名称。 |
表 27. DataStorage 属性
FileOffsetStore 模式参考
用于:Offset
表 28. FileOffsetStore 属性
FileSchemaHistoryStore 模式参考
表 29. FileSchemaHistoryStore 属性
InMemoryOffsetStore 模式参考
用于:Offset
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
config | Map | 无默认值 | 其他存储配置属性。 |
表 30. InMemoryOffsetStore 属性
InMemorySchemaHistoryStore 模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
config | Map | 无默认值 | 其他存储配置属性。 |
表 31. InMemorySchemaHistoryStore 属性
JdbcOffsetStore 模式参考
用于:Offset
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
table | JdbcOffsetTableConfig | 无默认值 | 偏移量表的配置 |
url | String | 无默认值 | JDBC 连接 URL |
user | String | 无默认值 | 用于连接存储数据库的用户名 |
password | String | 无默认值 | 用于连接存储数据库的密码 |
retryDelay | long | 无默认值 | 连接失败时的重试延迟(毫秒) |
maxRetries | int | 无默认值 | 连接失败时的最大重试次数 |
config | Map | 无默认值 | 存储的其他配置属性。 |
表 32. JdbcOffsetStore 属性
JdbcOffsetTableConfig 模式参考
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
name | String | 无默认值 | 偏移量表的名称 |
ddl | String | 无默认值 | 用于创建偏移量表的 DDL 语句 |
select | String | 无默认值 | 用于从偏移量表中查询数据的语句 |
insert | String | 无默认值 | 用于向偏移量表中插入数据的语句 |
delete | String | 无默认值 | 用于更新偏移量表的语句 |
表 33. JdbcOffsetTableConfig 属性
JdbcSchemaHistoryStore 模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
table | JdbcSchemaHistoryTableConfig | 无默认值 | 偏移量表的配置 |
url | String | 无默认值 | JDBC 连接 URL |
user | String | 无默认值 | 用于连接存储数据库的用户名 |
password | String | 无默认值 | 用于连接存储数据库的密码 |
retryDelay | long | 无默认值 | 连接失败时的重试延迟(毫秒) |
maxRetries | int | 无默认值 | 连接失败时的最大重试次数 |
config | Map | 无默认值 | 存储的其他配置属性。 |
表 34. JdbcSchemaHistoryStore 属性
JdbcSchemaHistoryTableConfig 模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
name | 字符串 | 无默认值 | 偏移量表的名称 |
ddl | 字符串 | 无默认值 | 用于创建模式历史表的 DDL 语句 |
select | 字符串 | 无默认值 | 用于从模式历史表中查询数据的语句 |
insert | 字符串 | 无默认值 | 用于向模式历史表中插入数据的语句 |
dataExistsSelect | 字符串 | 无默认值 | 用于检查模式历史表中是否存在某些数据的语句 |
表 35. JdbcSchemaHistoryTableConfig 属性
KafkaOffsetStore 模式参考
用于:Offset
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
props | Map | 无默认值 | 附加的 Kafka 客户端属性。 |
bootstrapServers | String | 无默认值 | 连接器用于与 Kafka 集群建立初始连接的主机/端口对列表 |
topic | String | 无默认值 | 用于存储偏移量的 Kafka 主题名称 |
partitions | int | 无默认值 | 创建偏移量存储主题时使用的分区数 |
replicationFactor | int | 无默认值 | 创建偏移量存储主题时使用的副本因子 |
config | Map | 无默认值 | 附加的存储配置属性。 |
表 36. KafkaOffsetStore 属性
KafkaSchemaHistoryStore 模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
bootstrapServers | String | 无默认值 | 连接器用于与 Kafka 集群建立初始连接的主机/端口对列表 |
topic | String | 无默认值 | 用于存储偏移量的 Kafka 主题名称 |
partitions | int | 无默认值 | 创建偏移量存储主题时使用的分区数 |
replicationFactor | int | 无默认值 | 创建偏移量存储主题时使用的副本因子 |
config | Map | 无默认值 | 其他存储配置属性。 |
表 37. KafkaSchemaHistoryStore 属性
MetadataTemplate 架构参考
用于:PodTemplate
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
labels | Map<String, String> | 无默认值 | 添加到 Kubernetes 资源上的标签 |
annotations | Map<String, String> | 无默认值 | 添加到 Kubernetes 资源上的注解 |
表 38. MetadataTemplate 属性
Offset 架构参考
用于:Source
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
file | FileOffsetStore | 无默认值 | 基于文件的偏移量存储配置 |
memory | InMemoryOffsetStore | 无默认值 | 基于内存的偏移量存储配置 |
redis | RedisOffsetStore | 无默认值 | 基于 Redis 的偏移量存储配置 |
kafka | KafkaOffsetStore | 无默认值 | 基于 Kafka 的存储配置 |
jdbc | JdbcOffsetStore | 无默认值 | 基于 JDBC 的存储配置 |
configMap | ConfigMapOffsetStore | 无默认值 | 基于 ConfigMap 的偏移量存储配置 |
store | CustomStore | 无默认值 | 自定义偏移量存储配置 |
flushMs | long | 60000 | 尝试提交偏移量的间隔时间 |
表 39. 偏移量属性
PodTemplate 架构参考
用于:Templates
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
metadata | MetadataTemplate | 无默认值 | 应用于该资源的元数据。 |
imagePullSecrets | List<LocalObjectReference> | 无默认值 | 用于拉取该 Pod 所使用的任意镜像的本地 Secret 引用列表。 |
affinity | Affinity | 无默认值 | Pod 亲和性规则 |
securityContext | PodSecurityContext | 无默认值 | Pod 级别的安全属性和容器设置 |
表 40. PodTemplate 属性
探针(Probe)架构参考
用于:Probes
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
initialDelaySeconds | int | 5 | 容器启动后经过多少秒才开始执行探针。 |
periodSeconds | int | 10 | 执行探针的间隔时间(以秒为单位)。 |
timeoutSeconds | int | 10 | 探针超时的秒数。 |
failureThreshold | int | 3 | 在整体检查判定为失败之前允许连续失败的次数。 |
表 41. 探针属性
Probes 架构参考
表 42. 探针属性
RedisOffsetStore 模式参考
用于:Offset
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
address | String | 无默认值 | 用于连接的 Redis host:port |
user | String | 无默认值 | Redis 用户名 |
password | String | 无默认值 | Redis 密码 |
sslEnabled | boolean | false | Redis 用户名 |
key | String | 无默认值 | Redis 哈希键 |
wait | RedisStoreWaitConfig | 无默认值 | 配置副本写入的验证方式 |
config | Map | 无默认值 | 其他存储配置属性。 |
表 43. RedisOffsetStore 属性
RedisSchemaHistoryStore 模式参考
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
address | String | 无默认值 | 用于连接的 Redis host:port |
user | String | 无默认值 | Redis 用户名 |
password | String | 无默认值 | Redis 密码 |
sslEnabled | boolean | false | Redis 用户名 |
key | String | 无默认值 | Redis 哈希键 |
wait | RedisStoreWaitConfig | 无默认值 | 配置副本写入的校验方式 |
config | Map | 无默认值 | 附加的存储配置属性。 |
表 44. RedisSchemaHistoryStore 属性
RedisStoreWaitConfig 模式参考
用于:RedisOffsetStore、RedisSchemaHistoryStore
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
enabled | boolean | false | 对于带有副本的 Redis,此选项允许验证数据已写入副本 |
timeoutMs | long | 1000 | 等待副本时的超时时间(毫秒) |
retry | boolean | false | 启用等待副本时的重试 |
retryDelayMs | long | 1000 | 等待时重试的延迟时间 |
表 45. RedisStoreWaitConfig 属性
SchemaHistory 模式参考
用于:Source
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
file | FileSchemaHistoryStore | 无默认值 | 基于文件的 Schema 历史存储配置 |
memory | InMemorySchemaHistoryStore | 无默认值 | 基于内存的 Schema 历史存储配置 |
redis | RedisSchemaHistoryStore | 无默认值 | 基于 Redis 的 Schema 历史存储配置 |
kafka | KafkaSchemaHistoryStore | 无默认值 | 基于 Kafka 的 Schema 历史存储配置 |
jdbc | JdbcSchemaHistoryStore | 无默认值 | 基于 JDBC 的 Schema 历史存储配置 |
store | CustomStore | 无默认值 | 自定义 Schema 历史存储配置 |
config | Map | 无默认值 | 额外的通用 Schema 历史存储配置属性。 |
表 46. SchemaHistory 属性
完整的 Debezium Server 配置示例
以下示例展示了包含前面各表中属性的完整 Debezium Server 自定义资源。
示例 2. 完整的 Debezium Server 自定义资源
apiVersion: debezium.io/v1alpha1
kind: DebeziumServer
metadata:
name: my-debezium-server
spec:
version: "3.2.0"
source:
class: io.debezium.connector.mysql.MySqlConnector
config:
database.hostname: mysql-server
database.port: 3306
database.user: debezium
database.password: secret
database.server.id: 184054
topic.prefix: mysql
database.include.list: inventory
offset:
type: kafka
config:
bootstrap.servers: kafka:9092
topic: debezium-offsets
schemaHistory:
type: kafka
config:
bootstrap.servers: kafka:9092
topic: debezium-schema-history
sink:
type: kafka
config:
bootstrap.servers: kafka:9092
format:
key:
type: json
value:
type: json
config:
schemas.enable: false
runtime:
jmx:
enabled: true
port: 1099
storage:
data:
type: persistent
claimName: debezium-data-pvc
metrics:
jmxExporter:
enabled: true
openTelemetry:
enabled: true
collector:
endpoint: http://otel-collector:4318
transforms:
- type: io.debezium.transforms.UnwrapFromEnvelope
config:
drop.tombstones: false
predicate: inventory-filter
negate: false
predicates:
inventory-filter:
type: org.apache.kafka.connect.transforms.predicates.TopicNameMatches
config:
pattern: "mysql.inventory.*"
quarkus:
config:
quarkus.log.level: INFO
quarkus.http.port: 8080评论
登录后参与评论
KnowForge