简介
NFS、网络文件系统的缩写、网络文件系统。功能:可以通过网络进程文件共享。
环境准备:
1、操作系统为Centos 6.8
2、rpc服务、nfs服务
3、服务器
NFS服务器(双节点,这里只配一个节点):A
WEB服务器(双节点):B
数据中心服务器(双节点):C
A作为文件共享服务器,C生成的数据文件可以写到A,B可以从A进行文件查询、下载。
一、服务端(A):
1、检查服务必要的服务是否已安装。如果没安装则需要安装并且启动。
命令:rpm -qa |grep -i -E 'rpc|nfs'
实操:
[root@localhost etc]# rpm -qa |grep -i nfs
n
n
[root@localhost etc]# yum install rpcbind
已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
包 r 已安装并且是最新版本
无须任何处理
[root@localhost etc]# netstat -an|grep 2049
[root@localhost etc]# service nfs status
r 已停
r 已停
nfsd 已停
[root@localhost etc]# service rpc status
rpc: 未被识别的服务
[root@localhost etc]# service rpcbind status
rpcbind 已停
[root@localhost etc]# service rpcbind restart
停止 rpcbind: [失败]
正在启动 rpcbind: [确定]
[root@localhost etc]# service rpcbind status
rpcbind (pid 45196) 正在运行…
[root@localhost etc]#
[root@localhost etc]#
[root@localhost etc]# netstat -an|grep 2049
[root@localhost etc]#
[root@localhost etc]# service nfs start
启动 NFS 服务: exportfs: duplicated export entries:
exportfs: 10.98.201.16
exportfs: 10.98.201.16
[确定]
启动 NFS mountd: [确定]
启动 NFS 守护进程: [确定]
正在启动 RPC idmapd: [确定]
[root@localhost etc]#
[root@localhost etc]# netstat -an|grep 2049
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN
tcp 0 0 :::2049 :::* LISTEN
udp 0 0 0.0.0.0:2049 0.0.0.0:*
udp 0 0 :::2049 :::*
[root@localhost etc]#
[root@localhost etc]#
2、配置exports
命令:vi /etc/exports
实操:
[root@localhost ~]$ vi /etc/exports
/data/app/data-center/nfsfiles 10.98.201.16(rw,no_root_squash,sync)
/data/app/data-center/nfsfiles 10.98.201.17(rw,no_root_squash,sync)
/data/app/data-center/nfsfiles 10.255.80.116(rw,all_squash,sync)
/data/app/data-center/nfsfiles 10.255.80.117(rw,all_squash,sync)
[root@localhost ~]$
二、客户端(C):
1、数据中心(data)节点,读写权限。本地的目录需要与配置中心的一致。譬如,配置中心配置的是 nfsfiles ,如下
#配置中心的导出文件路径
boxByLfsPath = nfsfiles
1)、C-节点1:10.98.201.16
命令:
mkdir -p ~/gnete-datasc-itfs-biz/datasc_file
mount -t nfs 10.211.201.91:/data/app/data-center/nfsfiles ~/gnete-datasc-itfs-biz/nfsfiles -o nolock
touch
实操:
[root@localhost ~]# mount -t nfs 10.211.201.91:/data/app/data-center/nfsfiles /home/app/data/datasc_file -o nolock
mount: wrong fs type, bad option, bad superblock on 10.211.201.91:/data/app/data-center/nfsfiles,
missing codepage or helper program, or other error
(for several filesystems . nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog – try
dmesg | tail or so
[root@localhost ~]#
[root@localhost ~]# service nfs status
nfs: 未被识别的服务
[root@localhost ~]#
[root@localhost ~]# rpm -qa|grep -i nfs
[root@localhost ~]# yum install nfs-utils -y
已加载插件:fastestmirror
设置安装进程
Determining fastest mirrors
base | 4.0 kB 00:00
解决依赖关系
–> 执行事务检查
—> Package n 1:1.2.3-78.el6 will be 安装
–> 处理依赖关系 nfs-utils-lib >= 1.1.0-3,它被软件包 1:n 需要
–> 处理依赖关系 libtirpc >= 0.2.1-11,它被软件包 1:n 需要
–> 处理依赖关系 keyutils >= 1.4-4,它被软件包 1:n 需要
–> 处理依赖关系 rpcbind,它被软件包 1:n 需要
–> 处理依赖关系 python-argparse,它被软件包 1:n 需要
–> 处理依赖关系 libg(libgssapi_CITI_2)(64bit),它被软件包 1:n 需要
–> 处理依赖关系 libgssglue,它被软件包 1:n 需要
–> 处理依赖关系 libevent,它被软件包 1:n 需要
–> 处理依赖关系 lib()(64bit),它被软件包 1:n 需要
–> 处理依赖关系 libn()(64bit),它被软件包 1:n 需要
–> 处理依赖关系 libg()(64bit),它被软件包 1:n 需要
–> 处理依赖关系 libeven()(64bit),它被软件包 1:n 需要
–> 执行事务检查
—> Package keyu 0:1.4-5.el6 will be 安装
—> Package libevent.x86_64 0:1.4.13-4.el6 will be 安装
—> Package libg 0:0.1-11.el6 will be 安装
—> Package lib 0:0.2.1-15.el6 will be 安装
—> Package n 0:1.1.5-13.el6 will be 安装
—> Package 0:1.2.1-2.1.el6 will be 安装
—> Package r 0:0.2.0-16.el6 will be 安装
–> 完成依赖关系计算
依赖关系解决
============================================================================================================================================================================================================================================
软件包 架构 版本 仓库 大小
============================================================================================================================================================================================================================================
正在安装:
nfs-utils x86_64 1:1.2.3-78.el6 base 336 k
为依赖而安装:
keyutils x86_64 1.4-5.el6 base 39 k
libevent x86_64 1.4.13-4.el6 base 66 k
libgssglue x86_64 0.1-11.el6 base 23 k
libtirpc x86_64 0.2.1-15.el6 base 82 k
nfs-utils-lib x86_64 1.1.5-13.el6 base 71 k
python-argparse noarch 1.2.1-2.1.el6 base 48 k
rpcbind x86_64 0.2.0-16.el6 base 51 k
事务概要
============================================================================================================================================================================================================================================
Install 8 Package(s)
总下载量:716 k
Installed size: 2.0 M
下载软件包:
(1/8): r.rpm | 51 kB 00:00
(2/8): keyu | 39 kB 00:00
(3/8): libeven | 66 kB 00:00
(4/8): n.rpm | 336 kB 00:00
(5/8): n.rpm | 71 kB 00:00
(6/8): lib | 82 kB 00:00
(7/8): | 48 kB 00:00
(8/8): libg | 23 kB 00:00
——————————————————————————————————————————————————————————————————————————————–
总计 19 MB/s | 716 kB 00:00
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
正在安装 : libg 1/8
正在安装 : lib 2/8
正在安装 : r 3/8
正在安装 : 4/8
正在安装 : libeven 5/8
正在安装 : keyu 6/8
正在安装 : n 7/8
正在安装 : 1:n 8/8
Verifying : r 1/8
Verifying : keyu 2/8
Verifying : libeven 3/8
Verifying : 1:n 4/8
Verifying : n 5/8
Verifying : lib 6/8
Verifying : 7/8
Verifying : libg 8/8
已安装:
n 1:1.2.3-78.el6
作为依赖被安装:
keyu 0:1.4-5.el6 libevent.x86_64 0:1.4.13-4.el6 libg 0:0.1-11.el6 lib 0:0.2.1-15.el6 n 0:1.1.5-13.el6 0:1.2.1-2.1.el6 r 0:0.2.0-16.el6
完毕!
[root@localhost ~]# mount -t nfs 10.211.201.91:/data/app/data-center/nfsfiles /home/app/data/datasc_file -o nolock
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
46G 2.7G 41G 7% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 477M 39M 413M 9% /boot
10.211.201.91:/data/app/data-center/nfsfiles
538G 2.5G 509G 1% /home/app/data/datasc_file
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
46G 2.7G 41G 7% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 477M 39M 413M 9% /boot
10.211.201.91:/data/app/data-center/nfsfiles
538G 2.5G 509G 1% /home/app/data/datasc_file
[root@localhost ~]# su – app
[app@localhost datasc_file]#cd /home/app/data/datasc_file
[app@localhost datasc_file]#
[app@localhost datasc_file]# touch
ls -lrt
总用量 0
-rw-rw-r–. 1 app app 0 2月 14 23:33
[app@localhost datasc_file]#
2)、C-节点2:10.98.201.17
命令、操作与节点1相同
三、客户端(B):
1、该节点的权限为只读。本地的目录需要与配置中心的一致。譬如,配置中心配置的是datasc_file,如下
#下载交易明细文件使用目录
testFileRemotePath = datasc_file/
testFileLocalTempPath = temp/
1)、B-节点1:10.255.80.116
命令:
mkdir -p ~/aix-web/datasc_file
mount -t nfs -o nolock 10.211.201.91:/data/app/data-center/nfsfiles ~/aix-web/datasc_file
实操:
[root@localhost datasc_file]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
46G 2.6G 41G 6% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 477M 39M 413M 9% /boot
10.211.201.91:/data/app/data-center/nfsfiles
538G 2.5G 509G 1% /home/app/aix-web/datasc_file
[root@localhost datasc_file]#
[root@localhost datasc_file]# pwd
/home/app/gnete-msc-web/datasc_file
[root@localhost datasc_file]#
[root@localhost datasc_file]# touch da
touch: 无法创建"da": 权限不够
[root@localhost datasc_file]#
2)、B-节点2:10.255.80.117
节点2操作与节点1相同
1.《nfs9,干货看这篇!NFS共享文件服务器搭建》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。
2.《nfs9,干货看这篇!NFS共享文件服务器搭建》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。
3.文章转载时请保留本站内容来源地址,https://www.cxvn.com/gl/djyxgl/147315.html