手动搭建一个nfs服务器

  • 开放/nfs/shared目录,供所有用户查阅资料
  • 开放/nfs/upload目录为172.16.12.0、24网段的数据上传目录,并将所有用户及所属的用户组都映射为nfs-upload,其UID与GID均为300

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里面的数据了。

猜你喜欢

转载自blog.51cto.com/13945839/2173711