利用空余时间,做个nfs共享实验,岂不美滋滋!!!

系统测试环境:

主机ip 系统     主机名(服务)
192.168.241.130    centos6.5    hadoop1(nfs-srever)
192.168.241.133    centos6.5    hadoop2(nfs-client1)
192.168.241.134    centos6.5    hadoop2(nfs-client2)

为了测试,三台服务器全部关了软件防火墙,在生产环境中需要做防火墙规则,我会在在后面对这块做详细说明。

服务器端(hadoop1上):

[root@hadoop1 ~]# yum -y install nfs-utils rpcbind

nfs的相关说明:

NFS的常用目录如下
/etc/exports                           NFS服务的主要配置文件
/usr/sbin/exportfs                   NFS服务的管理命令
/usr/sbin/showmount              客户端的查看命令
/var/lib/nfs/etab                      记录NFS分享出来的目录的完整权限设定值
/var/lib/nfs/xtab                      记录曾经登录过的客户端信息

  编辑nfs配置文件

NFS服务的配置文件为 /etc/exports,这个文件是NFS的主要配置文件,不过系统并没有默认值,所以这个文件不一定会存在,可能要使用vim手动建立,然后在文件里面写入配置内容。

  vim /etc/exports 

/test *(rw,sync,no_root_squash,insecure)

  注意:我开始写的是 /test  192.168.241.130(rw,sync,no_root_squash,insecure),但是这样客户端(hadoop2和hadoop3上)挂载事就会出现这种情况

[root@hadoop2 /]# mount -t nfs 192.168.241.130:/test /nfsclient
mount.nfs: access denied by server while mounting 192.168.241.130:/test

 后来上网找了解决方式就是按照我上面的方式才行,真是无语。

解释说明
/nfs/server 192.168.0.0/255.255.255.0(rw,no_root_squash)
1、每行分两部分,由空格分开。
2、第一部份(空格之前的那段)是你要共享出去的目录。
3、第二部份(空格之后的那段)又可以分三部分:
(1)、“192.168.0.0”表示有权共享本目录的IP网段。
(2)、“255.255.255.0”是那个有权共享的网段所用的掩码
(3)、括号里面又有两部分,用逗号隔开:
(i)、“rw”表示来访者对所共享出去的目录享有读和写的权力,如果只给读不给写就将之换成“ro” (意思是 Read Only)
(ii)、"no_root_squash"表示如果来访者是该机的 root 则在本机也给予 root 待遇,如果没有"no_root_squash"(以及前面的逗号),那来访者在本机只相当于本机的 nobody 用户。
(iii)、insecure:允许客户端从大于1024的tcp/ip端口连接服务器

启动服务端的服务 

[root@hadoop1 test]# /etc/init.d/rpcbind start
[root@hadoop1 test]# /etc/init.d/nfslock start
[root@hadoop1 test]# /etc/init.d/nfs start
注意启动顺序,一定是上面的顺序,否则会出错

设置开机自启动

[root@hadoop1 test]# chkconfig rpcbind on
[root@hadoop1 test]# chkconfig nfslock on
[root@hadoop1 test]# chkconfig nfs on

检查服务是否开启

