CentOS 开启NFS服务以及在Centos上挂在NFS

NFS 服务器这里我称之为Master服务器,IP为192.168.1.2,需要挂载NFS服务器的我称之为client,client服务器的IP为192.168.1.13

A服务器安装CentOS 6.X 64bit,首先需要安装NFS服务并且开启这个服务

yum install nfs-utils nfs-utils-lib

chkconfig nfs on 
service rpcbind start
service nfs start

其次,我们需要在Master服务器上决定我们要共享哪个文件夹,然后把文件夹目录以及符合共享,写入/etc/exports

假如说我们想共享/home目录

那么我们首先需要编辑/etc/exports

vi /etc/exports

加入以下命令:

/home 192.168.1.13(rw,sync,no_root_squash,no_subtree_check)

rw:表示client主机可以对共享的文件夹进行读和写的操作

sync: Sync confirms requests to the shared directory only once the changes have been committed.

编辑完/etc/exports以后,我们需要运行以下command来让配置生效:

exportfs -a

这样我们就完成master服务器的配置

下面我们来配置client服务器,安装nfs服务

yum install nfs-utils nfs-utils-lib

假如说我们需要把NFS挂载到/home/nfs

mkdir -p /home/nfs

mount 192.168.1.2:/home /home/nfs

这样我们就完成了挂载,可以通过df -h或者mount 来查看系统的挂载情况

但是这种挂载只是临时性的,每次我们重启,就需要重新运行一次挂载命令。为了省事,我们可以将挂载写入/etc/fstab

192.168.1.2:/home /home/nfs nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.