K8S 配置mysql配置文件不生效問題處理

平臺使用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 <integer>
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的配置文件並不可以~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章