1、环境介绍
NFS服务器:CentOS6.6 192.168.1.116
NFS客户端:CentOS5.5 192.168.1.114
服务器
2、服务器端安装配置
ide
一、先用rpm -qa命令查看所需安装包(nfs-utils、rpcbind)是否已经安装:spa
# rpm -qa | grep "rpcbind"rest
rpcbind-0.2.0-11.el6.i686进程
# rpm -qa | grep "nfs"ip
nfsometer-1.6-1.el6.noarchci
nfs-ganesha-proxy-2.2.0-2.el6.i686rpc
nfs-ganesha-2.2.0-2.el6.i686it
nfs-utils-lib-devel-1.1.5-11.el6.i686pip
nfs-ganesha-ceph-2.2.0-2.el6.i686
nfs-ganesha-nullfs-2.2.0-2.el6.i686
nfs-utils-lib-1.1.5-11.el6.i686
nfs-ganesha-utils-2.2.0-2.el6.i686
nfswatch-4.99.9-1.el6.rf.i686
nfs-utils-1.2.3-64.el6.i686
nfs4-acl-tools-0.3.3-7.el6.i686
nfs-ganesha-mount-9P-2.2.0-2.el6.i686
nfs-ganesha-vfs-2.2.0-2.el6.i686
二、如查询结果如上,说明服务器自身已经安装了NFS,若是没有安装,则用yum命令来安装:
# yum -y install nfs-utils rpcbind
三、NFS共享文件路径配置:
/home/ 192.168.1.0/24(rw,sync,no_root_squash)
/home/www 192.168.1.0/24(rw,sync,no_root_squash)
四、启动NFS服务(先启动rpcbind,再启动nfs;若是服务器自身已经安装过NFS,那就用restart重启两个服务):
# service rpcbind start
正在启动 rpcbind: [肯定]
# service nfs start
启动 NFS 服务: [肯定]
关掉 NFS 配额: [肯定]
启动 NFS mountd: [肯定]
启动 NFS 守护进程: [肯定]
正在启动 RPC idmapd: [肯定]
五、设置NFS服务开机自启动:
# chkconfig rpcbind on
# chkconfig nfs on
3、客户端挂载配置
一、安装nfs
# yum -y install nfs-utils rpcbind
二、启动服务
# service rpcbind start
二、设置服务自启
# chkconfig rpcbind on
3、建立挂载点
# make /AAA
# make /BBB
四、查看NFS服务器上的共享:
# showmount -e 192.168.1.116
Export list for 192.168.1.116:
/home/www 192.168.1.0/24
/home 192.168.1.0/24
五、挂载:
#mount -t nfs 192.168.1.116:/home/ /AAA
#mount -t nfs 192.168.1.116:/home/www/ /BBB
六、查看已挂载共享:
# mount
/dev/sda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.1.116:/home on /AAA type nfs (rw,addr=192.168.1.116)
192.168.1.116:/home/www on /BBB type nfs (rw,addr=192.168.1.116)
/dev/sdb on /home type ext3 (rw)
/dev/sdc on /home type ext3 (rw)
七、设置开机自动挂载
# vi /etc/fstab
添加下面两句
192.168.1.116:/home /AAA nfs defaults 0 0
192.168.1.116:/home/www /BBB nfs defaults 0 0
八、重启客户端验证是否生效
# reboot
待系统重启后查看是否自动挂载以及挂载的文件系统
# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda3 ext3 2.9G 1.8G 936M 66% /
/dev/sda1 ext3 99M 16M 79M 17% /boot
tmpfs tmpfs 499M 0 499M 0% /dev/shm
192.168.1.116:/home
nfs 8.3G 3.4G 4.5G 43% /AAA
192.168.1.116:/home/www
nfs 8.3G 3.4G 4.5G 43% /BBB
说明已经自动挂载成功,所挂载的文件系统格式为nfs格式。