CentOS 7 配置 nfs 和 autofs

深碍√TFBOYSˉ_ 2021-12-10 04:49 319阅读 0赞

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

转载于:https://www.cnblogs.com/languang9801/p/11104378.html

发表评论

表情:
评论列表 (有 0 条评论,319人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Centos7安装NFS

    简介 NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源。在NF