1. 首页
  2. 软件开发
  3. Linux
  4. linux nfs 服务启用以及开发权限配置

linux nfs 服务启用以及开发权限配置

  • 发布于 2024-09-20
  • 0 次阅读

文章出处:http://www.linuxidc.com/Linux/2014-05/101165.htm

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

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-05/101165.htm

本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2014-05/101165.htm

原文链接: https://blog.csdn.net/javajingling/article/details/47171135