首先安装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 重新检查
|
[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
附录:图片示意
|