CentOS 6.8上开启NFS服务给不同用户使用的曲线设置方法

服务端配置

1. 检查是否有安装nfs

rpm -qa|grep nfs

rpm -qa|grep rpcbind

若没有这安装nfs-utils和rpcbind

yum install nfs-utils rpcbind

2.设置开机启动服务

chkconfig nfs on
chkconfig rpcbind on

3.启动相关服务

service rpcbind start
service nfs start

4.创建共享目录

mkdir -p /export/primary
mkdir -p /export/secondary

或者直接每个用户下面单独建立一个自己的目录,例如nfsdir

/home/yanghg/nfsdir
/home/yaogl/nfsdir
/home/huangy/nfsdir
/home/wangw/nfsdir
/home/duh/nfsdir
/home/yuy/nfsdir

5.编辑/etc/exports文件添加如下内容

/export*(rw,async,no_root_squash,no_subtree_check)

/home/yanghg/nfsdir *(rw,sync,no_root_squash)
/home/yaogl/nfsdir *(rw,sync,no_root_squash)
/home/huangy/nfsdir *(rw,sync,no_root_squash)
/home/wangw/nfsdir *(rw,sync,no_root_squash)
/home/duh/nfsdir *(rw,sync,no_root_squash)
/home/yuy/nfsdir *(rw,sync,no_root_squash)

6.刷新配置立即生效

exportfs -a

>>>此时可以到你的客户端验证

>>>以我的平台为例,执行  mount -t nfs -o nolock 192.168.1.12:/home/yanghg/nfsdir /mnt

 

客户端配置
 
1. 安装nfs-utils和rpcbind

 
yum install nfs-utils rpcbind 

2.设置开机启动服务

chkconfig nfs on
chkconfig rpcbind on 

3.启动服务

servicerpcbind start
servicenfs start 

4.创建挂载点

mkdir -p /mnt/primary
mkdir -p /mnt/secondary 

5.挂载目录

mount -t nfs server_ip:/export/primary /mnt/primary
mount -t nfs server_ip:/export/secondary /mnt/secondary 

6.查看挂载的目录

df -h 

7.卸载挂载的目录

umount /mnt/primary

umount /mnt/secondary 
 
8.编辑/etc/fstab,开机自动挂载
 
vi /etc/fstab
server_ip:/export/primary/mnt/primary nfs rw,tcp,intr 0 1
server_ip:/export/secondary/mnt/secondary nfs rw,tcp,intr 0 1
 

 

posted @ 2016-11-09 20:44  cutelinux  阅读(906)  评论(0编辑  收藏  举报