NFS是Network File System的简称,即网络文件系统。NFS是系统间进行文件共享的一种网络协议,它允许用户像访问本地文件一样去访问网络上共享的文件。
CentOS 自带NFS功能
若没有需安装:yum install -y nfs-utils rpcbind
vim /etc/exports
/ane/data/LBLOGS 172.17.99.61(rw,sync,no_root_squash)
/ane/data/LPLOGS *(ro,sync)
#表示只有172.17.99.61有读写权限LBLOGS,只有读权限LPLOGS
vim /etc/sysconfig/nfs
RQUOTAD_PORT=30001
LOCKD_TCPPORT=30002
LOCKD_UDPPORT=30002
MOUNTD_PORT=30003
STATD_PORT=30004
mkdir /ane/data/LBLOGS -p
mkdir /ane/data/LPLOGS -p
service nfs start
service rpcbind start
showmount -e 172.17.99.131
clnt_create: RPC: Program not registered
#此报错是因为启动nfs应用顺序错误导致
service nfs stop
service rpcbind stop
#必须按以下方式顺序启动
service rpcbind start
service nfs start
showmount -e 172.17.99.67
Export list for 172.17.99.67:
/ane/data/LBLOGS 172.17.99.61(rw,sync,no_root_squash)
/ane/data/LPLOGS *(ro,sync)
mount -t 172.17.99.67:/ane/data/LBLOGS /ane/data/LBLOGS
mount -t 172.17.99.67:/ane/data/LPLOGS /ane/data/LPLOGS
mount | grep nfs
172.17.99.67:/ane/data/LBLOGS on /ane/data/LBLOGS type nfs (ro,vers=4,addr=172.17.99.67,clientaddr=172.17.99.61)
172.17.99.67:/ane/data/LPLOGS/ on /ane/data/LPLOGS type nfs (rw,vers=4,addr=172.17.99.67,clientaddr=172.17.99.61)
mount 172.17.99.131:/ane/data/YTLOGS/ /ane/data/YTLOGS/
mount.nfs: access denied by server while mounting 172.17.99.131:/ane/data/YTLOGS/
#因为版本的问题导致
mount -o v3 172.17.99.131:/ane/data/YTLOGS/ /ane/data/YTLOGS/ #指定版本挂载即可
#修改不活动状态的超时时间
vim /etc/sysconfig/autofs
TIMEOUT=300
修改为为
TIMEOUT=600
也就是将不活动状态的超时时间由5分钟修改为10分钟。
vim /etc/fstab
172.17.99.67:/ane/data/LPLOGS /ane/data/LPLOGS nfs defaults 0 0
umount /ane/data/LPLOGS
Over~