01-NFS配置

1.检查NFS软件包安装
# rpm -qa |grep nfs
nfs-utils-lib-1.1.5-6.el6.x86_64
nfs4-acl-tools-0.3.3-6.el6.x86_64
nfs-utils-1.2.3-36.el6.x86_64

# rpm -qa | grep rpcbind
rpcbind-0.2.0-11.el6.x86_64

2.检查守护进程
# /etc/init.d/rpcbind status

# service rpcbind status

3.检查服务状态
# /etc/init.d/nfs status

# service nfs status

4.修改配置文件
# vim /etc/exports

格式如下:
共享目录 访问对象(访问控制)
/tmp *(rw,no_root_squash,sync)

/tmp 192.168.6.102(ro,sync) 192.168.6.0/24(rw,sync,no_root_squash)

5.启动服务
# service nfs start

6.开机自动启动
# chkconfig --level 35 nfs on

# chkconfig nfs on

7.客户端查看共享资源
# showmount -e 192.168.6.11

8.客户端访问共享资源
# mkdir /nfsshare
# mount -t nfs 192.168.6.11:/tmp /nfsshare/
# df -Th
# cd /nfsshare && ls

9.客户端开机自动挂载
# vim /etc/fstab
192.168.6.11:/tmp /nfsshare nfs defaults 0 0
# mount -a

# vim /etc/rc.d/rc.local
mount -t nfs 192.168.6.11:/tmp /nfsshare/

10.服务器端查看被挂载情况
# showmount -a

11.注意:
(1)“写”需要的条件
共享权限&文件系统权限

(2)服务器修改配置文件后
# exportfs -rv

# service nfs reload

(3)查看NFS的版本
# cat /proc/mounts

(4)修改服务器端版本
# vim /etc/sysconfig/nfs
第29行
将 #RPCNFSDARGS="-N 4"
改 RPCNFSDARGS="-N 4"

# service nfs restart

(5)按需挂载(当访问到的时候自动挂载,不访问后600秒自动卸载)
服务器端配置
# mkdir -p /share/test{A,B}
# touch /share/testA/testa
# touch /share/testB/testb
# vim /etc/exports
/share *(rw,no_root_squash,sync)
# service nfs restart
客户端配置(挂载点无需手动创建)
# vim /etc/auto.master
/share /etc/auto.misc
# vim /etc/auto.misc
testA -fstype=nfs,rw 192.168.6.11:/share/testA
testB -fstype=nfs,ro 192.168.6.11:/share/testB
# service autofs restart
# chkconfig autofs on
# df -hT
# ll -d /share
# cd /share/testA && ls
# df -Th
# touch test1.txt
# cd /share/testB && ls
# df -Th
# touch test2.txt(权限拒绝)

posted @ 2018-02-26 01:20  freecd.cn  阅读(124)  评论(0编辑  收藏  举报