本文共 4002 字,大约阅读时间需要 13 分钟。
目录
yum install -y nfs-utils
过程 15.1. On the *SERVER* side
stop & disable services
service nfs stopservice nfslock stopservice rpcbind stopservice rpcidmapd stop
/etc/fstab
as root edit /etc/fstab and add nfs4 exports/www /exports none bind 0 0
as root edit /etc/exports
NFSv3
/exports 172.16.1.0/24 (rw,sync)
NFSv4
/exports 172.16.1.0/24(rw,sync,fsid=0,anonuid=99,anongid=99)/exports/neo *(rs,sync)
reload exported filesystems
# exportfs -rv
start required services
chkconfig rpcbind onchkconfig nfs onchkconfig nfslock onchkconfig rpcidmapd onservice rpcbind startservice rpcidmapd startservice nfs startservice nfslock start
nfs status
# nfsstatServer rpc stats:calls badcalls badauth badclnt xdrcall171 0 0 0 0Server nfs v3:null getattr setattr lookup access readlink3 1% 150 88% 0 0% 3 1% 2 1% 0 0%read write create mkdir symlink mknod0 0% 0 0% 0 0% 0 0% 0 0% 0 0%remove rmdir rename link readdir readdirplus0 0% 0 0% 0 0% 0 0% 0 0% 9 5%fsstat fsinfo pathconf commit0 0% 3 1% 0 0% 0 0%
# watch nfsstat -cEvery 2.0s: nfsstat -c Mon Sep 20 16:53:55 2010Client rpc stats:calls retrans authrefrsh286818929 1160 0Client nfs v4:null read write commit open open_conf0 0% 37286763 13% 6 0% 1 0% 38990106 13% 17986485 6%open_noat open_dgrd close setattr fsinfo renew6 0% 0 0% 38774539 13% 2172019 0% 16 0% 147 0%setclntid confirm lock lockt locku access321 0% 321 0% 0 0% 0 0% 0 0% 62157123 21%getattr lookup lookup_root remove rename link80553542 28% 8828991 3% 8 0% 5 0% 5 0% 0 0%symlink create pathconf statfs readlink readdir0 0% 1 0% 0 0% 5 0% 0 0% 13933 0%server_caps delegreturn24 0% 54556 0%
security
# vi /etc/hosts.denyrpcbind:ALL# vi /etc/hosts.allowrpcbind:172.16.1.0/255.255.254.0
NFS的队列大小下面将设置为较合理的值256K
# echo 262144 > /proc/sys/net/core/rmem_default# echo 262144 > /proc/sys/net/core/rmem_max# echo 262144 > /proc/sys/net/core/wmmen_default# echo 262144 > /proc/sys/net/core/wmmen_max
过程 15.2. NFSv4
/etc/exports
# cat /etc/exports/www 172.16.1.2/32(ro,sync,fsid=0,anonuid=99,anongid=99)/www/logs *(rw,sync)
注意,要通过NFS4共享一个目录,必须使用 fsid=0 的参数,使用fsid=0选项的时候只能共享一个目录,这个目录将成为NFS服务器的根目录。
启动NFS,v4 不需要rpcbind
service rpcbind stopservice rpcidmapd stopservice nfs restartservice nfslock stop
查看 export 设置
# exportfs/www 172.16.1.2/32/www/logs 172.16.1.0/24
mount NFSv4
mount -t nfs4 172.16.1.15:/logs /mnt
查看NFS正在使用的端口
rpcinfo -p localhost
vi /etc/sysconfig/nfs
LOCKD_TCPPORT=32803LOCKD_UDPPORT=32769MOUNTD_PORT=892RQUOTAD_PORT=875STATD_PORT=662STATD_OUTGOING_PORT=2020
service nfs restart
iptables -I INPUT -m state --state NEW -p tcp \ -m multiport --dport 111,892,2049,32803 -s 192.168.0.0/24 -j ACCEPT iptables -I INPUT -m state --state NEW -p udp \ -m multiport --dport 111,892,2049,32769 -s 192.168.0.0/24 -j ACCEPT
Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a>comments powered by Disqus 原文出处:Netkiller 系列 手札 本文作者:陈景峯 转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。