• 文件共享NFS


    文件共享NFS

    使用场景说明

      如图当我们有这样一个场景,s1系统在运行过程中生成了日志写入到logs中,当s2系统需要读取这些信息时怎么办,这里就需要使用nfs文件共享工具,通过对文件进行挂载实现多台服务器之间文件夹中文件的共享;

    安装

     首先看是否安装了nfs

    rpm -qa|grep nfs
    rpm -qa|grep rpcbind
    

     没有的话我们进行安装
       yum -y install rpcbind nfs-utils
     安装后我们来分一下客户端与服务端
      服务端是把自己的文件夹进行暴露给别人进行挂载的
      客户端是通过挂载来共享使用他人的文件夹

    服务端

     新建一个文件夹并对该文件夹进行赋予权限

    mkdir logs
    chmod -R 777 logs
    

     对该文件夹进行暴露处理

      vi /etc/exports

    /home/esblogs *(rw,sync,no_root_squash) or
    /primetonesb67/esblog *(rw,sync,no_root_squash) or
    /primetonesb67/esblog 192.168.100.0/24(rw,sync,no_root_squash)
    

      配置完后使用exportfs -r命令进行生效
      启动或者重启服务

    service nfs restart  重启
    systemctl start nfs  启动
    systemctl start rpcbind
    systemctl status nfs 查看状态
    systemctl status rpcbind
    showmount -e ip      查看开放的目录
    df -h                查看机器挂载情况
    

    客户端

      安装完后我们通过命令查看已经暴露的挂载文件
      找到我们要挂在的文件进行挂载
      mount -t nfs ip:xxx/xxxx xxx/xxx

    配置

      我们要注意是否能找到暴露的文件夹和是否能挂载上很大部分的原因是防火墙端口是否开启

    1.查看端口情况
     rpcinfo -p localhost
    2.分配端口,编辑配置文件: 
    # vim /etc/sysconfig/nfs 
    添加: 
     RQUOTAD_PORT=30001 
     LOCKD_TCPPORT=30002 
     LOCKD_UDPPORT=30002 
     MOUNTD_PORT=30003 
     STATD_PORT=30004 
    进行固定端口
    3.重启rpc、nfs的配置与服务:
     systemctl restart rpcbind.service
     systemctl restart nfs.service
    4.还需在/etc/modprobe.d/lockd.conf中添加以下设置:
     options lockd nlm_tcpport=30002
     options lockd nlm_udpport=30002
    5.重新加载NFS配置和服务:
     systemctl restart nfs-config
     systemctl restart nfs-idmap
     systemctl restart nfs-lock
     systemctl restart nfs-server
    参考 https://www.cnblogs.com/zhaojingyu/p/10529945.html
    

      开机自启

    systemctl enable nfs-server.server
    
     systemctl enable rpcbind
    

      开机自动挂载
      在rc.local中写上脚本
      mount -t nfs ip:xxx/xxxx xxx/xxx

    问题解决

    1.在客户端showmount -e 192.168.122.10遇到以下错误提示,“clnt_create: RPC: Program not registered”
    解决方法:
       服务端[root@server /]# rpc.mountd 即可

  • 相关阅读:
    JNDI 是什么
    RuntimeException和非RuntimeException的区别
    dynamicinsert,dynamicupdate能够性能上的少许提升
    Session,有没有必要使用它?[转]
    c# textbox中光标所在行命令及选中命令移动到最后一行且光标提前[转]
    C#分布式事务(TransactionScope )
    .net中的分布式事务
    大道至简,职场上做人做事做管理[转]
    C#中TreeView的CheckBox的两种级联选择
    C# winform TreeView中关于checkbox选择的完美类[转]
  • 原文地址:https://www.cnblogs.com/wangcr/p/12380898.html
Copyright © 2020-2023  润新知