zoukankan      html  css  js  c++  java
  • centos安装nfs并设置开机自启动

    nfs挂载:

    客户端服务器端安装nfs:

    yum install -y nfs-utils

    服务器端操作:

    启动nfsrpcbind:

    systemctl start nfs & systemctl enable nfs
    
    systemctl start rpcbind & systemctl enable rpcbind

    创建需要共享的目录(例如):

    mkdir /home/mnt/question/

    设置nfs共享目录权限:

    vim /etc/exports

    添加(红色ip为nfs服务端ip),:wq保存退出

    /home/mnt/question 192.168.1.30/24(rw,sync)

    此处rw表示可读写,sync表示文件同时写入硬盘和内存

    设置权限

    chmod -R 777 /home/mnt/question

    重启nfs服务

    systemctl restart nfs & systemctl restart rpcbind

    客户端操作:

    创建需要挂载nfs的目录(例如):

    mkdir /home/attachments

    添加挂载目录:

    mount -t nfs 192.168.1.30:/home/mnt/question /home/attachments/

    测试是否挂载成功:

    客户端操作:

    cd /home/attachments
    
    mkdir test

    服务器端操作:

    cd /home/mnt/question

    ls查看能看到test文件夹证明挂载成功

    如果挂载不成功的话请关闭nfs服务器的防火墙

    firewall-cmd --state
    
    systemctl stop firewalld
    
    systemctl disable firewalld

    开机自启动nfs:

    因为在centos7/etc/rc.d/rc.local的权限被降低了,所以需要赋予其可执行权

    chmod +x /etc/rc.d/rc.local

    编写自启动脚本

    红色所代表的ipplatform所在机器对应的ip

    vim /usr/local/sbin/nfsboot.sh

    往脚本填写一下内容:

    #! /bin/bash
    
     
    
    ## This is nfs自启动 shell script.
    
    ## Writen by Luyouzhi 2020-04-03.
    
     
    
    date
    
    mount -t nfs 192.168.1.30:/home/mnt/question /home/attachments/
    
    echo "nfs自启动 success!!"

    赋予脚本可执行权限

    chmod +x /usr/local/sbin/nfsboot.sh

    打开/etc/rc.d/rc.local文件,在末尾增加如下内容

    /usr/local/sbin/nfsboot.sh
  • 相关阅读:
    Windows Phone自学笔记(2)
    对MVC的初步认识
    CMSIS 的相关知识
    关于机器码的一些疑惑
    关于预编译处理的尝试
    IAR提示错误C:\Program Files\IAR Systems\Embedded Workbench 6.4 Kickstart\arm\bin路径下的armjlink.dll文件
    Spring学习笔记(四)
    Spring学习笔记(三)
    Docker容器数据卷(v创建数据卷)
    Spring5学习笔记(一)
  • 原文地址:https://www.cnblogs.com/longchengruoxi/p/12654590.html
Copyright © 2011-2022 走看看