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

    环境准备

    centos 7.x+ 两台

    192.168.40.128(用作NFS服务端)

    192.168.40.129(用作NFS客户端)

    NFS服务端部署(192.168.40.128 机器上面执行)

    1、安装nfs 和 rpcbind

    安装nfs-utils ,rpcbind:

    yum -y install nfs-utils ,rpcbind

    查看是否安装:

    rpm -qa |grep nfs

    rpm -qa |grep rpcbind

    2、关闭防火墙:

    关闭防火墙

    systemctl stop firewalld.service

    禁止防火墙开机自启动

    systemctl disable firewalld.service

    3、启动服务:一定要先启动rpc,然后启动nfs

    nfs需要向rpc注册,rpc一旦重启,所以注册的文件都丢失,其他向注册的服务都需要重启

    启动rpc服务:

    systemctl start rpcbind.service

    启动nfs服务:

    systemctl start nfs.service

    4、设置开机自启动

    设置rpc自己自启动:

    systemctl enable rpcbind.service

    设置rpc自己自启动 :

    systemctl enable nfs.service

    5、查看rpc ,nfs状态

    查看rpc状态:active

    systemctl status rpcbind.service

    查看nfs状态:active

    systemctl status nfs.service

    NFS服务端配置(192.168.40.128 机器上面执行)

    1、在/etc/exports设置NFS服务共享文件夹的位置

    vim /etc/exports:

    /etc/exports追加:/share *(rw,sync,no_root_squash)

    /share 共享的目录

    * :任何人

    rw :读写权限

    sync:资料会先暂存于内存中,而非直接写入硬盘。

    no_root_squash:当登录NFS主机使用共享目录的使用者是root时,其权限将被转换成为匿名使用者,通常它的UID与GID 都会变成nobody身份。

    2、重启rpcbind 然后重启 nfs:

    重启rpc服务:

    systemctl restart rpcbind.service

    重启nfs服务:

    systemctl restart nfs.service

     NFS客户端搭建(192.168.40.129 机器上面执行)

    1、安装nfs 和 rpcbind

    安装nfs-utils ,rpcbind:

    yum -y install nfs-utils ,rpcbind

    查看是否安装:

    rpm -qa |grep nfs

    rpm -qa |grep rpcbind

    2、关闭防火墙:

    关闭防火墙

    systemctl stop firewalld.service

    禁止防火墙开机自启动

    systemctl disable firewalld.service

    3.创NFS文件系统服务端目录(例:/opt/nfs),并赋予用户权限

          mkdir /share

          chown nastors:storage /share

          chmod 777 /share

    5.启动服务:一定要先启动rpc,然后启动nfs

    nfs需要向rpc注册,rpc一旦重启,所以注册的文件都丢失,其他向注册的服务都需要重启

    启动rpc服务:

    systemctl start rpcbind.service

    启动nfs服务:

    systemctl start nfs.service

    6、设置开机自启动

    设置rpc自己自启动:

    systemctl enable rpcbind.service

    设置rpc自己自启动 :

    systemctl enable nfs.service

    7、查看rpc ,nfs状态

    查看rpc状态:active

    systemctl status rpcbind.service

    查看nfs状态:active

    systemctl status nfs.service

    8.查看端口和服务

          rpcinfo –p localhost  看到portmap,nfs,mountd进程都已经开启

    9.查看nfs的设置

          showmount -e localhost  查看exports文件

          showmount -a localhost  查看nfs与主机连接情况

    在客户端挂载服务器192.168.40.128的/share目录

    查看192.168.40.128服务器可挂载的目录:

    showmount -e 192.168.40.128

    10、新建挂载服务端的目录到本地的目录

    mkdir /share

    将服务器上面的共享目录192.168.40.128:/share 挂载到本地的/share目录

    mount -t nfs 192.168.40.128:/share  /share

    11、设置客户端开机时自动挂载192.168.40.128:/share到本地的/share

    在root用户下:

    vim /etc/fstab

    追加:192.168.40.128:/share /share #开机时自动将192.168.40.128:/share 挂在到/share

  • 相关阅读:
    html$css_day05
    html$css_day04
    html$css_day03
    html$css_day02
    html$css_day01
    日常笔记19/3/04-19/3/10
    堆排序
    js对象之XMLHttpReques对象学习
    前端页面显示问题解决步骤(方法)
    SpringBoot跨域小结
  • 原文地址:https://www.cnblogs.com/mjoker0416/p/9908392.html
Copyright © 2011-2022 走看看