Skip to content

Commit

Permalink
chore: update canal-server application.
Browse files Browse the repository at this point in the history
release version 0.0.2.
  • Loading branch information
dellnoantechnp committed May 29, 2023
1 parent ebb1aba commit e105f34
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 308 deletions.
2 changes: 1 addition & 1 deletion charts/canal-server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.1
version: 0.0.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
20 changes: 15 additions & 5 deletions charts/canal-server/configs/canal.properties
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,17 @@ canal.instance.get.ddl.isolation=false
canal.instance.parser.parallel=true

## concurrent thread number, default 60% available processors, suggest not to exceed Runtime.getRuntime().availableProcessors()
{{- if .Values.ServerConf.instanceParserParallelThreadSize }}
canal.instance.parser.parallelThreadSize = {{ .Values.ServerConf.instanceParserParallelThreadSize }}
{{- else }}
#canal.instance.parser.parallelThreadSize = 16
{{- end }}

## disruptor ringbuffer size, must be power of 2
canal.instance.parser.parallelBufferSize=256

# table meta tsdb info
canal.instance.tsdb.enable={{ .Values.TsdbDBConf.enabled }}
canal.instance.tsdb.enable={{ .Values.TsdbDBConf.enabled | default "false" }}
canal.instance.tsdb.dir=${canal.file.data.dir:../conf}/${canal.instance.destination:}
{{- if .Values.TsdbDBConf.enabled }}
canal.instance.tsdb.url=jdbc:mysql://{{ .Values.TsdbDBConf.canal_tsdb_mysql_address }}:{{ .Values.TsdbDBConf.canal_tsdb_mysql_port }}/{{ .Values.TsdbDBConf.canal_tsdb_db_name }}?characterEncoding=utf-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=UTC
Expand Down Expand Up @@ -124,15 +128,21 @@ canal.auto.scan.interval=5

# set this value to 'true' means that when binlog pos not found, skip to latest.
# WARN: pls keep 'false' in production env, or if you know what you want.
canal.auto.reset.latest.pos.mode=false
#canal.instance.tsdb.spring.xml = classpath:spring/tsdb/h2-tsdb.xml
canal.auto.reset.latest.pos.mode={{ .Values.ServerConf.autoResetLatestPosMode | default "false" }}
{{- if .Values.TsdbDBConf.enabled }}
canal.instance.tsdb.spring.xml=classpath:spring/tsdb/mysql-tsdb.xml
{{- else }}
canal.instance.tsdb.spring.xml = classpath:spring/tsdb/h2-tsdb.xml
{{- end }}
canal.instance.global.mode=spring
canal.instance.global.lazy=false
canal.instance.global.manager.address=${canal.admin.manager}
#canal.instance.global.spring.xml = classpath:spring/memory-instance.xml
{{- if include "zkServers" . }}
canal.instance.global.spring.xml = classpath:spring/default-instance.xml
{{- else }}
canal.instance.global.spring.xml=classpath:spring/file-instance.xml
#canal.instance.global.spring.xml = classpath:spring/default-instance.xml
{{- end }}
#canal.instance.global.spring.xml = classpath:spring/memory-instance.xml

##################################################
######### MQ Properties #############
Expand Down
37 changes: 23 additions & 14 deletions charts/canal-server/configs/instance.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,50 @@ canal.instance.mysql.slaveId={{ .item.mysql.slaveId.number }}
canal.instance.gtidon={{ .item.gtidon }}
# position info
canal.instance.master.address={{ .item.master.address }}
canal.instance.master.journal.name=
canal.instance.master.position=
canal.instance.master.timestamp=
canal.instance.master.gtid=
canal.instance.master.journal.name={{ .item.master.journalName }}
canal.instance.master.position={{ .item.master.position }}
canal.instance.master.timestamp={{ .item.master.timestamp }}
canal.instance.master.gtid={{ .item.master.gtid }}

# rds oss binlog
canal.instance.rds.accesskey=
canal.instance.rds.secretkey=
canal.instance.rds.instanceId=

# table meta tsdb info
canal.instance.tsdb.enable=true
canal.instance.tsdb.enable={{ $.Values.TsdbDBConf.enabled }}
#canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb?characterEncoding=utf-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=UTC
#canal.instance.tsdb.dbUsername=canal
#canal.instance.tsdb.dbPassword=canal
#canal.instance.standby.address =
#canal.instance.standby.journal.name =
#canal.instance.standby.position =
#canal.instance.standby.timestamp =
#canal.instance.standby.gtid=

## Standby mysql instance
{{- if .item.standby.enabled }}
canal.instance.standby.address = {{ .item.standby.address }}
canal.instance.standby.journal.name={{ .item.standby.journalName }}
canal.instance.standby.position={{ .item.standby.position }}
canal.instance.standby.timestamp={{ .item.standby.timestamp }}
canal.instance.standby.gtid={{ .item.standby.gtid }}
{{- end }}

