当前位置:网站首页>[nfs failed to mount problem] mount nfs: access denied by server while mounting localhost:/data/dev/mysql

[nfs failed to mount problem] mount nfs: access denied by server while mounting localhost:/data/dev/mysql

2022-06-22 19:38:00 Dream_ it_ possible!

        centos 7 Use nfs An error occurred while mounting the data volume :localhost kubelet: mount.nfs: access denied by server while mounting localhost:/data/dev/mysql

        perform Create when ,mysql The container has been in creating state ,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

        I want to put mysql-data Mount to this machine /data/dev/mysql Under the table of contents , Use command  cat /var/log/messages | grep mount see mount Related logs , It keeps reporting errors access denied, The following is the log after solving the problem .

resolvent :
1. Check whether the system is equipped with nfs service, You can use systemctl status  <service_name> see .

2. Set the mounted directory to insecure attribute , Carry out orders

vim  /etc/exports

Add the following , Said to /data Give permissions and permissions to the directory insecure.

/data *(insecure,rw,async,no_root_squash) 

After editing , preservation , restart nfs service. 

 systemctl restart nfs

 3. Re execution kubectl  apply -f  service command , see pods Is it working .

原网站

版权声明
本文为[Dream_ it_ possible!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221811556730.html