服务器下
关闭防火墙
[root@kvm-server ~]# systemctl stop firewalld
设置开机不启动
[root@kvm-server ~]# systemctl disable firewalld
安装软件包
[root@kvm-server ~]# yum -y install nfs-utils
启动
[root@kvm-server ~]#systemctl start nfs
[root@kvm-server ~]#systemctl enable nfs
1:以只读的方式共享
[root@kvm-server ~]# mkdir -p /share/dir1
[root@kvm-server ~]# chmod 757 /share/dir1
[root@kvm-server ~]# vim /etc/exports
/share/dir1 *(ro,sync) ro 只读
[root@kvm-server ~]# exportfs -rv //重新刷新共享
2:以读写的方式共享
[root@kvm-server ~]# mkdir -p /share/dir2
[root@kvm-server ~]# chmod 757 /share/dir2
[root@kvm-server ~]# vim /etc/exports
/share/dir2 192.168.122.238/24(rw,sync) rw 读写服务器IP地址
[root@kvm-server ~]# exportfs -rv
exporting 192.168.122.238/24:/share/dir2
exporting *:/share/dir1
客户端下测试
[root@gaojingbo ~]# showmount -e 192.168.122.238
Export list for 192.168.122.238:
/share/dir1 *
创建挂载点
[root@gaojingbo ~]# mkdir /mnt/nfs1
[root@gaojingbo ~]# mkdir /mnt/nfs2
[root@gaojingbo ~]# vim /etc/auto.master
/nfs2 /etc/auto.misc
[root@gaojingbo ~]# vim /etc/auto.misc
dir1 -ro 192.168.122.238:/share/dir1
dir2 -rw 192.168.122.238:/share/dir2
手动触发就可以自动挂载
[root@gaojingbo ~]# ls /nfs2/dir1
[root@gaojingbo ~]# ls /nfs2/dir2
[root@gaojingbo ~]# systemctl restart autofs
[root@gaojingbo ~]# chkconfig autofs on
[root@gaojingbo ~]# df
192.168.122.238:/share/dir2 99562048 3007360 96554688 4% /nfs2/dir2
192.168.122.238:/share/dir1 99562048 3007360 96554688 4% /nfs2/dir1
配置NFS即Network File System,Unix系统之间共享文件的一种协议,客户端主要是Linux
最新推荐文章于 2024-03-15 09:50:56 发布