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的更多相关文章

  1. Build a Restful Service

    最近项目中遇到的REST的问题很多,很多情况下受weblogic以及Jdeveloper版本的影响,无法直接从Jdeveloper中生成一个RESTful Service出来,所以基于流行的Sprin ...

  2. [转]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- ...

  3. NFS文件系统存储服务部署

    1 NFS介绍 1.1 什么是NFS? NFS是Network File System的缩写,中文名称是网络文件系统.它的主要功能是通过网络让不用的主机系统之间可以共享文件或者目录.NFS客户端通过挂 ...

  4. nfs服务的讲解

    第4章 nfs存储服务的搭建 4.1 nfs服务的介绍 4.1.1 nfs的作用 nfs服务器是一种远程网络传输的共享文件系统 节省web服务器的本地存储空间 用户存储在web服务器上面的资源,会通过 ...

  5. 【集群实战】NFS网络文件共享服务

    1. NFS介绍 1.1 什么是NFS? NFS是Network File System的缩写,中文意思是网络文件系统. 它的主要功能是通过网络(一般是局域网)让不同的主机系统之间可以共享文件或目录. ...

  6. Linux NFS 服务部署

    系统环境:Oracle Linux 5.7 服务端:192.168.1.111 客户端:192.168.1.171 一.服务端配置 二.客户端配置 一.服务端配置 1.依次启动portmap和nfs服 ...

  7. Windows Service--Write a Better Windows Service

    原文地址: http://visualstudiomagazine.com/Articles/2005/10/01/Write-a-Better-Windows-Service.aspx?Page=1 ...

  8. 2 NFS高可用解决方案之NFS的搭建

    preface 我们紧接着上一篇博文的基础(drbd+heartbeat的正常工作,http://www.cnblogs.com/liaojiafa/p/6129499.html)来搭建NFS的服务. ...

  9. Linux 配置NFS,文件共享

    配置:   1.设定共享主机服务器    ---(注意防火墙) 编辑ipA端的/etc/exports 文件 [root@dbrac2 ~]# cat /etc/exports /media  192 ...

随机推荐

  1. 我的屌丝giser成长记-研一篇(下)

    研一生活的下学期开始,课程就比较少了,加上选修课,4门课而已,总体还是比较轻松的,让我有更过充裕时间来做自己的事情以及导师的项目.开始导师的一个新的webgis开发项目,叫做三峡库区事故型水环境污染风 ...

  2. Xcode自定义代码块

    到现在才发现原来Xcode有自定义代码块这么神奇的功能,能简化很多无聊的敲重复代码的工作,真是感叹我怎么才知道!!! 具体的设置流程见:http://nshipster.cn/xcode-snippe ...

  3. 安卓开发之ListAdapter(二)

    今天我们来学习一下ArrayAdapter: ArrayAdapter是安卓中最简单的适配器.使用ArrayAdapter(数组适配器),需要把数据源存 放至数组里面来显示. •构造函数: publi ...

  4. 15-static和extern关键字1-对函数的作用

    一.extern与函数 如果一个程序中有多个源文件(.c),编译成功会生成对应的多个目标文件(.obj),这些目标文件还不能单独运行,因为这些目标文件之间可能会有关联,比如a.obj可能会调用c.ob ...

  5. 【Bootstrap-插件使用】Jcrop+fileinput组合实现头像上传功能

    作者:Dreawer链接:https://zhuanlan.zhihu.com/p/24465742来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 作者:梦游的龙猫(转 ...

  6. centos本地yum源安装

    1.为DVD或U盘创建一个用于挂载的目录 [root@localhost ~]# mkdir /media/CentOS/ 2.查看DVD或U盘所在的路径 [root@localhost ~]# fd ...

  7. 修复 Windows7 资源管理器左侧收藏夹无法展开问题

    相信大家在网上搜多到的解决办法大多数都是修改注册表,但是这个办法多数是无效的 1.运行regedit 2.展开到HKEY_CLASSES_ROOT\lnkfile 3.添加一个字符串值:IsShort ...

  8. 编程语言吉祥物之Duke

    在看到这个可爱的小家伙前,我一直以为那个咖啡杯子是Java的吉祥物.直到拿到<Java性能优化权威指南>这本书,才知道有这个小东西Duke.这位可爱的Duke是由Joe Palrang在1 ...

  9. struts2中各个jar包作用

    Struts2.3.4 所需的Jar包及介绍 Jar包的分类 jar包名称 jar包版本 jar包 文件名 jar包 的作用 jar包内包含的主要包路径及主要类 依赖的自有jar包名称 依赖的第三方j ...

  10. jQuery选择器和选取方法 http://www.cnblogs.com/MaxIE/p/4078869.html

    我们已经使用了带有简单Css选择器的jQuery选取函数:$().现在是时候深入了解jQuery选择器语法,以及一些提取和扩充选中元素集的方法了. 一.jQuery选择器 在CSS3选择器标淮草案定义 ...