• 部署NFS


    -----------------------部署NFS-----------------------

    1、NFS的概念

    NFS,是Network File System的简写,即网络文件系统。网络文件系统是FreeBSD支持的文件系统中的一种,也被称为NFS,NFS允许一个系统在网络上与他人共享目录和文件。通过使用NFS,用户和程序可以像访问本地文件一样访问远端系统上的文件。
    运行模式: C/S 模式 。端口:CentOS7以NFSv4作为默认版本,NFSv4使用TCP协议(端口号是2049)和NFS服务器建立连接。

    2、应用场景

    • 首先利用NFS搭建文件Server端
      • 然后在应用上也安装NFS,并将应用文件目录/app/file挂载到Server端指定目录/app/file,这样在应用上上传文件后,文件会自动同步到Server端
        • 将应用部署多台进行横向扩容,并全部按照步骤2进行文件挂载。这样文件也都会同步到所有的应用服务器上。
         

      部署过程

      Server端部署

      安装NFS

      • 检查是否安装NFS
        rpm -qa nfs-utils rpcbind

      • 关闭防火墙

      • ## 查看防火墙状态
        systemctl status firewalld
        ## 关闭防火墙
        systemctl stop firewalld
        
        安装NFS
        yum install nfs-utils rpcbind -y
        
        检查安装结果
        rpm -qa nfs-utils rpcbind
        

         配置NFS

      •     创建配置文件
            vi /etc/exports
        
            建立同步文件夹
            mkdir -p /app/file
        
            对同步文件夹进行授权
            chown -R nfsnobody.nfsnobody /app/file/
        
            在配置文件中加入如下配置
        
        /app/file *(rw,sync)
        
            
        
        执行exportfs –rv让配置立即生效
        
            将NFS和rpcbind加入开机启动
        
        systemctl enable nfs
        systemctl enable rpcbind
        
           
        
            启动NFS和rpcbind
        
        systemctl start nfs
        systemctl start rpcbind
        
           
        
            查看NFS启动状态
            systemctl status nfs
        
        

         客户端配置

      • ## 查看防火墙状态
        systemctl status firewalld
        ## 关闭防火墙
        systemctl stop firewalld
        
        ## 安装NFS
        yum install nfs-utils rpcbind  -y
        ## 将NFS加入开启启动
        systemctl enable nfs
        ## 将rpcbind加入开启启动
        systemctl enable rpcbind
        ##启动NFS
        systemctl start nfs 
        ## 启动RPCbind
        systemctl start rpcbind
        

         将应用文件夹挂载到服务器上
        mount –t nfs 172.31.63.132:/app/file /app/file
        挂载完成后可以使用mount | grep file命令查看挂载情况

      • 取消挂载
      • sudo fuser -m -v -i -k /app/file
        sudo umount /app/file
        
  • 相关阅读:
    html5——文件断点续传
    前端自制Jquery插件————轮播
    js的订阅发布者模式
    写在前面
    Jmeter用于接口测试中,关联如何实现
    转: centos7 jdk(java) 安装以及安装命令相关知识
    ubuntu12.04上手动安装mysql
    ubuntu12.04 安装和卸载mysql
    Ubuntu 12.04 安装MySQL
    Ubuntu 12.04下安装MySQL图解
  • 原文地址:https://www.cnblogs.com/yyuuee/p/15307873.html
Copyright © 2020-2023  润新知