[nfs无法挂载问题] mount.nfs: access denied by server while mounting localhost:/data/dev/mysql
centos 7 使用nfs挂载数据卷时出现报错:localhost kubelet: mount.nfs: access denied by server while mounting localhost:/data/dev/mysql执行Create时,mysql容器一直处于creating状态,mysql-dev-nfs.yamlapiVersion: v1kind: Replication
centos 7 使用nfs挂载数据卷时出现报错:localhost kubelet: mount.nfs: access denied by server while mounting localhost:/data/dev/mysql
执行Create时,mysql容器一直处于creating状态,mysql-dev-nfs.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: mysql-dev
labels:
name: mysql-dev
spec:
replicas: 1
selector:
name: mysql-dev
template:
metadata:
labels:
name: mysql-dev
spec:
containers:
- name: mysql
image: nacos/nacos-mysql:5.7
ports:
- containerPort: 3307
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: "root"
- name: MYSQL_DATABASE
value: "nacos_devtest"
- name: MYSQL_USER
value: "nacos"
- name: MYSQL_PASSWORD
value: "nacos"
volumes:
- name: mysql-data
nfs:
server: localhost
path: /data/dev/mysql
---
apiVersion: v1
kind: Service
metadata:
name: mysql-dev
labels:
name: mysql-dev
spec:
ports:
- port: 3307
targetPort: 3307
nodePort: 30070
selector:
name: mysql-dev
type: NodePort
我想把mysql-data挂载到本机的/data/dev/mysql目录下,使用命令 cat /var/log/messages | grep mount 查看mount相关的日志, 上面一直报错access denied, 下面是解决问题后的日志。
解决方法:
1. 检查系统中是否装有有nfs service, 可使用systemctl status <service_name>查看。
2. 将挂载的目录设置为insecure属性, 执行命令
vim /etc/exports
添加如下内容,表示给/data目录赋予权限和insecure。
/data *(insecure,rw,async,no_root_squash)
编辑完后,保存,重启nfs service。
systemctl restart nfs
3. 重新执行 kubectl apply -f service 命令,查看pods是否正常运行。
更多推荐
所有评论(0)