天天看点

centos6下配置nfs

centos6.2变更了portmap服务为rpcbind,在使用nfs时这点与centos5不同,下面配置一个nfs系统,用来使局域网内的所有用户均可访问该目录,可将该目录配置成yum源,供内网机器安装软件。

首先安装NFS套件,命令如下:

yum install nfs-utils.x86_64(64位系统)

yum install nfs-utils(32位系统)

然后安装portmap服务,portmap在centos6中改名为rpcbind

yum install rpcbind(centos6)

yum install portmap(centos5)

类型:System V-launched Service

软件包:nfs-utils

进程:nfsd,lockd,rpciod,rpc.{mounted,rquotad,statd}

脚本:nfs,nfslock

端口:由portmap服务指派端口(111) 

配置文件:/etc/exports 

辅助工具:portmap(必须)

相关命令:rpcinfo -p [IPADD]:查看服务器提供的rpc服务

          showmount -e:查看服务共享的目录

Server端:

1./etc/exports格式:

            目录                     选项             

例:共享/share目录给192.168.0.x的用户

           /share                192.168.0.0/24 (rw)  

2.启动portmap服务:                                    

    service portmap start[restart]                     

3.启动NFS服务:

    service nfs start[restart]                         

Client端

1.启动portmap服务:                                    

2.挂载服务器端的共享目录(假设服务器端192.168.0.1):    

    mount -t nfs 192.168.0.1:/share  /mnt/localshare   

客户端配置

查看是否能访问nfs服务

showmount -e 192.168.0.10

显示如下:

Export list for 192.168.0.10:

/opt/centos6 192.168.0.11

表示可以访问,如不可访问查看nfs服务端nfs服务是否启用,防火墙是否允许通过。

挂载nfs目录

mkdir /opt/centos6

mount -t nfs 192.168.0.10:/opt/centos6/ /opt/centos6/

配置开机自动挂载

vi /etc/fstab

添加

192.168.0.10:/opt/centos6 /opt/centos6 nfs  nodev,ro,rsize=32768,wsize=32768    0 0

配置nfs服务端

vi /etc/exports

/opt/centos6 192.168.0.0/24(ro,no_root_squash)

这一行表明本机的/opt/centos6这个目录为nfs共享目录,可访问的ip地址区间为192.168.0.0-192.168.0.254,权限为只读,当访问者为root用户时方位该目录具有root权限

重启nfs服务

/etc/init.d/rpcbind start 

/etc/init.d/nfs start      

将nfs加入开机启动项

chkconfig nfs on

本文转自 hb_fukua 51CTO博客,原文链接:http://blog.51cto.com/2804976/955727

继续阅读