首页 > 其他 > 详细

NFS共享安装部署

时间:2015-11-27 20:06:24      阅读:313      评论:0      收藏:0      [点我收藏+]

系统环境

操作系统 centos 6.4 

服务器IP 172.16.7.40

客户端IP 172.16.5.53


一、安装所以需软件

yum install -y nfs-utils rpcbind


二、为NFS指定固定端口,运行以下命令:

vi /etc/sysconfig/nfs

搜索和设置如下所示的端口配置:

RQUOTAD_PORT=30001

LOCKD_TCPPORT=30002

LOCKD_UDPPORT=30002

MOUNTD_PORT=30003

STATD_PORT=30004


三、开放防火墙中的上述端口,运行以下命令:

iptables  -I INPUT -p tcp --dport 111 -j ACCEPT

iptables  -I INPUT -p udp --dport 111 -j ACCEPT

iptables  -I INPUT -p tcp --dport 2049 -j ACCEPT

iptables  -I INPUT -p udp --dport 2049 -j ACCEPT

iptables  -I INPUT -p tcp --dport 30001:30004 -j ACCEPT

iptables  -I INPUT -p udp --dport 30001:30004 -j ACCEPT

service iptables save

service iptables restart


四、创建共享目录,运行以下命令:

mkdir -p /data/nfs_share

上述命令将建立共享目录/data/nfs_share。


五、配置exports文件,运行以下命令:

vi /etc/exports

在上述文件的末尾新增一行,如下所示:

/data/nfs_share 192.168.4.212(rw,sync,no_root_squash)

/data/nfs_share *(ro)

这一行表示只有192.168.4.212客户端能够以读写权限挂载共享目录,其他客户端只能以只读权限挂载。


六、启动NFS相关服务,运行以下命令:

chkconfig nfs on

chkconfig rpcbind on

service nfs start

service rpcbind start

七、检查NFS的相关端口是否已经启用,运行以下命令:

service iptables status

rpcinfo -p localhost


八、安装NFS客户端(192.168.4.212)

NFS客户端不需要启动NFS服务,但需要安装nfs-utils,运行以下命令:

yum install -y nfs-utils

 

九、手动挂载NFS共享目录

 

1:确定挂载点,运行以下命令:

showmount -e 192.168.4.211

-e选项显示NFS服务端的共享列表。

 

2:创建挂载目录,运行以下命令:

mkdir -p /root/remote_dir

其中,/root/remote_dir为共享目录的挂载点目录。

 

3:挂载共享目录,运行以下命令:

mount -t nfs 192.168.4.211:/data/nfs_share /root/remote_dir

其中,-t选项用于指定文件系统的类型为nfs。

 

4:共享目录使用结束之后,卸载共享目录,运行以下命令:

umount /root/remote_dir


十、添加开机自动挂载

echo mount -t nfs 172.16.7.40:/tmp/craw/zxbg/ /tmp/craw/zxbg/ ext4 defaults 0 0 >> /etc/fstab


本文出自 “脚踏实地、稳步向前” 博客,请务必保留此出处http://linuxtech.blog.51cto.com/3670088/1717565

NFS共享安装部署

原文:http://linuxtech.blog.51cto.com/3670088/1717565

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!