您的位置:首页 > 运维架构 > Linux

CentOS 6.6下NFS安装配置

2015-10-20 11:44 711 查看
一、环境介绍
  NFS服务器:CentOS6.6 192.168.1.116
  NFS客户端:CentOS5.5 192.168.1.114

二、服务器端安装配置

1、先用rpm -qa命令查看所需安装包(nfs-utils、rpcbind)是否已经安装:
# rpm -qa | grep "rpcbind"
rpcbind-0.2.0-11.el6.i686
# rpm -qa | grep "nfs"

nfsometer-1.6-1.el6.noarch
nfs-ganesha-proxy-2.2.0-2.el6.i686
nfs-ganesha-2.2.0-2.el6.i686
nfs-utils-lib-devel-1.1.5-11.el6.i686
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

2、如查询结果如上,说明服务器自身已经安装了NFS,如果没有安装,则用yum命令来安装:# yum -y install nfs-utils rpcbind

3、NFS共享文件路径配置:
/home/ 192.168.1.0/24(rw,sync,no_root_squash)
/home/www 192.168.1.0/24(rw,sync,no_root_squash)

4、启动NFS服务(先启动rpcbind,再启动nfs;如果服务器自身已经安装过NFS,那就用restart重启两个服务):
# service rpcbind start

正在启动 rpcbind: [确定]
# service nfs start
启动 NFS 服务: [确定]
关掉 NFS 配额: [确定]
启动 NFS mountd: [确定]
启动 NFS 守护进程: [确定]
正在启动 RPC idmapd: [确定]

5、设置NFS服务开机自启动:# chkconfig rpcbind on# chkconfig nfs on

三、客户端挂载配置1、安装nfs# yum -y install nfs-utils rpcbind
2、启动服务# service rpcbind start

2、设置服务自启
# chkconfig rpcbind on

3、创建挂载点
# make /AAA
# make /BBB

4、查看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

5、挂载:

#mount -t nfs 192.168.1.116:/home/ /AAA
#mount -t nfs 192.168.1.116:/home/www/ /BBB

6、查看已挂载共享:
# 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)

7、设置开机自动挂载

# vi /etc/fstab

添加下面两句

192.168.1.116:/home /AAA nfs defaults 0 0
192.168.1.116:/home/www /BBB nfs defaults 0 0

8、重启客户端验证是否生效

# 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格式。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nfs nfs-utils rpcbin