1:rpm 没有安装包的先下载 nfs-utils 安装包安装, nfs 的安装和启动
安装软件包: yum -y install nfs-utils
启动 nfs 服务: systemctl start rpcbind nfs-server
查看一下服务进程启动没有;
- [root@localhost ~]# ss -antl
- State Recv-Q Send-Q Local Address:Port Peer Address:Port
- LISTEN 0 128 :111:LISTEN 0 128:20048 :
- LISTEN 0 128 :22:LISTEN 0 100 127.0.0.1:25:LISTEN 0 128:58651 :
- LISTEN 0 64 :38560:LISTEN 0 64:2049 :
- LISTEN 0 128 :::41899 :::LISTEN 0 128 :::111 :::
- LISTEN 0 128 :::20048 :::LISTEN 0 128 :::22 :::
- LISTEN 0 100 ::1:25 :::LISTEN 0 64 :::46558 :::
- LISTEN 0 64 :::2049 :::*
查看到 111 和 2049 就可以确定服务器启动了.
2 编辑 etc/exportfs
- [root@localhost ~]# vim /etc/exports
- /nfs/shared 172.16.12.128(ro,sync)
- /nfs/upload 172.16.12.0(anongid=300,anonuid=30 )
systemctl stop firewalld.service 关闭防火墙
exportfs -vr 在不重启的情况下启动这个配置文件并在屏幕上显示出来.
- root@localhost ~]# exportfs -vr
- /nfs/shared 172.16.12.128(ro,sync,wdelay,hide,no_subtree_check,sec=sys,secure,root_squash,no_all_squash)
3 显示指定的 NFS 服务器上说有输出的共享目录, 将主机的共享目录挂载到客户端的目录里面,
- root@localhost ~]# showmount -e
- Export list for localhost.localdomain:
- /nfs/shared 172.16.12.12
进入到客户端创建一个 nfs/shared 的目录
进行挂载 root@localhost ~]#mount --t nfs SERVER:/nfs/shared /nfs/shared
然后接下来进入到客户端 / nfs/shared 就能读取到主机共享目录 nfs/shared 里面的数据了.
来源: http://www.bubuko.com/infodetail-2763292.html