已解决
k8s部署mysql报错‘/var/lib/mysql/‘: Operation not permitted
来自网友在路上 172872提问 提问时间:2023-10-05 17:29:08阅读次数: 72
最佳答案 问答题库728位专家为你答疑解惑
前言
环境:k8s 1.22.6、nfs-server后端存储
部署mysql
kind: StatefulSet
apiVersion: apps/v1
metadata:name: mysql-hisnamespace: hislabels:app: mysql-hisannotations:kubesphere.io/alias-name: mysql-hiskubesphere.io/creator: dev-liukubesphere.io/description: his项目的数据库
spec:replicas: 1selector:matchLabels:app: mysql-histemplate:metadata:creationTimestamp: nulllabels:app: mysql-hisannotations:kubesphere.io/creator: dev-liukubesphere.io/imagepullsecrets: '{}'logging.kubesphere.io/logsidecar-config: '{}'spec:volumes:- name: host-timehostPath:path: /etc/localtimetype: ''containers:- name: container-91dh9aimage: 'mysql:5.7.35'ports:- name: tcp-3306containerPort: 3306protocol: TCP- name: tcp-33060containerPort: 33060protocol: TCPenv:- name: MYSQL_ROOT_PASSWORDvalue: Aa123456resources: {}volumeMounts:- name: host-timemountPath: /etc/localtime- name: mysql-hismountPath: /var/lib/mysqlterminationMessagePath: /dev/termination-logterminationMessagePolicy: FileimagePullPolicy: IfNotPresentsecurityContext:privileged: truerestartPolicy: AlwaysterminationGracePeriodSeconds: 30dnsPolicy: ClusterFirstserviceAccountName: defaultserviceAccount: defaultsecurityContext:runAsNonRoot: falseschedulerName: default-schedulervolumeClaimTemplates:- kind: PersistentVolumeClaimapiVersion: v1metadata:name: mysql-hisnamespace: hiscreationTimestamp: nullspec:accessModes:- ReadWriteOnceresources:requests:storage: 1GistorageClassName: nfs-storageclassvolumeMode: Filesystemstatus:phase: PendingserviceName: mysql-his-6kpepodManagementPolicy: OrderedReadyupdateStrategy:type: RollingUpdaterollingUpdate:partition: 0revisionHistoryLimit: 10
报错
#创建sts之后,pod启动报错,日志如下
[root@master01 ~]# kubectl -n his logs mysql-his-0
2023-10-05 15:41:02+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.35-1debian10 started.
chown: changing ownership of '/var/lib/mysql/': Operation not permitted
[root@master01 ~]#
解决办法
#测试使用docker启动mysql,可以正常启动
mysql -p /my/own/datadir
docker run --name mysql -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Aa123456 -d mysql:5.7.35#最后问题定位为后端存储nfs配置存在错误。
#查看nfs配置:
[root@master01 k8s]# cat /etc/exports
/data/k8s *(rw,sync)
#添加一个参数:
[root@master01 k8s]# cat /etc/exports
/data/k8s *(rw,sync,no_root_squash)
[root@master01 k8s]# exportfs -rv #使配置立即生效,也可以systemctl reload nfs-server.service
#最后重新创建mysql pod,pod正常,问题解决
查看全文
99%的人还看了
相似问题
- conda创建pytorch环境报错
- Python通过selenium调用IE11浏览器报错解决方法
- kafka本地安装报错
- 【BUG】第一次创建vue3+vite项目启动报错Error: Cannot find module ‘worker_threads‘
- git 构建报错
- Docker build报错总结,版本过新大避雷!
- Mongodb3.4升级高版本mongoTemplate.executeCommand报错The cursor option is required
- duplicate复制数据库单个数据文件复制失败报错rman-03009 ora-03113
- 安装第三方包报错 error: Microsoft Visual C++ 14.0 or greater is required——解决办法
- 邮件|gitpushgithub报错|Lombok注解
猜你感兴趣
版权申明
本文"k8s部署mysql报错‘/var/lib/mysql/‘: Operation not permitted":http://eshow365.cn/6-15894-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!
- 上一篇: 开题报告 PPT 应该怎么做
- 下一篇: 做好微信CRM,这些功能你不可不知!