关于解决K8S部署mysql报错chown: changing ownership of ‘/var/lib/mysql/‘: Operation not permitted的问题
原创
©著作权归作者所有:来自51CTO博客作者fong1221的原创作品,请联系作者获取转载授权,否则将追究法律责任
1、现象
[root@master mysql]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
mysql-6c759bf84c-6jj6v 0/1 CrashLoopBackOff 6 7m18s 10.244.1.36 node1 <none> <none>
2、日志分析
[root@master mysql]# kubectl logs -f mysql-6c759bf84c-6jj6v
[Entrypoint] MySQL Docker Image 5.7.31-1.1.17
chown: changing ownership of '/var/lib/mysql/': Operation not permitted
3、解决办法
K8S环境 NFS做持久化,在NFS做共享时,添加no_root_squash权限
[root@master mysql]# cat /etc/exports
/home/nfsdata/ *(rw,sync,no_all_squash)
[root@master mysql]# cat /etc/exports
/home/nfsdata/ *(rw,sync,no_root_squash)
[root@master mysql]# systemctl restart rpcbind
[root@master mysql]# systemctl restart nfs