moco
moco copied to clipboard
How to specify lower_case_table_names=1 for mysqld --initialize
This is the only block to migrate our bitnami mysql to wonderful moco.
Sorry for the late reply. I'm confirming this, so please wait a moment.
@uqix
Sorry for the late reply.
Unfortunately, there is no official way to specify lower_case_table_names=1
at this time.
I want to enable to specify it, but it to take a while.
As a temporary workaround, if you build a custom MySQL image with the following Dockerfile and patch file, you can use lower_case_table_names=1
.
Dockerfile
# Build the patched moco-init binary.
FROM quay.io/cybozu/golang:1.18-focal as builder
WORKDIR /work
COPY ./moco-init.patch .
RUN git clone --depth 1 https://github.com/cybozu/neco-containers.git
RUN cd ./neco-containers/ && patch -p1 < ../moco-init.patch
RUN cd ./neco-containers/mysql/moco-init && go build -ldflags="-w -s" -o /work/moco-init .
# Overwrite the original moco-init.
FROM quay.io/cybozu/mysql:8.0.28
COPY --from=builder /work/moco-init /usr/local/mysql/bin/
moco-init.patch
diff --git a/mysql/moco-init/main.go b/mysql/moco-init/main.go
index fd3933cc..3aaf4ff0 100644
--- a/mysql/moco-init/main.go
+++ b/mysql/moco-init/main.go
@@ -102,7 +102,7 @@ func initMySQL(mysqld string) error {
return fmt.Errorf("failed to remove dir %s: %w", dataDir, err)
}
- cmd := exec.Command(mysqld, "--basedir="+config.baseDir, "--datadir="+dataDir, "--initialize-insecure")
+ cmd := exec.Command(mysqld, "--basedir="+config.baseDir, "--datadir="+dataDir, "--initialize-insecure", "--lower_case_table_names=1", "--log-error-verbosity=3")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
The options for mysqld --initialize-insecure
are specified in moco-init, which is contained in MOCO's MySQL images.
So as a simple solution, we just modify the moco-init.
But the changes of moco-init may break existing MySQLClusters. So it requires attention and takes time.
Just wondering is it feasible to specify --lower_case_table_names=1
by env vars of moco-init container?
That's a good suggestion. Please wait for a little. Currently, we try making the moco-init under version control to address this issue.
Glad to hear that, take your time.
@uqix I apologize for the very late reply...
Currently, MOCO accepts lower_case_table_names
.
Please try it if you have the chance.
apiVersion: v1
kind: ConfigMap
metadata:
name: myconf
data:
lower_case_table_names: "1"
---
apiVersion: moco.cybozu.com/v1beta2
kind: MySQLCluster
...
spec:
mysqlConfigMapName: myconf
...