阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

RHEL6.4 NFS文件共享服务器搭建

171次阅读
没有评论

共计 2653 个字符,预计需要花费 7 分钟才能阅读完成。

RHEL6.4 NFS 文件共享服务器搭建

相关阅读:

Ubuntu 12.04 安装 NFS server http://www.linuxidc.com/Linux/2012-09/70728.htm

NFS 服务器安装配置实现 Ubuntu 12.04 与 ARM 文件共享 http://www.linuxidc.com/Linux/2012-10/73159.htm

Ubuntu 搭建 nfs 服务器 http://www.linuxidc.com/Linux/2012-10/71930.htm

文件服务器 NFS 配置详解 http://www.linuxidc.com/Linux/2013-06/86542.htm

Ubuntu 下搭建 NFS 网络文件系统服务器 http://www.linuxidc.com/Linux/2013-07/87367.htm

Heartbeat_ldirector+LB+NFS 实现 HA 及 LB、文件共享 http://www.linuxidc.com/Linux/2013-06/85292.htm

CentOS 5.5 配置 NFS 服务器教程 http://www.linuxidc.com/Linux/2013-03/81737.htm

Ubuntu 12.10 下 NFS 的安装使用 http://www.linuxidc.com/Linux/2013-03/80478.htm

1 实验方案

使用 2 台 RHEL6.4 虚拟机,其中一台作为 NFS 共享服务器 (192.168.100.1)、另外一台作为测试用的 NFS 客户机(192.168.100.2)

2. 实现

2.1.配置 NFS 共享服务器。

1)安装软件包及创建共享目录。

[root@nfs-server ~]# rpm -q rpcbind nfs-utils

rpcbind-0.2.0-11.el6.x86_64

nfs-utils-1.2.3-36.el6.x86_64

[root@nfs-server ~]# mkdir /nfstest

[root@nfs-server ~]# echo “test file” > /nfstest/nfs.txt  // 创建测试文件

[root@nfs-server ~]# ls -ld /nfstest                // 查看测试目录权限

drwxr-xr-x. 2 root root 4096 Apr 14 07:18 /nfstest

2)修改 nfs 主配置文件 /etc/exports,添加 /nfstest 共享设置。

[root@nfs-server ~]# vim /etc/exports

[root@nfs-server ~]# cat /etc/exports

/nfstest 192.168.100.2(rw,sync,no_root_squash) // 设置为只对 192.168.100.2 用户读写权限,并同步写入内存与硬盘,开放客户端使用 root 身份

3)启用 NFS 相关服务程序。

rpcbind 和 nfs 服务均启动成功后,执行 showmount - e 可查看本机当前已发布的共享资源列表:

[root@nfs-server ~]# service rpcbind start

[root@nfs-server ~]# service nfs start

[root@nfs-server ~]# chkconfig rpcbind on    // 设置开机启动服务

[root@nfs-server ~]# chkconfig nfs on

[root@nfs-server ~]# chkconfig –list rpcbind  // 确保服务开机启动

rpcbind        0:off1:off2:on3:on4:on5:on6:off

[root@nfs-server ~]# chkconfig –list nfs

nfs            0:off1:off2:on3:on4:on5:on6:off

[root@nfs-server ~]# showmount -e localhost    // 查看本机发布共享资源

Export list for localhost:

/nfstest 192.168.100.2

2.2 使用 NFS 客户机,查看及访问 /nfstest 共享。

1)客户端也需要安装相应软件

[root@client01 ~]# rpm -q rpcbind nfs-utils

rpcbind-0.2.0-11.el6.x86_64

nfs-utils-1.2.3-36.el6.x86_64

2)从客户机上查看服务器的 NFS 共享资源列表。

客户机必须安装了 nfs-utils 软件包,才能使用 showmount 命令查看 NFS 资源:

[root@client01 ~]# showmount -e 192.168.100.1

Export list for 192.168.100.1:

/nfstest 192.168.100.2

3)从客户机 192.168.100.2 上挂载 /nfstest 共享,并测试读写权限。

[root@client01 ~]# mount 192.168.100.1:/nfstest /mnt  // 将共享目录挂载到本地 mnt 目录下

[root@client01 ~]# cd /mnt; ls

nfs.txt

[root@client01 mnt]# cd

[root@client01 ~]# cd /mnt;ls

nfs.txt

[root@client01 mnt]# touch aa.txt    // 测试写入权限

[root@client01 mnt]# ll

total 4

-rw-r–r–. 1 root root  0 Apr 14 07:40 aa.txt

-rw-r–r–. 1 root root 10 Apr 14 07:18 nfs.txt

4)设置开机后自动挂载 NFS 共享资源。

[root@client01 ~]# vim /etc/fstab

192.168.100.1:/nfstest  /mnt  nfs  defaults  0 0  // 文件类型为 nfs

[root@client01 ~]# umount /mnt

[root@client01 ~]# mount -a

[root@client01 ~]# mount | tail -n 1

192.168.100.1:/nfsteston /mnt type nfs (rw,vers=4,addr=192.168.100.1,clientaddr=192.168.100.2)                // 开机自动挂载成功

更多 RedHat 相关信息见 RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计2653字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中