我一直在尝试部署 mariadb-operator、mariadb 完全复制和 maxscale。一切都很好,但我有两个问题 - 它们可能是相关的。
当我为 maxscale 部署以下 yaml 时,它会给出错误:初始化 Pod 'maxscale-0' 时出错:创建监视器时出错:无法使用模块 'mariadbmon' 创建监视器 'mariadbmon-monitor'
我的 Maxscale:
apiVersion: k8s.mariadb.com/v1alpha1
kind: MaxScale
metadata:
name: maxscale
spec:
podSecurityContext:
runAsUser: 0
replicas: 3
mariaDbRef:
name: mariadb
initContainers:
## Added for local in mac/minikube: https://github.com/mariadb-operator/mariadb-operator/issues/381
- image: busybox
command:
- /bin/sh
- -c
- chown -R 998:996 /var/lib/maxscale
volumeMounts:
- name: storage
mountPath: /var/lib/maxscale
services:
- name: rw-router
router: readwritesplit
params:
transaction_replay: "true"
transaction_replay_attempts: "10"
transaction_replay_timeout: "5s"
max_slave_connections: "255"
max_replication_lag: "3s"
master_accept_reads: "true"
listener:
port: 3306
protocol: MariaDBProtocol
params:
connection_metadata: "tx_isolation=auto"
- name: rconn-master-router
router: readconnroute
params:
router_options: "master"
max_replication_lag: "3s"
master_accept_reads: "true"
listener:
port: 3307
- name: rconn-slave-router
router: readconnroute
params:
router_options: "slave"
max_replication_lag: "3s"
listener:
port: 3308
monitor:
interval: 2000ms
cooperativeMonitoring: majority_of_all
params:
disable_master_failback: "false"
available_when_donor: "false"
disable_master_role_setting: "false"
admin:
port: 8989
guiEnabled: true
config:
sync:
database: mysql
interval: 5s
timeout: 10s
volumeClaimTemplate:
resources:
requests:
storage: 300Mi
accessModes:
- ReadWriteOnce
auth:
generate: true
kubernetesService:
type: LoadBalancer
guiKubernetesService:
type: ClusterIP
connection:
secretName: mxs-conn
port: 3306
requeueInterval: 10s
我的玛丽亚数据库:
apiVersion: k8s.mariadb.com/v1alpha1
kind: MariaDB
metadata:
name: mariadb
spec:
podSecurityContext:
runAsUser: 0
rootPasswordSecretKeyRef:
name: mariadb-root
key: password
generate: true
username: mariadb
passwordSecretKeyRef:
name: mariadb-password
key: password
generate: true
database: mariadb
storage:
size: 300Mi
resizeInUseVolumes: true
waitForVolumeResize: true
volumeClaimTemplate:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 300Mi
replicas: 3
# provision a MaxScale instance and set 'spec.maxScaleRef' automatically.
maxScaleRef:
name: maxscale
enabled: true
replication:
enabled: true
primary:
automaticFailover: false
replica:
waitPoint: AfterCommit
gtid: SlavePos
connectionTimeout: 10s
connectionRetries: 10
syncTimeout: 10s
syncBinlog: true
service:
type: LoadBalancer
connection:
secretName: mariadb-repl-conn
secretTemplate:
key: dsn
primaryService:
type: ClusterIP
primaryConnection:
secretName: mariadb-repl-conn-primary
secretTemplate:
key: dsn
secondaryService:
type: ClusterIP
secondaryConnection:
secretName: mariadb-repl-conn-secondary
secretTemplate:
key: dsn
affinity:
antiAffinityEnabled: true
tolerations:
- key: "k8s.mariadb.com/ha"
operator: "Exists"
effect: "NoSchedule"
podDisruptionBudget:
maxUnavailable: 33%
updateStrategy:
type: ReplicasFirstPrimaryLast
myCnf: |
[mariadb]
bind-address=*
default_storage_engine=InnoDB
binlog_format=row
innodb_autoinc_lock_mode=2
innodb_buffer_pool_size=1024M
max_allowed_packet=256M
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
memory: 1Gi
livenessProbe:
initialDelaySeconds: 20
periodSeconds: 5
timeoutSeconds: 5
readinessProbe:
initialDelaySeconds: 20
periodSeconds: 5
timeoutSeconds: 5
metrics:
enabled: true
错误日志:
{"level":"error","ts":1724848591.526018,"msg":"Reconciler error","controller":"maxscale","controllerGroup":"k8s.mariadb.com","controllerKind":"MaxScale","MaxScale":{"name":"maxscale","namespace":"mariadb"},"namespace":"mariadb","name":"maxscale","reconcileID":"9ef2ef75-7a9e-40b3-9f7f-47e8e7d5dff7","error":"error reconciling phase Init: 1 error occurred:\n\t* error initializing Pod 'maxscale-0': error creating monitor: Could not create monitor 'mariadbmon-monitor' with module 'mariadbmon'\n\n","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
{"level":"info","ts":1724848591.7120426,"msg":"Initializing MaxScale Pod","controller":"maxscale","controllerGroup":"k8s.mariadb.com","controllerKind":"MaxScale","MaxScale":{"name":"maxscale","namespace":"mariadb"},"namespace":"mariadb","name":"maxscale","reconcileID":"4e51940e-0eee-428e-8b33-6a8a507e1f71","pod":"maxscale-0"}
{"level":"error","ts":1724848591.7299356,"msg":"Reconciler error","controller":"maxscale","controllerGroup":"k8s.mariadb.com","controllerKind":"MaxScale","MaxScale":{"name":"maxscale","namespace":"mariadb"},"namespace":"mariadb","name":"maxscale","reconcileID":"4e51940e-0eee-428e-8b33-6a8a507e1f71","error":"error reconciling phase Init: 1 error occurred:\n\t error initializing Pod 'maxscale-0': error creating monitor: Could not create monitor 'mariadbmon-monitor' with module 'mariadbmon'\n\n","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
环境详情:
这已在较新的
mariadb-operator
版本中得到解决。 https://github.com/mariadb-operator/mariadb-operator/issues/814#issuecomment-2343125150