Temporal connectivity with MySQL

Hi Team,
I want to connect my existing mysql database into the temporal Instead of Cassandra. I configured the mysql credentials in values.mysql.yaml file like this

server:
  config:
    persistence:
      default:
        driver: "sql"

        sql:
          driver: "mysql"
          host: localhost
          port: 3306
          database: database name
          user: xyz
          password: xyz
          maxConns: 20
          maxConnLifetime: "1h"

      visibility:
        driver: "sql"

        sql:
          driver: "mysql"
          host: localhost
          port: 3306
          database: database name
          user: xyz
          password: xyz
          maxConns: 20
          maxConnLifetime: "1h"

cassandra:
  enabled: false

mysql:
  enabled: true

postgresql:
  enabled: false

schema:
  setup:
    enabled: false
  update:
    enabled: false

I enabled mysql into true and cassandra, elasticsearch, prometheus, grafana and postgresql into false and i try to install by using the command

helm install -f values/values.mysql.yaml temporaltest . --timeout 900s

also i tried with the another command

helm install -f values/values.mysql.yaml temporaltest \
  --set elasticsearch.enabled=false \
  --set server.config.persistence.default.sql.user=mysql_user \
  --set server.config.persistence.default.sql.password=mysql_password \
  --set server.config.persistence.visibility.sql.user=mysql_user \
  --set server.config.persistence.visibility.sql.password=mysql_password \
  --set server.config.persistence.default.sql.host=mysql_host \
  --set server.config.persistence.visibility.sql.host=mysql_host . --timeout 900s

By using the above commands the chart is deployed but all the pod is in crashloopbackoff and pending state.
Can you please suggest some ideas to connect the existing mysql into the temporal.

Hi, where is your db running, locally on machine, docker or your k8s/minikube cluster?

Hi @tihomir my DB is running locally

Depending what you are running on you would need to enable host access. I tested with minikube and was able to use host.minikube.internal as the sql host:

helm install -f values/values.mysql.yaml temporaltest \
  --set elasticsearch.enabled=false \
  --set prometheus.enabled=false \
  --set grafana.enabled=false \
  --set server.config.persistence.default.sql.user=myuser \
  --set server.config.persistence.default.sql.password=mypassword \
  --set server.config.persistence.visibility.sql.user=myuser \
  --set server.config.persistence.visibility.sql.password=mypassword \
  --set server.config.persistence.default.sql.host=host.minikube.internal \
  --set server.config.persistence.visibility.sql.host=host.minikube.internal . --timeout 900s

Just make sure that locally your mysql user has a non-blank password (if you use root by default its blank so make sure you set it to something) cause there seems to be a small issue with having blank password for sql in helm charts atm, investigating.

Hi @tihomir
Thanks for your reply, I configured the MySQL DB in minikube cluster but when i try to install temporal-sql-tool it showing an error. Can you please suggest some ideas to configure the temporal-sql-tool.

Whats the error you are getting?
Assume you cloned temporal server repo
and ran

make install

from it, right?

Hi @tihomir
Yeah I clone the repo and run the command

export SQL_PLUGIN=mysql
export SQL_HOST=mysql_host
export SQL_PORT=3306
export SQL_USER=mysql_user
export SQL_PASSWORD=mysql_password
SQL_USER=$SQL_USER SQL_PASSWORD=$SQL_PASSWORD make install-schema-mysql
 Run `make

when I ran the install schema mysql command I facing error like this

$ SQL_USER=$SQL_USER SQL_PASSWORD=$SQL_PASSWORD make install-schema-mysql
process_begin: CreateProcess(NULL, go env GOBIN, ...) failed.
Makefile:48: pipe: No error
process_begin: CreateProcess(NULL, go env GOPATH, ...) failed.
Makefile:48: pipe: No error
process_begin: CreateProcess(NULL, go env GOPATH, ...) failed.
Makefile:69: pipe: Bad file descriptor
process_begin: CreateProcess(NULL, go env GOOS, ...) failed.
Makefile:409: pipe: Bad file descriptor
process_begin: CreateProcess(NULL, go env GOOS, ...) failed.
Makefile:410: pipe: Bad file descriptor
process_begin: CreateProcess(NULL, go env GOOS, ...) failed.
Makefile:201: pipe: No such file or directory
process_begin: CreateProcess(NULL, go env GOARCH, ...) failed.
Makefile:201: pipe: No such file or directory
Build temporal-sql-tool with CGO_ENABLED=0 for /...
CGO_ENABLED=0 go build -o temporal-sql-tool ./cmd/tools/sql
/usr/bin/sh: go: command not found
make: *** [Makefile:202: temporal-sql-tool] Error 127

I couldn’t able to install temporal-sql-tool

Can you check that you have GOROOT system var on your system?
echo $GOROOT

Can you compile all the tools by just running make ?

make install-schema-mysql requires temporal db user to exist and you would need to set TEMPORAL_DB and VISIBILITY_DB env vars before running it.

If you are able to just run make to build all tools you can follow the scripts in helm chart repo here.

Hope this helps.

Hi @tihomir
When I run the command make install-schema-mysql I’m facing the error like this.

Build temporal-sql-tool with CGO_ENABLED=0 for windows/amd64...
CGO_ENABLED=0 go build -o temporal-sql-tool ./cmd/tools/sql
error obtaining VCS status: exit status 0xc000007b
        Use -buildvcs=false to disable VCS stamping.
make: *** [Makefile:207: temporal-sql-tool] Error 1

I try with -buildvcs=false command also but the error is not resolved

Hi @tihomir MySQL connectivity issue is resolved now but when i try to deploy a chart using this command

helm install  --set server.replicaCount=1  --set cassandra.config.cluster_size=1 --set prometheus.enabled=false  --set grafana.enabled=false  --set elasticsearch.enabled=false   temporal-server . --timeout 15m 

I enabled Cassandra=false
I enabled MySQL = true in values.yaml
and configure the values.mysql.yaml and deployed using the above command but i got an error like this

Please specify cassandra port for default store

Hi @tihomir
Do we need cassandra to be enabled while installing Mysql ?
Will Mysql spin into separate pod ?

Do we need cassandra to be enabled while installing Mysql ?

No you should not need to have cassandra enabled as you are not using it. You can use value flag as shown in previous reply and use values_mysql.yaml to overwrite defaults set in values.yaml.

Will Mysql spin into separate pod ?

Should not, you mentioned you want to use local mysql right?

Thank you @tihomir

Having the same error Please specify cassandra port for visibility store here but I’m using a cloudsql proxy sidecar container so I’m trying to install temporal disabling Cassandra like this:

helm install -f values/values.cloudsqlproxy.yaml -n temporal \
    --set cassandra.enabled=false \
    --set prometheus.enabled=true \
    --set grafana.enabled=false \
    --set elasticsearch.enabled=true \
    temporal . --timeout 900s

How can I make that work?