设为首页 收藏本站
查看: 1017|回复: 0

[经验分享] nfs 初步使用 创建SERVER AND CLIENT ,share files

[复制链接]
累计签到:2 天
连续签到:1 天
发表于 2016-1-29 08:17:03 | 显示全部楼层 |阅读模式
首先安装NFS服务
1
yum groupinstall "NFS file server"



默认就给安装rpcbind(c6system)了
查询NFS服务向RPC服务注册的端口信息
1
2
3
4
5
6
7
8
9
10
[iyunv@linux-chen ~]# rpcinfo -p localhost      
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  55908  status
    100024    1   tcp  53125  status



因为NFS还没起动,所以,现在没太多注册的端口映射信息。请留意和后面NFS启动后这里的对比


查询下现在NFS服务运行状态
1
2
3
4
5
[iyunv@linux-chen ~]# /etc/init.d/nfs status
rpc.svcgssd 已停
rpc.mountd 已停
nfsd 已停
rpc.rquotad 已停




上边显示没有启动,我们现在启动
1
2
3
4
5
6
[iyunv@linux-chen ~]# /etc/init.d/nfs start
启动 NFS 服务:                                            [确定]
关掉 NFS 配额:                                            [确定]
启动 NFS mountd:                                          [确定]
启动 NFS 守护进程:                                        [确定]
正在启动 RPC idmapd:                                      [确定]



如第一段所说我们在查询下NFS在RPC注册的端口数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[iyunv@linux-chen ~]# rpcinfo -p localhost
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  55908  status
    100024    1   tcp  53125  status
    100011    1   udp    875  rquotad
    100011    2   udp    875  rquotad
    100011    1   tcp    875  rquotad
    100011    2   tcp    875  rquotad
    100005    1   udp  51537  mountd
    100005    1   tcp  49708  mountd
    100005    2   udp  46369  mountd
    100005    2   tcp  49553  mountd
    100005    3   udp  56355  mountd
    100005    3   tcp  39360  mountd
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049  nfs_acl
    100227    3   tcp   2049  nfs_acl
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    2   udp   2049  nfs_acl
    100227    3   udp   2049  nfs_acl
    100021    1   udp  60653  nlockmgr
    100021    3   udp  60653  nlockmgr
    100021    4   udp  60653  nlockmgr
    100021    1   tcp  56339  nlockmgr
    100021    3   tcp  56339  nlockmgr
    100021    4   tcp  56339  nlockmgr



果然多了很多

查询下NFS运行状态
1
2
3
4
5
[iyunv@linux-chen ~]# /etc/init.d/nfs status
rpc.svcgssd 已停
rpc.mountd (pid 1572) 正在运行...
nfsd (pid 1588 1587 1586 1585 1584 1583 1582 1581) 正在运行...
rpc.rquotad (pid 1567) 正在运行...



设置成开机自动启动
1
2
3
4
5
6
[iyunv@linux-chen ~]# chkconfig nfs on
[iyunv@linux-chen ~]# chkconfig rpcbind on
[iyunv@linux-chen ~]# chkconfig --list nfs
nfs            0:off1:off2:on3:on4:on5:on6:off
[iyunv@linux-chen ~]# chkconfig --list rpcbind
rpcbind        0:off1:off2:on3:on4:on5:on6:off





分别more下 rpcbind and nfs server 看看哪个先启动 哪个后启动
[iyunv@linux-chen ~]# more /etc/init.d/rpcbind
#! /bin/sh
#
# rpcbind       Start/Stop RPCbind
#
# chkconfig: 2345 13 87
# description: The rpcbind utility is a server that converts RPC program \
#              numbers into universal addresses. It must be running on the \
#              host to be able to make RPC calls on a server on that machine.
#
# processname: rpcbind
# probe: true
# config: /etc/sysconfig/rpcbind
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
#
# nfs           This shell script takes care of starting and stopping
#               the NFS services.
#
# chkconfig: - 30 60
# description: NFS is a popular protocol for file sharing across networks.
#              This service provides NFS server functionality, which is \
#              configured via the /etc/exports file.
# probe: true
# config: /etc/sysconfig/nfs
### BEGIN INIT INFO
# Provides: nfs
# Required-Start: $local_fs $network $syslog $rpcbind
# Required-Stop: $local_fs $network $syslog $rpcbind
# Default-Stop: 0 1 6
# Short-Description: Start up the NFS server sevice
# Description: NFS is a popular protocol for file sharing across networks \
#              This service provides NFS server functionality, \
#              which is configured via the /etc/exports file.
### END INIT INFO



很明显:rpc先启动nfs后启动,nfs先关闭。rpc后关闭

#####################################################################################
客户端配置  
不用多说,看完上边的肯定看的懂下边的。只启动rpc即可。毕竟咱们是一般的client
1
2
3
4
5
6
[iyunv@localhost ~]# service rpcbind start
[iyunv@localhost ~]# /etc/init.d/rpcbind status
rpcbind (pid  2009) is running...
[iyunv@localhost ~]# chkconfig rpcbind on
[iyunv@localhost ~]# chkconfig --list rpcbind
rpcbind        0:off1:off2:on3:on4:on5:on6:off




##############################################################################
server端配置服务
配置文件位置
[iyunv@linux-chen ~]# ll /etc/exports
-rw-r--r--. 1 root root 0 Jan 12  2010 /etc/exports
1
<span style="font-family:sans-serif;"><br><br>开始共享目录data</span><br>



mkdir /data
复制一些内容到新建目录

cp -r /tmp/temp /data
[iyunv@linux-chen temp]# ls
a.du  b.du  b.sh  leran.log  miao.xx  test1.xx

1
2
3
vi /etc/exports
#shared data for NFS CLIENT at 20160128
/data  10.10.10.1/24(rw,sync)



"rw" 读写权限 “ro”只读权限 “sync”允许写入磁盘权限
重启服务
/etc/init.d/nfs reload
(reload=平滑重启即等连接的服务完成以后再退出)

检查下能否共享:
[iyunv@linux-chen ~]# showmount -e localhost
Export list for localhost:
/data 10.10.10.1/24

##########################################################
CLIENT host


检查下能否共享
1
2
[iyunv@localhost ~]# showmount -e 10.10.10.16
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)



这个错误是因为server host的防火墙没有关闭
所以要在SERVER-HOST操做
1
2
3
4
5
[iyunv@linux-chen ~]# service iptables stop
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:   
CLIENT host 重新检查



1
回到client



[iyunv@localhost ~]# showmount -e 10.10.10.16
Export list for 10.10.10.16:
/data 10.10.10.1/24
即可~!

好!我们现在挂载server的 /data
1
2
3
4
[iyunv@localhost temp]# mount -t nfs 10.10.10.16:/data /nethost
[iyunv@localhost ~]# cd /nethost/temp
[iyunv@localhost temp]# ls
a.du  b.du  b.sh  leran.log  miao.xx  test1.xx




注意:SERVERhost /data 的目录其他人没有写入权限,所以 客户不能写入。修改后即可
chmod -t nfs 777 /data

附录:图片示意
QQ截图20160129081651.jpg


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-170848-1-1.html 上篇帖子: Linux调试工具 strace ldd pstack 下篇帖子: 微软是否该发布Linux版IE? Linux files share
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表