[root@hadoop1 test]# ps -ef |grep nfs
root       4987      2  0 17:57 ?        00:00:00 [nfsd4]
root       4988      2  0 17:57 ?        00:00:00 [nfsd4_callbacks]
root       4989      2  0 17:57 ?        00:00:00 [nfsd]
root       4990      2  0 17:57 ?        00:00:00 [nfsd]
root       4991      2  0 17:57 ?        00:00:00 [nfsd]
root       4992      2  0 17:57 ?        00:00:00 [nfsd]
root       4993      2  0 17:57 ?        00:00:00 [nfsd]
root       4994      2  0 17:57 ?        00:00:00 [nfsd]
root       4995      2  0 17:57 ?        00:00:00 [nfsd]
root       4996      2  0 17:57 ?        00:00:00 [nfsd]
root       5126   4011  0 18:04 pts/0    00:00:00 grep nfs
[root@hadoop1 test]# ps -ef |grep rpcbind
rpc        3674      1  0 17:16 ?        00:00:00 rpcbind
root       5128   4011  0 18:04 pts/0    00:00:00 grep rpcbind
[root@hadoop1 test]# netstat -tanpl |grep rpc
tcp        0      0 0.0.0.0:875                 0.0.0.0:*                   LISTEN      4977/rpc.rquotad
tcp        0      0 0.0.0.0:48590               0.0.0.0:*                   LISTEN      4981/rpc.mountd
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      3674/rpcbind
tcp        0      0 0.0.0.0:50960               0.0.0.0:*                   LISTEN      4981/rpc.mountd
tcp        0      0 0.0.0.0:59572               0.0.0.0:*                   LISTEN      3692/rpc.statd
tcp        0      0 0.0.0.0:50461               0.0.0.0:*                   LISTEN      4981/rpc.mountd
tcp        0      0 :::36045                    :::*                        LISTEN      4981/rpc.mountd
tcp        0      0 :::111                      :::*                        LISTEN      3674/rpcbind
tcp        0      0 :::49659                    :::*                        LISTEN      4981/rpc.mountd
tcp        0      0 :::60635                    :::*                        LISTEN      3692/rpc.statd
tcp        0      0 :::45215                    :::*                        LISTEN      4981/rpc.mountd   

hadoop2和hadoop3客户端操作,以hadoop2为例说明

[root@hadoop2 ~]# yum -y install nfs-utils

 在本机使用命令可以看到共享目录,在客户端安装了nfs-utils软件后,使用同样的命令也可以看到。

[root@hadoop1 test]# showmount -e 192.168.241.130
Export list for 192.168.241.130:
/test *  

在hadoop2上创建挂载目录,并将本地目录(nfsclient)挂载到nfs共享目录(test)上去

mkdir /nfsclient
[root@hadoop2 /]# mount -t nfs 192.168.241.130:/test /nfsclient

此时在各自的挂载目录上做一系列测试证明nfs共享是否成功

在nfs-server上,也就是hadoop1上做以下操作

[root@hadoop1 test]# mkdir data lala haha
[root@hadoop1 test]# vim page.test
this is test page  !!!

 那么在nfsclient1的/nfsclient目录下看看有没有这些内容

[root@hadoop2 nfsclient]# cat page.test
this is test page  !!!
[root@hadoop2 nfsclient]# pwd
/nfsclient

  显然,这是成功的,但是这样还不全面的,我们从客户端再做一些测试

我们将这下面的东西全部删掉

[root@hadoop2 nfsclient]# ls
data  haha  lala  page.test
[root@hadoop2 nfsclient]# rm -rf ./*
[root@hadoop2 nfsclient]# ls
[root@hadoop2 nfsclient]# pwd
/nfsclient

 看下nfsserver(hadoop1)的/test目录下还有没有,看下服务端hadoop1,显然没有了。

[root@hadoop1 test]# ls
[root@hadoop1 test]# pwd
/test

 那么再测试下客户端写入文件,在服务端能否看到和删除。

[root@hadoop2 nfsclient]# pwd
/nfsclient
[root@hadoop2 nfsclient]# mkdir zhangsan lisi wangwu
[root@hadoop2 nfsclient]# vim nongyao.txt
laalalalalalalalala

 看下服务端 

[root@hadoop1 test]# pwd
/test
[root@hadoop1 test]# cat nongyao.txt
laalalalalalalalala

显然服务端是有的,这就形成了数据共享,不用测试,hadoop3也是一样的,这样一个简单的nfs共享服务器就做成了。

