平台使用Rancher 2.x

问题原因是,一个测试用的mysql需要开启binlog日志,我想着这个不是挺简单的嘛~

于是,配置了一个config,挂载到对应的mysql配置文件下,然后重新部署一下~

然而进容器一看,配置文件是挂载上了,可是配置却未生效。。

具体如下:

1、因为使用Rancher平台,所以配置及挂载这一步是在web端进行的(祸根。)。

即添加一个configmap,覆盖掉原配置文件:

#开启binlog日志的配置文件~

[mysqld]

pid-file = /var/run/mysqld/mysqld.pid

socket = /var/run/mysqld/mysqld.sock

datadir = /var/lib/mysql

#log-error = /var/log/mysql/error.log

#By default we only accept connections from localhost

#bind-address = 127.0.0.1

#Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-bin=/var/lib/mysql/mysql-bin

server-id=1

挂载到mysql的/etc/mysql/mysql.conf.d/下,覆盖掉mysqld.cnf

2、然鹅并没生效,配置文件确实挂载了,有点怀疑人生...

3、于是修改其他配置,修改其他配置查看是不是binlog配置问题(怀疑人生。)

即随便修改了下datadir的路径:

[mysqld]

pid-file = /var/run/mysqld/mysqld.pid

socket = /var/run/mysqld/mysqld.sock

datadir = /home/mysql

#log-error = /var/log/mysql/error.log

#By default we only accept connections from localhost

#bind-address = 127.0.0.1

#Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-bin=/var/lib/mysql/mysql-bin

server-id=1

4、然后发现配置文件依然挂载了,这个也没生效!!!

5、查看yaml文件,如下:

- configMap:

defaultMode: 292

name: mysql-config

optional: false

name: vol1

查看configMap的defaultMode:

kubectl explain deployment.spec.template.spec.volumes.configmag

defaultMode

Optional: mode bits to use on created files by default. Must be a value

between 0 and 0777. Defaults to 0644. Directories within the path are not

affected by this setting. This might be in conflict with other options that

affect the file mode, like fsGroup, and the result can be other mode bits

set.

6、对照查看,发现Rancher默认模式为400,修改成644后,重新部署~可以了!

之前nginx的配置使用默认模式400可以生效,mysql的配置文件并不可以~

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