搭建CNFS文件系统

1.概念:

  • CNFS (Cluster Network File System)是 GPFS 中的一种模式,用于配置和管理多台服务器(节点)之间的文件共享和数据访问

  • 它允许多个节点同时访问和共享文件系统的数据,以实现高性能、高可用性的存储解决方案

2.创建CNFS文件系统:

  • 将原本的GPFS文件系统修改为cnfs文件系统:

    复制代码
    [root@node1 ~]# mmchfs gpfs1 -o syncnfs
    mmchfs: Propagating the cluster configuration data to all
      affected nodes.  This is an asynchronous process.
  • 修改配置文件/etc/exports(这是nfs服务器的配置文件),

    复制代码
    #|   共享目录     |  主机名        (权限)|
    /usr/qv123/nfsdata  192.168.73.0/24(rw)
    
    man exports    # 查看所有参数
    权限参数值 说明
    rw/ro rw:可读写,ro:只读,还是与文件系统的rwx有关
    sync/async sync:数据会同步写入到内存与硬盘中,async:则代表数据会先暂存于内存当中
    no_root_squash/root_squash no_root_squash表示就显示root用户和root组;root_squash表示将root用户和组映射为匿名用户和组(默认设置)。
    all_squash/no_all_squash allsquash:客户端所有用户创建文件时,客户端会将文件的用户和组映射为匿名用户和组no_all_squash:客户端普通用户创建的文件的UID和GID是多少,服务端就显示为多少(默认设置)
    anonuid=anongid= 将文件的用户和组映射为指定的UID和GID,若不指定默认为65534(nfsnobody)
    复制代码
    [root@node1 ~]# cat << eof > /etc/exports
    /gpfs1/nfs 192.168.10.0/24(rw,fsid=11)
    eof
    [root@node2 ~]# cat << eof > /etc/exports
    /gpfs1/nfs 192.168.10.0/24(rw,fsid=11)
    eof
  • 使配置生效

    复制代码
    [root@node1 ~]# exportfs -r
    [root@node1 ~]# exportfs -r
  • 在每个服务端上面设置nfsd自动启动

    复制代码
    [root@node1 ~]# systemctl enable nfs-server
    Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
    [root@node2 ~]# systemctl enable nfs-server
    Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
  • 指定 CNFS 服务器的共享根目录,最好是一个单独小的文件系统且不被NFS共享出去

    复制代码
    [root@node1 ~]# mmchconfig cnfsSharedRoot=/gpfs1/cnfs
    mmchconfig: Command successfully completed
    mmchconfig: Propagating the cluster configuration data to all
      affected nodes.  This is an asynchronous process.
  • 指定 CNFS(Cluster Network File System)服务器节点上用于 CNFS 服务的网络接口

    ip_address_list为上面配置的专用于NFS的ip,node为这个节点在GPFS里面的主机名;CNFS 允许多个 Spectrum Scale 节点通过 RDMA(远程直接内存访问)协议来访问共享数据。

    复制代码
    [root@node1 ~]# mmchnode --cnfs-interface=192.168.10.151 -N node1
    Wed Sep 27 05:24:58 EDT 2023: mmchnode: Processing node node1
    mmnfsinstall: CNFS has modified configuration file /etc/sysconfig/network-scripts/ifcfg-ens38.
    Restarting monitor 
    mmchnode: Propagating the cluster configuration data to all
      affected nodes.  This is an asynchronous process.
    [root@node2 ~]# mmchnode --cnfs-interface=192.168.10.152 -N node2
    Wed Sep 27 05:33:53 EDT 2023: mmchnode: Processing node node2
    mmnfsinstall: CNFS has modified configuration file /etc/sysconfig/network-scripts/ifcfg-ens38.
    Restarting monitor 
    mmchnode: Propagating the cluster configuration data to all
      affected nodes.  This is an asynchronous process.
  • 指定 CNFS服务器上的 mountd 服务监听的端口号

    复制代码
    [root@node1 ~]# mmchconfig cnfsMountdPort=3000 -N node1
    mmchconfig: Command successfully completed
    mmchconfig: Propagating the cluster configuration data to all
      affected nodes.  This is an asynchronous process.
    [root@node2 ~]# mmchconfig cnfsMountdPort=3000 -N node2
    mmchconfig: Command successfully completed
    mmchconfig: Propagating the cluster configuration data to all
      affected nodes.  This is an asynchronous process.
  • 查看集群里的CNFS节点:

    复制代码
    [root@node1 ~]# mmlscluster --cnfs
    ​
    GPFS cluster information
    ========================
      GPFS cluster name:         gpfs.node1
      GPFS cluster id:           1484988891362745278
    ​
    Cluster NFS global parameters
    -----------------------------
      Shared root directory:                /gpfs1/cnfs
      rpc.mountd port number:               3000
      nfsd threads:                         32
      Reboot on failure enabled:            yes
      CNFS monitor enabled:                 yes
    ​
     Node  Daemon node name            IP address       CNFS state  group  CNFS IP address list
    -------------------------------------------------------------------------------------------
       1   node1                       192.168.10.101   enabled        0   192.168.10.151
       2   node2                       192.168.10.102   enabled        0   192.168.10.152
  • 测试是否存在共享目录:

    复制代码
    [root@node1 ~]# showmount -e 192.168.10.151
    Export list for 192.168.10.151:
    /gpfs1/nfs 192.168.10.0/24

