zoukankan      html  css  js  c++  java
  • RHEL6.4 NFS文件共享服务搭建

    NFS文件共享服务

    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)                 //开机自动挂载成功

    http://jinjianjun.blog.51cto.com/8539251/1395621

  • 相关阅读:
    Java内存区域
    高并发
    集合框架
    面向对象基础概念
    java synchronized详解
    java使用DOM操作XML
    二、认识Xcode(第一个工程:Hello world)
    菜鸟手下的iOS开发笔记(swift)
    一、iOS开发环境搭建
    一个基于JRTPLIB的轻量级RTSP客户端(myRTSPClient)——实现篇:(十)使用JRTPLIB传输RTP数据
  • 原文地址:https://www.cnblogs.com/findumars/p/5618345.html
Copyright © 2011-2022 走看看