Skip to content

Commit

Permalink
fix: mysql addon error (#1344)
Browse files Browse the repository at this point in the history
Co-authored-by: xuriwuyun <[email protected]>
  • Loading branch information
xuriwuyun and xuriwuyun authored Dec 19, 2024
1 parent 9a224d9 commit 6ca8d49
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 45 deletions.
2 changes: 1 addition & 1 deletion addons/mysql/scripts/init-mysql-instance-for-orc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ setup_master_slave() {
master_from_orc=""
get_master_from_orc

self_last_digit=${SYNCER_POD_NAME##*-}
self_last_digit=${POD_NAME##*-}
self_service_name=$(echo "${COMPONENT_NAME}_MYSQL_${self_last_digit}" | tr '_' '-' | tr '[:upper:]' '[:lower:]' )

# If the cluster is already registered to the Orchestrator and the Master of the cluster is itself, then no action is required.
Expand Down
8 changes: 4 additions & 4 deletions addons/mysql/scripts/mysql-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/bash
REPORT_HOST=${COMPONENT_NAME}-mysql-${SYNCER_POD_NAME##*-}
SERVICE_ID=$((${SYNCER_POD_NAME##*-} + 1))
REPORT_HOST=${COMPONENT_NAME}-mysql-${POD_NAME##*-}
SERVICE_ID=$((${POD_NAME##*-} + 1))
if [ "${MYSQL_MAJOR}" = '5.7' ]; then
docker-entrypoint.sh mysqld --server-id $SERVICE_ID --report-host ${REPORT_HOST} \
--ignore-db-dir=lost+found \
--plugin-load-add=rpl_semi_sync_master=semisync_master.so \
--plugin-load-add=rpl_semi_sync_slave=semisync_slave.so \
--plugin-load-add=audit_log=audit_log.so \
--log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \
--log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \
--skip-slave-start=$skip_slave_start
elif [ "${MYSQL_MAJOR}" = '8.0' ]; then
docker-entrypoint.sh mysqld --server-id $SERVICE_ID --report-host ${REPORT_HOST} \
--plugin-load-add=rpl_semi_sync_source=semisync_source.so \
--plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \
--plugin-load-add=audit_log=audit_log.so \
--log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \
--log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \
--skip-slave-start=$skip_slave_start
else
echo "Unsupported MySQL version"
Expand Down
36 changes: 15 additions & 21 deletions addons/mysql/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ vars:
valueFrom:
clusterVarRef:
namespace: Required
- name: COMPONENT_NAME
valueFrom:
componentVarRef:
optional: false
shortName: Required
- name: CLUSTER_COMPONENT_NAME
valueFrom:
componentVarRef:
optional: false
componentName: Required
- name: MYSQL_ROOT_USER
valueFrom:
credentialVarRef:
Expand All @@ -134,10 +144,7 @@ lifecycleActions:
exec:
container: mysql
command:
- /tools/dbctl
- --config-path
- /tools/config/dbctl/components
- mysql
- /tools/syncerctl
- getrole
switchover:
exec:
Expand Down Expand Up @@ -168,18 +175,6 @@ roles:
volumeMounts:
- mountPath: /tools
name: tools
- command:
- cp
- -r
- /bin/dbctl
- /config
- /tools/
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.dbctl.repository }}:{{ .Values.image.dbctl.tag }}
imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }}
name: init-dbctl
volumeMounts:
- mountPath: /tools
name: tools
{{- end }}

{{- define "mysql-orc.spec.common"}}
Expand Down Expand Up @@ -245,7 +240,7 @@ vars:
valueFrom:
componentVarRef:
optional: false
componentName: Required
shortName: Required
- name: MYSQL_ROOT_USER
valueFrom:
credentialVarRef:
Expand Down Expand Up @@ -404,17 +399,17 @@ env:
value: orchestrator
- name: SERVICE_PORT
value: "3306"
- name: SYNCER_POD_NAME
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: SYNCER_POD_UID
- name: POD_UID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.uid
- name: SYNCER_POD_IP
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
Expand Down Expand Up @@ -448,6 +443,5 @@ volumeMounts:
{{- define "mysql.spec.runtime.images" -}}
init-jemalloc: {{ .Values.image.registry | default "docker.io" }}/apecloud/jemalloc:5.3.0
init-syncer: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.syncer.repository }}:{{ .Values.image.syncer.tag }}
init-dbctl: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.dbctl.repository }}:{{ .Values.image.dbctl.tag }}
mysql-exporter: {{ .Values.metrics.image.registry | default ( .Values.image.registry | default "docker.io" ) }}/{{ .Values.metrics.image.repository }}:{{ default .Values.metrics.image.tag }}
{{- end -}}
15 changes: 10 additions & 5 deletions addons/mysql/templates/cmpd-mysql57.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ spec:
if [ -f {{ .Values.dataMountPath }}/data/.restore_new_cluster ]; then
skip_slave_start="ON"
fi
SERVICE_ID=$((${SYNCER_POD_NAME##*-} + 1))
SERVICE_ID=$((${POD_NAME##*-} + 1))
docker-entrypoint.sh mysqld --server-id $SERVICE_ID \
--ignore-db-dir=lost+found \
--plugin-load-add=rpl_semi_sync_master=semisync_master.so \
--plugin-load-add=rpl_semi_sync_slave=semisync_slave.so \
--plugin-load-add=audit_log=audit_log.so \
--log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \
--log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \
--skip-slave-start=$skip_slave_start
volumeMounts:
- mountPath: {{ .Values.dataMountPath }}
Expand All @@ -106,17 +106,22 @@ spec:
value: {{ .Values.auth.rootHost | default "%" | quote }}
- name: SERVICE_PORT
value: "3306"
- name: SYNCER_POD_NAME
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: SYNCER_POD_UID
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: POD_UID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.uid
- name: SYNCER_POD_IP
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
Expand Down
15 changes: 10 additions & 5 deletions addons/mysql/templates/cmpd-mysql80.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ spec:
if [ -f {{ .Values.dataMountPath }}/data/.restore_new_cluster ]; then
skip_slave_start="ON"
fi
SERVICE_ID=$((${SYNCER_POD_NAME##*-} + 1))
SERVICE_ID=$((${POD_NAME##*-} + 1))
docker-entrypoint.sh mysqld --server-id $SERVICE_ID \
--plugin-load-add=rpl_semi_sync_source=semisync_source.so \
--plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \
--plugin-load-add=audit_log=audit_log.so \
--log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \
--log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \
--skip-slave-start=$skip_slave_start
volumeMounts:
- mountPath: {{ .Values.dataMountPath }}
Expand All @@ -105,17 +105,22 @@ spec:
value: {{ .Values.auth.rootHost | default "%" | quote }}
- name: SERVICE_PORT
value: "3306"
- name: SYNCER_POD_NAME
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: SYNCER_POD_UID
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: POD_UID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.uid
- name: SYNCER_POD_IP
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
Expand Down
15 changes: 10 additions & 5 deletions addons/mysql/templates/cmpd-mysql84.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ spec:
if [ -f {{ .Values.dataMountPath }}/data/.restore_new_cluster ]; then
skip_slave_start="ON"
fi
SERVICE_ID=$((${SYNCER_POD_NAME##*-} + 1))
SERVICE_ID=$((${POD_NAME##*-} + 1))
docker-entrypoint.sh mysqld --server-id $SERVICE_ID \
--plugin-load-add=rpl_semi_sync_source=semisync_source.so \
--plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \
--log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \
--log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \
--skip-slave-start=$skip_slave_start
volumeMounts:
- mountPath: {{ .Values.dataMountPath }}
Expand All @@ -92,17 +92,22 @@ spec:
value: {{ .Values.auth.rootHost | default "%" | quote }}
- name: SERVICE_PORT
value: "3306"
- name: SYNCER_POD_NAME
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: SYNCER_POD_UID
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: POD_UID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.uid
- name: SYNCER_POD_IP
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
Expand Down
5 changes: 1 addition & 4 deletions addons/mysql/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ image:
repository: apecloud/percona-xtrabackup
syncer:
repository: apecloud/syncer
tag: 0.3.8
dbctl:
repository: apecloud/dbctl
tag: 0.1.5
tag: 0.4.1
# refer: addons/mysql/orc-tools/Dockerfile
orcTools:
repository: apecloud/orc-tools
Expand Down

0 comments on commit 6ca8d49

Please sign in to comment.