3.客户端挂载:

  • 方式一:临时挂载

    • 安装nfs-utils

      复制代码
      [root@gpfs-client ~]# yum install  -y nfs-utils
    • 查看是否可以连接上共享目录:

      复制代码
      [root@gpfs-client ~]# showmount -e 192.168.10.151
      Export list for 192.168.10.151:
      /gpfs1/nfs 192.168.10.0/24
      [root@gpfs-client ~]# showmount -e 192.168.10.152
      Export list for 192.168.10.152:
      /gpfs1/nfs 192.168.10.0/24
    • 创建挂载目录,挂载目录或解挂载目录

      复制代码
      [root@gpfs-client ~]# mount -o sync,hard,intr 192.168.10.151:/gpfs1/nfs /mnt/nfs
    • 查看挂载:

      复制代码
      [root@gpfs-client ~]# df -h | grep nfs
      192.168.10.151:/gpfs1/nfs   20G  3.7G   17G  19% /mnt/nfs
  • 方式二:自动挂载

    • 安装autofs:

      复制代码
      yum install -y autofs
    • 配置文件:

      复制代码
      autofs.conf:针对服务autofs的配置
      timeout = 300,               # 
      dismount_interval = 300      # 挂载超时时间
      
      auto.master:是针对目录对应的挂载配置文件
      /misc这个目录自动挂载的信息autofs在 /etc/auto.misc中
      配置语法: 目录   自动挂载配置文件的目录
      
      auto.xxx:具体的挂载的信息
      cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
      挂载的目录  挂载的选项    :要挂载的设备
      boot      -fstype=ext2   :/dev/hda1
    • 修改配置文件:

      复制代码
      cat << eof > /etc/auto.master
      /mnt   /etc/auto.nfs
      eof
      
      cat << eof > /etc/auto.nfs
      # 添加内容
      #本地端子目录 -挂载参数  服务器所提供的目录 
      nfs 192.168.10.151:/gpfs1/nfs
      eof
      参数 参数功能
      fgbg 当执行挂载时,该挂载行为会在前台(fg)还是后台(bg)执行,若在前台执行,则mount会持续尝试挂载,直到成功或time out为止;若为后台执行,则mount会在后台持续多次进行mount,而不会影响到前台的程序运行。
      softhard hard表示当两者之间的任何一台主机脱机,则RPC会持续地呼叫,直到对方恢复连接为止。如果是soft的话,那RPC会在time out后重复呼叫,而非持续呼叫
      intr 当使用上面提到的hard方式挂载时,若加上intr这个参数,则当RPC持续呼叫时,该次的呼叫是可以被中断的
      rsizewsize 读出(rsize)与写入(wsize)的区块大小。这个设置值可以影响客户端与服务器端传输数据的缓冲记忆容量
    • 重启autofs服务

      复制代码
      systemctl restart autofs
    • 查看挂载信息:

      复制代码
      mount | grep /nfs
    • 触发自动挂载,进入到子目录中触发,退出挂载目录一定时间后触发解挂载:

      复制代码
      cd /mnt/nfs   

3.删除cnfs节点:

复制代码
mmchnode --cnfs-interface=DELETE -N "node1,node2"
相关推荐
MarkHD2 小时前
第八天 - paramiko/ssh模块 - 远程服务器管理 - 练习:批量服务器命令执行工具
运维·服务器·ssh
写代码的小王吧2 小时前
【安全】Web渗透测试(全流程)_渗透测试学习流程图
linux·前端·网络·学习·安全·网络安全·ssh
Tee xm3 小时前
清晰易懂的跨平台 MySQL 安装与配置教程
linux·windows·mysql·macos·安装
GalaxyPokemon3 小时前
MySQL基础 [一] - Ubuntu版本安装
linux·运维·ubuntu
musk12123 小时前
wsl2 配置ubuntu 固定ip
linux·tcp/ip·ubuntu
柳鲲鹏4 小时前
UBUNTU编译datalink
linux·运维·ubuntu
追随远方4 小时前
Ubuntu 64-bit 交叉编译 FFmpeg(高级用户指南)
linux·ubuntu·ffmpeg
GalaxyPokemon4 小时前
Muduo网络库实现 [七] - Connection模块
linux·服务器·网络
慈云数据4 小时前
构建自己的私有 Git 服务器:基于 Gitea 的轻量化部署实战指南
服务器·git·gitea
三阶码叟4 小时前
centos7 yum install docker 安装错误
运维·docker·容器