CentOS配置NFS

NFS共享及挂载

NFS服务端

1、安装nfs

yum -y install nfs-utils rpcbind

(小提示:在安装完nfs-utils后,rpcbind默认是启动了的。)

2、enable services设置开机启动nfs相关服务。

systemctl enable rpcbind
systemctl enable nfs-server 
systemctl enable nfs-lock
systemctl enable nfs-idmap

输入systemctl enable nfs-server后会报:Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.

3、启动nfs service

systemctl start rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap

4、创建需要共享的目录

mkdir -p /home/docker/images/
chmod -R 777 /home/docker/images/

5、配置需要共享的目录到 /etc/exports下,xxx.xxx.xxx.xxx为需要共享的对象ip地址。

echo "/application/share 10.200.3.*(rw,sync,no_root_squash)" >> /etc/exports
或
echo "/application/share 10.200.3.0/24(rw,sync,no_root_squash)" >> /etc/exports

exportfs -a          #使exports的修改生效

[root@nfs_server ~]# more /etc/exports
/application/share 192.168.0.*(rw,sync,no_root_squash)

6、检查共享目录是否设置正确

[root@nerve ~]# showmount -e
Export list for nerve:
/home/docker/images 10.200.3.*

7、调整防火墙配置

可使用 命令 iptables -L -n 查看开放的端口

[root@nfs_server ~]# firewall-cmd --add-service=nfs --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --add-service=mountd --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --add-service=rpc-bind --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --reload   重新载入配置,使其生效
success

NFS客户端

注意:客户端不需要启动nfs服务

1、安装nfs

yum -y install nfs-utils

2、检查共享目录是否设置正确,xxx.xxx.xxx.xxx 为共享服务器地址

[root@centos7 yum.repos.d]# showmount -e 10.200.3.93
Export list for 10.200.3.93:
/home/docker/images 10.200.3.*

3、挂载远程服务器NFS分区到本地挂载点

make mount points

mkdir -p /home/docker/images

mount nfs

mount -t nfs -o auto 10.200.3.93:/home/docker/images /home/docker/images

(开发板上的目录,注意挂载成功后,/home/docker/images下原有数据将会被隐藏,无法找到)

posted @ 2021-10-13 10:13  qtyanan  阅读(247)  评论(0编辑  收藏  举报