zoukankan      html  css  js  c++  java
  • Linux 配置nfs

    1、
    NFS的安装是非常简单的,只需要两个软件包即可,而且在通常情况下,是作为系统的默认包安装的。
     ?nfs-utils-* :包括基本的NFS命令与监控程序 
     ?portmap-* :支持安全NFS RPC服务的连接
    
    
    yum -y install nfs-utils portmap 
    
    centos 6(在CentOS 6.5当中,portmap服务由rpcbind负责) :
    
    yum -y install nfs-utils rpcbind 
    
    
    [root@centos2 /]# service rpcbind start
    
    Starting rpcbind:                                          [  OK  ]
    
    [root@centos2 /]# service nfs start
    
    
    
    
    vim /etc/exports
    在exports文件中添加
    /sharedisk    192.168.0.0/24(rw,no_root_squash,async)
    #表示将/sharedisk这个目录共享给192.168.0.*这些客户机,括号中的参数设置意义为:
    
    01 ro                     该主机对该共享目录有只读权限
    02 rw                    该主机对该共享目录有读写权限
    03 root_squash       客户机用root用户访问该共享文件夹时,将root用户映射成匿名用户
    04 no_root_squash  客户机用root访问该共享文件夹时,不映射root用户
    05 all_squash          客户机上的任何用户访问该共享目录时都映射成匿名用户
    06 anonuid             将客户机上的用户映射成指定的本地用户ID的用户
    07 anongid             将客户机上的用户映射成属于指定的本地用户组ID
    08 sync                  资料同步写入到内存与硬盘中
    09 async                资料会先暂存于内存中,而非直接写入硬盘
    10 insecure            允许从这台机器过来的非授权访问
    3、重启nfs 或者使用exportfs命令使设置生效
    重启nfs:
    service nfs restart用exportfs
    exportfs -rv#exportfs用法
    -a :全部mount或者unmount /etc/exports中的内容
    -r :重新mount /etc/exports中分享出来的目录
    -u :umount 目录
    -v :将详细的信息输出到屏幕上
    这样nfs的服务器端就设置好了。
    
    
    
    
    
    
    2.服务器端配置:
    v-lhb-nfs01:/root# mkdir /usr/local/test
    v-lhb-nfs01:/root# vi /etc/exports 
    v-lhb-nfs01:/root# vi /etc/exports 
    v-lhb-nfs01:/root# cat /etc/exports 
    /usr/local/test/ 192.168.32.*(rw,no_root_squash,no_all_squash,sync)
    
    
    centos6:
     
    
    [root@centos2 /]# service rpcbind restart
    
    Starting rpcbind:                                          [  OK  ]
    
    [root@centos2 /]# service nfs restart
    
    Starting NFS services:                                     [  OK  ]
    
    Starting NFS quotas:                                       [  OK  ]
    
    Starting NFS mountd:                                       [  OK  ]
    
    Stopping RPC idmapd:                                       [  OK  ]
    
    Starting RPC idmapd:                                       [  OK  ]
    
    Starting NFS daemon:                                       [  OK  ]
    
    [root@centos2 /]# 
    
    
    centos 5
     
    [root@centos2 /]# service portmap start
    
    [root@centos2 /]# service nfs start
    
    [root@centos2 /]# 
    
    
    
    3、服务器端使用showmount命令查询NFS的共享状态
     
    # showmount -e    //默认查看自己共享的服务,前提是要DNS能解析自己,不然容易报错
    
    
    # showmount -a    //显示已经与客户端连接上的目录信息
    
    v-lhb-nfs01:/root# exportfs
    /usr/local/test
    		192.168.32.*
    
    
    4.客户端挂载:
    
    v-lhb-app01:/root# mkdir /nfs01
    
    
    
    mount -t nfs 11.3.52.4:/nfs01 /nfs01  -o proto=tcp -o nolock 
    

  • 相关阅读:
    MySQL日志15连问
    Call to undefined function cli_set_process_title,cli_set_process_title 信息/选项函数
    swoole 笔记
    linux 查找目录下的所有文件中是否包含某个字符串
    请说下redis命令的时间复杂度??(实际问的是redis底层结构)
    Elasticsearch:Fatal error: Uncaught Error: Class PsrLogNullLogger
    ElasticSearch近实时搜索的实现
    离职后心生不满,西安某医院运维“炫技性报复”破坏诊疗系统,被依法刑拘...
    报错: libmysqlclient.so.20: cannot open shared object file: No such file or directory(亲测可用)
    中国程序员有美国梦吗?
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351668.html
Copyright © 2011-2022 走看看