{{- if .item.standby.enabled }}
{{ include "canal.instance.enable.detection" . }}
{{- end }}


# username/password
canal.instance.dbUsername={{ .item.dbUsername | quote }}
canal.instance.dbPassword={{ .item.dbPassword | quote }}
canal.instance.dbUsername={{ .item.dbUsername }}
canal.instance.dbPassword={{ .item.dbPassword }}
canal.instance.connectionCharset=UTF-8

# enable druid Decrypt database password
canal.instance.enableDruid=false
#canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==

# table regex
canal.instance.filter.regex={{ .item.filter.regex }}
canal.instance.filter.regex={{ .item.filter.regex | quote }}

# table black regex
canal.instance.filter.black.regex={{ .item.filter.black.regex }}
canal.instance.filter.black.regex={{ .item.filter.black.regex | quote }}

# table field filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
#canal.instance.filter.field=test1.t_product:id/subject/keywords,test2.t_company:id/name/contact/ch
Expand Down
33 changes: 32 additions & 1 deletion charts/canal-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}
APP VERSION: {{ .Chart.AppVersion }}

1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
Expand All @@ -17,6 +21,33 @@
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "canal-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
echo "canal-client connect 127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}

2. Set instance name to use by canal-client:
{{- range .Values.InstanceConf.canal.instance }}
- Instance name: {{ .name }}
+- Sync master from: {{ .master.address }}
{{- if .standby.enabled }}
+- Sync standby from: {{ .standby.address }}
+- Enabled HA: {{ .standby.enabled }}
{{- end }}
{{- if ne .filter.regex ".*\\..*" }}
+- filter: {{ .filter.regex | quote }}
\- black: {{ .filter.black.regex | quote }}
{{- end }}
{{- end }}

3. Tsdb information:
{{- if .Values.TsdbDBConf.enabled }}
mysql: {{ .Values.TsdbDBConf.canal_tsdb_mysql_address }}:{{ .Values.TsdbDBConf.canal_tsdb_mysql_port }}/{{ .Values.TsdbDBConf.canal_tsdb_db_name }}
{{- else }}
local h2.
{{- end }}

{{- if (include "zkServers" .) }}
4. canal-client use example

CanalConnector connector = CanalConnectors.newClusterConnector("zkServers:2181", "example-instance", "", "");
{{- end }}
13 changes: 13 additions & 0 deletions charts/canal-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,17 @@ return canal-server instance instance.properties mount resouce string.
subPath: {{ .name }}-instance.properties
name: config
{{- end }}
{{- end }}

{{/*
canal-server instance HA detection config.
*/}}
{{- define "canal.instance.enable.detection" }}
## heartbeat instance HA config
canal.instance.detecting.enable=true
#canal.instance.detecting.sql = insert into retl.xdual values(1,now()) on duplicate key update x=now()
canal.instance.detecting.sql=select 1
canal.instance.detecting.interval.time=3
canal.instance.detecting.retry.threshold=3
canal.instance.detecting.heartbeatHaEnable=true
{{- end }}
2 changes: 1 addition & 1 deletion charts/canal-server/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data:
{{- range $key, $values := .Values.InstanceConf.canal.instance }}
{{- $_ := set $ "item" $values }}
{{ $values.name }}-instance.properties: |
{{- tpl ($.Files.Get "configs/instance.properties") $ | indent 4 }}
{{ tpl ($.Files.Get "configs/instance.properties") $ | indent 4 }}
{{- end }}
canal.properties: |
{{ tpl ($.Files.Get "configs/canal.properties") $ | indent 4 }}
11 changes: 10 additions & 1 deletion charts/canal-server/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@ metadata:
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.ports.canal }}
- port: {{ .Values.service.ports.canal.port }}
targetPort: tcp-canal
protocol: TCP
name: tcp-canal
{{- if and (contains .Values.service.type "NodePort") (typeIs "int" .Values.service.ports.canal.nodePort) }}
nodePort: {{ .Values.service.ports.canal.nodePort }}
{{- end }}
- port: {{ .Values.service.ports.admin }}
targetPort: tcp-admin
protocol: TCP
name: tcp-admin
{{- if and (contains .Values.service.type "NodePort") (typeIs "int" .Values.service.ports.admin.nodePort) }}
nodePort: {{ .Values.service.ports.admin.nodePort }}
{{- end }}
- port: {{ .Values.service.ports.metrics }}
targetPort: http-metrics
protocol: TCP
name: http-metrics
{{- if and (contains .Values.service.type "NodePort") (typeIs "int" .Values.service.ports.metrics.nodePort) }}
nodePort: {{ .Values.service.ports.metrics.nodePort }}
{{- end }}
selector:
{{- include "canal-server.selectorLabels" . | nindent 4 }}
Loading

0 comments on commit e105f34

Please sign in to comment.