CentOS 7 NFS服务器和客户端设置
来源:互联网 发布:2144传奇盛世翅膀数据 编辑:程序博客网 时间:2024/05/23 14:10
CentOS 7 NFS服务器和客户端设置
CentOS 7引入了全新的 systemctl
服务管理,设置和管理服务略有不同。以下是为了提供Mac OS X客户端访问Linux NFS输出的卷实现数据备份的记录,NFS服务器设置见本文,Mac OS X挂载Linux的NFS输出见Mac OS X 挂载Linux卷(NFS)。
设置Linux服务端
将移动硬盘挂载到 /data
目录
mount /dev/sdb1 /data
在Paralles Desktop虚拟机运行的是CentOS 7操作系统,使用以下命令安装 NFS 支持
yum install nfs-utils nfs-utils-lib
设置nfs相关服务在操作系统启动时启动
systemctl enable rpcbindsystemctl enable nfs-serversystemctl enable nfs-locksystemctl enable nfs-idmap
启动nfs服务
systemctl start rpcbindsystemctl start nfs-serversystemctl start nfs-locksystemctl start nfs-idmap
服务器端设置NFS卷输出,即编辑 /etc/exports
添加:
/data 10.211.55.0/24(rw,sync,no_root_squash,no_subtree_check)
/data – 共享目录
10.211.55.0/24 – 允许访问NFS的客户端IP地址段
rw – 允许对共享目录进行读写
sync – 实时同步共享目录
no_root_squash – 允许root访问
no_all_squash - 允许用户授权
no_subtree_check - 如果卷的一部分被输出,从客户端发出请求文件的一个常规的调用子目录检查验证卷的相应部分。如果是整个卷输出,禁止这个检查可以加速传输。
no_subtree_check - If only part of a volume is exported, a routine called subtree checking verifies that a file that is requested from the client is in the appropriate part of the volume. If the entire volume is exported, disabling this check will speed up transfers. Setting Up an NFS Server
NFS客户端挂载
yum install nfs-utils nfs-utils-lib
Linux挂载NFS的客户端非常简单的命令,先创建挂载目录,然后用 -t nfs
参数挂载就可以了
mount -t nfs 10.211.55.9:/data /data
如果要设置客户端启动时候就挂载NFS,可以配置 /etc/fstab
添加以下内容
10.211.55.9:/data /data nfs auto,rw,vers=3,hard,intr,tcp,rsize=32768,wsize=32768 0 0
在centos 7 的系统下面,可能会发生重启后无法mount 这个nfs的情况
解决办法:
1. 修改 /etc/rc.d/rc.local 的权限,增加执行权限
2. 在/etc/rc.d/rc.local下面 增加这样的一句语句
mount -a
-a的参数含义是:-a, –all mount all filesystems mentioned in fstab
然后在客户端简单使用以下命令就可以挂载
mount /data
通过防火墙挂载NFS服务
在生产环境,可能会因为安全需求在NFS服务器和客户端之间部署防火墙。此时,NFS客户端挂载的时候会有如下输出报错
mount.nfs: Connection timed out
参考 Running NFS Behind a Firewall 设置防火墙允许访问NFS服务器的服务端口,注意,需要配置NFS服务使用固定端口。
MOUNTD_PORT=port# Controls which TCP and UDP port mountd (rpc.mountd) uses.STATD_PORT=port# Controls which TCP and UDP port status (rpc.statd) uses.LOCKD_TCPPORT=port# Controls which TCP port nlockmgr (lockd) uses.LOCKD_UDPPORT=port# Controls which UDP port nlockmgr (lockd) uses.
编辑 /etc/sysconfig/nfs
配置文件
# TCP port rpc.lockd should listen on.LOCKD_TCPPORT=32803# UDP port rpc.lockd should listen on.LOCKD_UDPPORT=32769MOUNTD_PORT=892STATD_PORT=662
可以在Linux NFS服务器上执行以下命令获得NFS端口信息
rpcinfo -p
需要允许以下端口
NFS的TCP和UDP端口2049
rpcbind/sunrpc的TCP和UDP端口111
设置
MOUNTD_PORT
的TCP和UDP端口设置
STATD_PORT
的TCP和UDP端口设置
LOCKD_TCPPORT
的TCP端口设置
LOCKD_UDPPORT
的UDP端口
program vers proto port service100000 4 tcp 111 portmapper100000 3 tcp 111 portmapper100000 2 tcp 111 portmapper100000 4 udp 111 portmapper100000 3 udp 111 portmapper100000 2 udp 111 portmapper100024 1 udp 54305 status100024 1 tcp 55604 status100005 1 udp 20048 mountd100005 1 tcp 20048 mountd100005 2 udp 20048 mountd100005 2 tcp 20048 mountd100005 3 udp 20048 mountd100005 3 tcp 20048 mountd100003 3 tcp 2049 nfs100003 4 tcp 2049 nfs100227 3 tcp 2049 nfs_acl100003 3 udp 2049 nfs100003 4 udp 2049 nfs100227 3 udp 2049 nfs_acl100021 1 udp 32769 nlockmgr100021 3 udp 32769 nlockmgr100021 4 udp 32769 nlockmgr100021 1 tcp 32803 nlockmgr100021 3 tcp 32803 nlockmgr100021 4 tcp 32803 nlockmgr100011 1 udp 875 rquotad100011 2 udp 875 rquotad100011 1 tcp 875 rquotad100011 2 tcp 875 rquotad
在 Linux NFS 服务器上使用以下命令开启iptables防火墙允许访问以上端口
firewall-cmd --permanent --add-port=2049/tcpfirewall-cmd --permanent --add-port=2049/udpfirewall-cmd --permanent --add-port=111/tcpfirewall-cmd --permanent --add-port=111/udpfirewall-cmd --permanent --add-port=892/tcpfirewall-cmd --permanent --add-port=892/udpfirewall-cmd --permanent --add-port=662/tcpfirewall-cmd --permanent --add-port=662/udpfirewall-cmd --permanent --add-port=32803/tcpfirewall-cmd --permanent --add-port=32769/udp
在 Linux NFS 服务器上使用以下命令重新加载防火墙规则
firewall-cmd --reload
不过,我实测还是存在访问问题,以后再验证
http://blog.huatai.me/2014/10/14/CentOS-7-NFS-Server-and-Client-Setup/
- CentOS 7 NFS服务器和客户端设置
- CentOS 7 NFS服务器和客户端设置
- CentOS 7 NFS服务器和客户端设置
- 配置NFS服务器和NFS客户端
- Linux NFS 服务器和客户端
- nfs服务器和客户端配置
- Ubuntu下配置NFS服务器和客户端
- NFS服务器和客户端的配置
- centos7 搭建nfs服务器和客户端
- Ubuntu 和Centos 系统搭建nfs服务器
- centos nfs 服务器
- Ubuntu 12.04 Nfs 服务器和客户端的安装和配置
- 客户端如何挂载和卸载nfs服务器文件
- centos快速搭建nfs服务器
- CentOS下架设NFS服务器
- centos 6.5配置nfs服务器
- Windows下Linux开发环境设置(一)--TFTP服务器设置和NFS服务器设置
- 自己动手设置VPN服务器和客户端
- 其实我真的不是来搞笑的(内含java学习笔记)
- Iterator的remove()和Collection的remove()
- 【技巧-模拟除法】LightOJ Large Division 1214
- JAVA_SE ----- 基础知识总结-----方法,数组
- Android中基于protobuf的socket通信的实例
- CentOS 7 NFS服务器和客户端设置
- C++开源项目
- 10_Java循环结构
- 南大软院二十一天成神计划
- 四种途径将HTML5 web应用变成android应用
- String中hashCode的缓存和懒加载
- NYIST27 水池数目
- Reverse Integer
- 系统架构设计