cnetos6上实现nfs共享的更多相关文章

  1. 在CentOS7上实现NFS共享

    一.介绍 NFS 是Network File System的缩写,即网络文件系统.一种使用于分散式文件系统的协定,功能是让客户端通过网络访问不同主机上磁盘里的数据,主要用在类Unix系统上实现文件共享 ...

  2. 工程师技术(四):配置SMB文件夹共享、多用户Samba挂载、普通NFS共享的实现、安全NFS共享的实现

    一.配置SMB文件夹共享 目标: 本例要求在虚拟机 server0 上发布两个共享文件夹,具体要求如下: 1> 此服务器必须是 STAFF 工作组的一个成员   2> 发布目录 /comm ...

  3. 配置samba和NFS共享服务

                            配置samba和NFS共享服务 1案例1:配置SMB文件夹共享 1.1问题 本例要求在虚拟机server0上发布两个共享文件夹,具体要求如下: 此服务器 ...

  4. 【Oracle 集群】11G RAC 知识图文详细教程之RAC在LINUX上使用NFS安装前准备(六)

    RAC在LINUX上使用NFS安装前准备(六) 概述:写下本文档的初衷和动力,来源于上篇的<oracle基本操作手册>.oracle基本操作手册是作者研一假期对oracle基础知识学习的汇 ...

  5. 关于nfs共享目录的使用技巧

    nfs客户端的使用 1.查看nfs服务器信息挂载信息 1)在客户端,要查看nfs服务器上有哪些共享目录 # showmount -e nfs服务器ip 在客户端,要查看nfs服务器上有哪些客户端的目录 ...

  6. ubuntu下建立NFS共享,并用开发板挂载

    安装NFS服务 apt-get install nfs-kernel-server nfs-common apt-get install portmap 在/etc/exports里加入 /home/ ...

  7. 生产场景NFS共享存储优化及实战

    生产场景NFS共享存储优化: 1.硬件:sas/ssd磁盘,买多块,raid0/raid10,网卡好 2.NFS服务器端优化加all_squash,async /backup/NFS 192.168. ...

  8. Ubuntu在ARM上建立NFS服务

    先引用别人的做法: 1.进行NFS服务器端与客户端的安装: sudo apt-get install nfs-kernel-server nfs-common portmap 安装客户端的作用是可以在 ...

  9. Suse 创建NFS共享目录

    Suse 创建NFS共享目录 服务端的配置: 1.编辑nfs服务的配置文件 /software/suse11 *(rw,sync,no_root_squash,no_all_squash) 凝视: / ...

随机推荐

  1. 2019.01.19 codeforces915E.Physical Education Lessons(ODT)

    传送门 ODT水题(当然可以上线段树) 支持区间01覆盖,询问全局1的个数. 思路:直接上ODTODTODT. 不会的点这里 代码: #include<bits/stdc++.h> #de ...

  2. tomat修改启动路径

    https://blog.csdn.net/axela30w/article/details/76546735

  3. spring cloud 组件图

    spring cloud 提供了一套微服务的框架. 上图就是微服务一些常用的组件. 1.EureKa 实现服务的注册和发现. 2.Ribbon 实现服务的调用(客户端实现负载均衡) 3.Feign 实 ...

  4. ZOJ 3216 Compositions (矩阵快速幂)

    题意:求把 n 拆成几个大于等于 k 的数的和的方案数. 析:根据题目很容易写出递推式,f[i] = f[i-1] + f[i-k],什么意思呢,f[i-1] 表示是进行加 1 操作,那么可以给 n- ...

  5. FPGA速度等级

    转自http://wenku.baidu.com/view/ea793deef8c75fbfc77db263.html?from=rec 最初接触speed grade这个概念时,很是为Altera的 ...

  6. ROM的一种写法

    module mr_rom_pll_valuemask_8bpc #( , , , , // 6*7 // alt_clogb2(42) ) ( input wire clock, :] addr_p ...

  7. python中global 和 nonlocal的使用

    1.global关键字用来在函数或其他局部作用域中使用全局变量.但是如果不修改全局变量也可以不使用global关键字. gcount = 0 def global_test(): gcount+=1 ...

  8. mysql 数据类型及java对应关系

    http://www.cnblogs.com/jerrylz/p/5814460.html    Java数据类型和MySql数据类型对应表 http://www.cnblogs.com/yiwd/p ...

  9. 踏破铁鞋无觅处,从AsyncTask学Android线程池

    android对于主线程的响应时间限制的非常严格,稍有不慎就会遇到Application Not Responding(ANR)的弹框.用户可以轻点手指关掉你的APP.官方文档写的非常明确!同时,保持 ...

  10. js中对String去空格

    str为要去除空格的字符串: 去除所有空格: str = str.replace(/\s+/g,""); 去除两头空格: str = str.replace(/^\s+|\s+$/ ...