六 NFS--指定多个网段访问
[sql]
--第一步,修改配置文件
[root@serv01 share]# vim /etc/exports
[root@serv01 share]# cat /etc/exports
/share 192.168.1.0/255.255.255.0(rw,all_squash,anonuid=501,anongid=501)172.16.1.0/255.255.255.0(rw)
#/share192.168.1.0/24(rw,all_squash,anonuid=501,anongid=501)
--第二步,重启服务
[root@serv01 share]# /etc/init.d/nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
--第三步,测试
#真实机挂载
[root@larrywen 0812]# mount192.168.1.11:/share /mnt
[root@larrywen 0812]# mount |grep share
192.168.1.11:/share on /mnt type nfs(rw,vers=4,addr=192.168.1.11,clientaddr=192.168.1.1)
#serv01添加网卡,真实机使用其他网段挂载
[root@serv01 share]# ifconfig eth1 172.16.1.11netmask 255.255.255.0
[root@larrywen 0812]# umount /mnt
[root@larrywen 0812]# mount172.16.1.11:/share /mnt
#永久挂载
[root@serv02~]# tail -n1 /etc/fstab
192.168.1.11:/share /data nfs defaults 00
#读取fstab文件
[root@serv02 ~]# mount -a
[root@serv02 ~]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts(rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs(rw,rootcontext=“system_u:object_r:tmpfs_t:s0”)
/dev/sda1 on /boot type ext4 (rw)
/dev/sda5 on /opt type ext4 (rw)
none on /proc/sys/fs/binfmt_misc typebinfmt_misc (rw)
/dev/sr0 on /iso type iso9660 (ro)
192.168.1.11:/share on /data type nfs(rw,vers=4,addr=192.168.1.11,clientaddr=192.168.1.12)
#查看有哪些用户挂载到本机?
[root@serv01 ~]# netstat -langput | grep nfs
[root@serv01 ~]# ps -ef|grep nfs
root 1246 2 0 22:29 ? 00:00:00 [nfsiod]
root 1323 2 0 22:35 ? 00:00:00 [nfsd4]
root 1324 2 0 22:35 ? 00:00:00 [nfsd4_callbacks]
root 1325 2 0 22:35 ? 00:00:00 [nfsd]
root 1326 2 0 22:35 ? 00:00:00 [nfsd]
root 1327 2 0 22:35 ? 00:00:00 [nfsd]
root 1328 2 0 22:35 ? 00:00:00 [nfsd]
root 1329 2 0 22:35 ? 00:00:00 [nfsd]
root 1330 2 0 22:35 ? 00:00:00 [nfsd]
root 1331 2 0 22:35 ? 00:00:00 [nfsd]
root 1332 2 0 22:35 ? 00:00:00 [nfsd]
root 1360 1219 0 22:36 pts/0 00:00:00 grep nfs
[root@serv01 ~]# ps -aux|grep nfs
Warning: bad syntax, perhaps a bogus ‘-’? See/usr/share/doc/procps-3.2.8/FAQ
root 1246 0.0 0.0 0 0 ? S 22:29 0:00 [nfsiod]
root 1323 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd4]
root 1324 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd4_callbacks]
root 1325 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd]
root 1326 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd]
root 1327 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd]
root 1328 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd]
root 1329 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd]
root 1330 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd]
root 1331 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd]
root 1332 0.0 0.0 0 0 ? S 22:35 0:00 [nfsd]
root 1362 0.0 0.2 103228 868 pts/0 S+ 22:36 0:00 grep nfs
[root@serv01 ~]# netstat -langput | grep192.168.1.12
tcp 0 0 192.168.1.11:2049 192.168.1.12:906 ESTABLISHED -