zoukankan      html  css  js  c++  java
  • NFS学习

      linux下搭建nfs服务:

      NFS是network filesystem的缩写,它可以通过网络,让不同的机器、不同的操作系统共享文件。

      NFS支持的功能比较多,默认端口也是随机的,基于远程调用服务(RPC)服务支持,rpc使用111端口监听,然后收到客户端请求后回复nfs工作的端口,客户端再拿着这个端口号去访问nfs共享。

      启动NFS之前,必须先启动RPC服务,否则NFS无法想RPC注册。nfs其实很简单,只是要基于rpc服务,所以要先安装rpc软件且运行后,才能运行nfs。这边我是学习,就不讲解具体原理了,如果看原理,请点击最下面的链接查看详情;

      系统环境:centos 7.6

      1、查看系统是否安装了nfs和rpc

    [root@nfs01 ~]# rpm -qa | grep  rpcbind
    rpcbind-0.2.0-47.el7.x86_64
    [root@nfs01 ~]# rpm -qa | grep nfs
    nfs-utils-1.3.0-0.61.el7.x86_64
    

      2、我这里已经安装了,如果没有安装,就安装nfs和rpc

    [root@nfs01 ~]# yum install -y nfs-utils rpcbind
    

      3、服务端配置

    在nfs服务器上创建共享目录,并给予权限

    [root@nfs01 ~]# mkdir -p /share
    [root@nfs01 ~]# chown nfsnobody.nfsnobody /share
    [root@nfs01 ~]# ls -ld /share
    drwxr-xr-x 2 nfsnobody nfsnobody 6 May 30 17:08 /share
    

      4、服务端启动rpc服务和nfs服务

    [root@nfs01 ~]# systemctl start rpcbind
    [root@nfs01 ~]# systemctl enable rpcbind
    [root@nfs01 ~]# systemctl start nfs
    [root@nfs01 ~]# ps -ef |grep nfs
    [root@nfs01 data]# rpcinfo -p localhost
    

      5、编辑exports文件

    [root@nfs01 ~]# vim /etc/exports
    /share 172.16.1.0/24(rw,sync,all_squash)

    常用all_squash参数,即将所有来访用户变成nfsnobody用户访问。

      6、重启nfs并检查挂载

    [root@nfs01 ~]# systemctl restart nfs
    [root@nfs01 ~]# showmount -e localhost
    Export list for localhost:
    /share 172.16.1.0/24

      7、客户端挂载

    客户端必须安装rpcbind软件,最好也安装nfs服务,不然没办法运行showmount命令

    客户端先检查服务共享目录,再进行挂载,最后查看挂载结果

    [root@web01 ~]# showmount -e 172.16.1.31
    Export list for 172.16.1.31:
    /share 172.16.1.0/24
    [root@web01 ~]# mount -t nfs 172.16.1.31:/share /share -o proto=tcp
    [root@web01 ~]# df -h

      8、客户端测试

    [root@web01 ~]# cd /share
    [root@web01 share]# touch 123.txt

    上述都是基于关闭防火墙的配置(iptables -F),服务端的nfs最好加入开机自启动,客户端开机自动挂载。

     详细过程及参考文献:https://www.cnblogs.com/liuyisai/p/5992511.html

      

  • 相关阅读:
    UVa 1595
    求树直径及所有直径顶点

    python-sort()/sorted()比较
    MNIST数据集分类简单版本
    Tensorlflow-解决非线性回归问题
    Tensorlflow-神经网络解决非线性回归问题
    tensorflow基础-placeholder
    Tensorflow基础-mnist数据集
    Week 3: Structured Types 5. Tuples and Lists Exercise: odd tuples
  • 原文地址:https://www.cnblogs.com/zhanbing/p/10950949.html
Copyright © 2011-2022 走看看