1:服务器端:
[root@languang ~]# mkdir /nfsfile
[root@languang ~]# chmod 777 /nfsfile/
[root@languang ~]# echo "welcome to nfs" > /nfsfile/readme.txt
[root@languang ~]# vim /etc/exports (加上以下内容)
/nfsfile 192.168.0.*(rw,sync,root_squash)
[root@languang ~]# firewall-cmd --permanent --add-service=nfs
success
[root@languang ~]# firewall-cmd --permanent --add-service=mountd
success
[root@languang ~]# firewall-cmd --permanent --add-service=rpc-bind
success
[root@languang ~]# systemctl restart firewalld.service
[root@languang ~]# systemctl restart rpcbind.socket
[root@languang ~]# systemctl enable rpcbind.socket
[root@languang ~]# systemctl restart nfs-server
[root@languang ~]# systemctl enable nfs-server
完成!
2:客户端
[root@www ~]# showmount -e 192.168.0.66
Export list for 192.168.0.66:
/nfsfile 192.168.0.*
echo "192.168.0.188:/nfsfile /nfsfile nfs defaults 0 0" >> /etc/fstab
完成!
3:自动挂载autofs
[root@localhost ~]# yum install autofs
[root@localhost ~]# vim /etc/auto.master(主配置文件添加挂载目录的上一级目录 (空格)子配置文件目录)
/media /etc/iso.misc
[root@localhost ~]# vim /etc/iso.misc(子配置文件添加 挂载目录(空格)-文件系统类型,权限信息(空格):被挂载目录)
iso -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
测试,完成!
如挂载nfs网络文件
[root@localhost ~]# yum install autofs
[root@localhost ~]# vim /etc/auto.master
/nfs /etc/nfs.misc
[root@localhost ~]# vim /etc/nfs.misc
nfsfile -fstype=nfs,rw,sync,root_squash 192.168.0.188:/nfsfile
测试,完成!
挂载超时时间修改在 /etc/sysconfig/autofs
DEFAULT_TIMEOUT=300