How to build a NFS Service
NFS网络文件系统的服务的配置
1 Preparation
Three Linux virtual machines
one: to be NFS Service
the other two: NFS Clinet
2 Install And Setting
2.1 checking System version
Client:
cat /etc/redhat-release
uname -a
ifconfig
Service:
cat /etc/redhat-release
uname -a
ifconfig
you are better make sure three Linux System is same.
2.2 Checking RPC and NFS whether has installed at Service
Service:
rpm -aq nfs-utils portmap rpcbind
If the PRC and NFS haven’t installed, you can user “ yum install nfs-utils rpcbind -y”
2.3 Start NFS and RPC Service at Service
switch to NFS Service
Firstly start RPC Service at service.
rpcinfo -p localhost: check RPC localhost port
“rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused”: show RPC Service does not start.
Secondly: start NFS Service
2.4 Setting NSF at Service
/etc/exports is setting of NFS, we need to set it by “VIM”.
The GateWay can be replaced by IP, it will make the /date used by only Client. So we always use gateway.
The authority includes:
ro: only read
wo:only write
sync:
use “,” as separator.
Then, you need to reload the nfs Service.
Then, you need to check the mount information for an NFS Server.
At this moment, The Service is OK.
2.5 Setting RPC in Client
switch to NFS Client.
Firstly: start RPC Service.
Check NFS information of NFS Server from Client, If show flowing it success.
If it don’t success ,you use ping SERVICE_IP or telnet SERVICE_IP 111(RPC port) to check where error occurs.
you are better make sure two client Linux System is same.
2.6 mount Service Data and update directory owner.
The you should update owner or group of /data at Service, or client will has authority errors.
If you set “w” authority, you need set “nfsnobody” to owner or group of /data and give writable authority.
“nfsnobody” is the default user of NFS.
you can see it’s UID in /var/lib/nfs/etab
If show red information, it is OK.
The another client operations is same as first one.
3 run and test
switch to Client.
Then switch to Service
If the /date of Service is same as the /mnt of Client, indicates it success.
4 optimization
4.1 set start with System open
we add all NFS, RPC starting commands in /etc/rc.local file to manage easily.
at Service:
at Client: you better make sure two client is same.
4.2 update /etc/exports
we want all clients can ADD, VIEW, UPDATE, and DELETE file. So we should use the same user to execute the client process. So we can use
all_squash: indicates all user will be set anonuid, if anonuid is not given, using default nfsnobody to be the client process executor.
anonuid: give executor UID
anongid: give executor GID
It will prompt the system safety.
4.3 use soft not hard
hard: request NFS service all time
soft: request NFS service intermittent
but, the two options belong to mount.
We use soft we reduce the coupling(耦合性) between NFS Service and NFS Client.
So we should use flowing command to mount NFS Service and add it at /etc/rc.local
/bin/mount -t nfs -o soft 192.168.98.132:/data /mnt/.
4.4 rsize, wsize
rsize: the max size of cache of reading file.
wsize: the max size of buffer of write file
test data:
#test read and write speed about rsize,wsize
the rsize=1024,wsize=1024
time sh read.sh
real 0m43.792s
user 0m11.669s
sys 0m21.960s
time sh write.sh
20000+0 records in
20000+0 records out
184320000 bytes (184 MB) copied, 64.963 s, 2.8 MB/s
real 1m5.058s
user 0m0.006s
sys 0m6.103s
[root@nfs_clinet_2 nfs_test]# grep mnt /proc/mounts
192.168.98.132:/data/ /mnt nfs4 rw,relatime,vers=4,rsize=1024,wsize=1024,namlen=255,soft,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.98.134,minorversion=0,local_lock=none,addr=192.168.98.132 0 0
the rsize=262144,wsize=262144,
time sh read.sh
real 0m37.112s
user 0m4.690s
sys 0m25.867s
time sh write.sh
20000+0 records in
20000+0 records out
184320000 bytes (184 MB) copied, 6.63189 s, 27.8 MB/s
real 0m6.645s
user 0m0.002s
sys 0m1.366s
grep mnt /proc/mounts
192.168.98.132:/data/ /mnt nfs4 rw,relatime,vers=4,rsize=262144,wsize=262144,namlen=255,soft,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.98.134,minorversion=0,local_lock=none,addr=192.168.98.132 0 0
obvious the rsize and wsize bigger, the speed is more quickly.
In Centos 6.5 default rsize and wrize is so good ,we don’t need to update it.
4.5 noatime, nodiratime
noatime: when you access a file, will not update its atime
nodiratime: when you access a file, will not update its atiem
If you hope you NFS Service read/write more quickly, you can add these two options.
4.6 nosuid, noexec, nodev
nosuid: forbidden seting suid
noexec:forbidden executing scripts, including shell and scropts
nodev: Do not interpret character or block special devices on the file system.
The three is safe options, we can use these to prevent our system be invaded
The picture is show noexec option effect.
How to build a NFS Service的更多相关文章
- Build a Restful Service
最近项目中遇到的REST的问题很多,很多情况下受weblogic以及Jdeveloper版本的影响,无法直接从Jdeveloper中生成一个RESTful Service出来,所以基于流行的Sprin ...
- [转]How to Use Web API OData to Build an OData V4 Service without Entity Framework
本文转自:http://www.odata.org/blog/how-to-use-web-api-odata-to-build-an-odata-v4-service-without-entity- ...
- NFS文件系统存储服务部署
1 NFS介绍 1.1 什么是NFS? NFS是Network File System的缩写,中文名称是网络文件系统.它的主要功能是通过网络让不用的主机系统之间可以共享文件或者目录.NFS客户端通过挂 ...
- nfs服务的讲解
第4章 nfs存储服务的搭建 4.1 nfs服务的介绍 4.1.1 nfs的作用 nfs服务器是一种远程网络传输的共享文件系统 节省web服务器的本地存储空间 用户存储在web服务器上面的资源,会通过 ...
- 【集群实战】NFS网络文件共享服务
1. NFS介绍 1.1 什么是NFS? NFS是Network File System的缩写,中文意思是网络文件系统. 它的主要功能是通过网络(一般是局域网)让不同的主机系统之间可以共享文件或目录. ...
- Linux NFS 服务部署
系统环境:Oracle Linux 5.7 服务端:192.168.1.111 客户端:192.168.1.171 一.服务端配置 二.客户端配置 一.服务端配置 1.依次启动portmap和nfs服 ...
- Windows Service--Write a Better Windows Service
原文地址: http://visualstudiomagazine.com/Articles/2005/10/01/Write-a-Better-Windows-Service.aspx?Page=1 ...
- 2 NFS高可用解决方案之NFS的搭建
preface 我们紧接着上一篇博文的基础(drbd+heartbeat的正常工作,http://www.cnblogs.com/liaojiafa/p/6129499.html)来搭建NFS的服务. ...
- Linux 配置NFS,文件共享
配置: 1.设定共享主机服务器 ---(注意防火墙) 编辑ipA端的/etc/exports 文件 [root@dbrac2 ~]# cat /etc/exports /media 192 ...
随机推荐
- 业务人员自助BI分析不够用,还要自助数据准备?
自助式BI工具,可以帮助业务人员充分了解和利用企业数据,通过可视化操作,拖拖拽拽来新建分析,生成可视化的报表,帮助企业决策.但近几年的调查研究发现,拥有强大分析策略和模型的产品,比如Tableau.q ...
- KOTLIN开发语言文档(官方文档) -- 入门
网页链接:https://kotlinlang.org/docs/reference/basic-syntax.html 1. 入门 1.1. 基本语法 1.1.1. 定义包 包说明应该在源 ...
- android 帧动画,补间动画,属性动画的简单总结
帧动画——FrameAnimation 将一系列图片有序播放,形成动画的效果.其本质是一个Drawable,是一系列图片的集合,本身可以当做一个图片一样使用 在Drawable文件夹下,创建ani ...
- Android数据库相关整理
今天对Android中数据库相关的操作和代码做了一个整理,便于自己之后的查阅.主要内容有: 1.原生数据库写法 2.终端进sqlite的操作 3.第三方库 4.事务处理 5.权限和路径 一.原生数据库 ...
- iOS - GitHub干货分享(APP引导页的高度集成 - DHGuidePageHUD - ②)
距上一篇博客"APP引导页的高度集成 - DHGuidePageHUD - ①"的发布有一段时间了, 后来又在SDK中补充了一些新的内容进去但是一直没来得及跟大家分享, 今天来跟大 ...
- Android面试题(一)
1. 请描述一下Activity 生命周期. 答: 如下图所示.共有七个周期函数,按顺序分别是: onCreate(), onStart(), onRestart(), onResume(), onP ...
- ListView之点击展开菜单
一.概述 ListView点击item显示菜单是要实现这样的效果: 需要实现的逻辑如下: 1)点击一个普通item,展开当前菜单,同时关闭其他菜单 2)点击一个已展开的菜单,隐藏当前菜单 3)将展开菜 ...
- Linux用户态和内核态
究竟什么是用户态,什么是内核态,这两个基本概念以前一直理解得不是很清楚,根本原因个人觉得是在于因为大部分时候我们在写程序时关注的重点和着眼的角度放在了实现的功能和代码的逻辑性上,先看一个例子: 1)例 ...
- 如何写出高质量的技术博客 这边文章出自http://www.jianshu.com/p/ae9ab21a5730 觉得不错直接拿过来了 好东西要大家分享嘛
如何写出高质量的技术博客?答案是:如果你想,就一定能写出高质量的技术博客.看起来很唯心,但这就是事实.有足够愿力去做一件目标明确,有良好反馈系统的事情往往很简单.就是不停地训练,慢慢地,你自己 ...
- 论Pair的重要性
这些天我在用React和D3做图表,从已经实现的图表里复制了一些坐标轴的代码,发现坐标轴上的n个点里,只有第一个点下面能渲染出文字提示,其余点下面都无法渲染出文字. 和组里的FL一起百思不得其解好几天 ...