系统版本:CentOS Linux release 7.5.1804 (Core)
nfs版本:nfs-utils-2.3.2
服务器设置:
安装前先关闭防火墙和selinux
systemctl stop firewalld
setenforce 0
1、先解决依赖关系
# yum -y install libwrap libwrap-devel libtirpc libtirpc-devel libevent libevent-devel device-mapper-event-libs device-mapper-libs libdevmapper libdevmapper-devel device-mapper-devel libblkid libblkid-devel dh-autoreconf rpcbind redhat-lsb initscripts libnfs-utils
2、下载软件、解压并编译
# wget https://downloads.sourceforge.net/nfs/nfs-utils-2.3.2.tar.xz
# xz -d nfs-utils-2.3.2.tar.xz
# tar xvf nfs-utils-2.3.2.tar
# cd nfs-utils-2.3.2
# sed -i '/strict-prototypes/d' configure.ac
# autoreconf -fiv
# ./configure --prefix=/data/server/nfs
--sysconfdir=/etc
--sbindir=/usr/sbin
--without-tcp-wrappers
--disable-nfsv4
--disable-gss
# make && make install
–without-tcp-wrappers:由于TCP包装器不在BLFS中,因此需要此选项。
–disable-nfsv4:这允许在libnfsidmap尚未安装时构建软件包。
–disable-gss:禁用对RPCSEC GSS(RPC安全性)的支持。
3、修改权限及创建共享的文件夹
# chmod u+w,go+r /sbin/mount.nfs # mkdir /home/nfsfile # chmod -R 777 /home/nfsfile
4、设置/etc/exports (若没有这个文件,则手动建立)
编辑好主要设定档/etc/exports之后,先启动rpcbind(若已经启动了,就不要重新启动),然后再启动nfs,就ok了。
systemctl start rpcbind
systemctl start nfs-server
systemctl daemon-reload