NFS服务搭建
准备两台虚拟机,服务端和客户端。
IP分别是192.168.1.145 192.168.1.234
操作服务端:
[root@localhost ~]# yum -y install nfs-utils rpcbind
编辑配置文件。
[root@localhost ~]# vim /etc/exports
[root@localhost ~]# cat /etc/exports
/home/xxx 192.168.1.234(rw)
[root@localhost ~]# mkdir /home/xxx
[root@localhost ~]# chmod 777 /home/xxx
开启服务(开启顺序不能变)。
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs
关闭防火墙,降低沙盒。
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
操作客户端:
[root@localhost ~]# yum -y install nfs-utils rpcbind
开启服务。
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs
查看虚拟机能否连通。
[root@localhost ~]# ping 192.168.1.145
PING 192.168.1.145 (192.168.1.145) 56(84) bytes of data.
64 bytes from 192.168.1.145: icmp_seq=1 ttl=64 time=2.91 ms
64 bytes from 192.168.1.145: icmp_seq=2 ttl=64 time=1.60 ms
64 bytes from 192.168.1.145: icmp_seq=3 ttl=64 time=0.504 ms
连接服务端IP。
[root@localhost ~]# showmount -e 192.168.1.145
Export list for 192.168.1.145:
/home/xxx 192.168.1.234
关闭防火墙,降低沙盒。
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
挂载服务端的共享目录并用df查看。
[root@localhost ~]# mount -t nfs 192.168.1.145:/home/xxx /mnt
[root@localhost ~]# df -h
附:如要重启服务要先关闭rpcbind,再关闭nfs,之后开启rpcbind后开启nfs,顺序不能错。