NFS Server

1. 安装nfs-server

  # yum install -y nfs-utils

2. 创建NFS目录

  # mkdir /nfs

3. 配置NFS目录

 

  # echo "/nfs    *(rw,sync,no_root_squash)" >> /etc/exports

  参数说明: 

    rw 读写
    ro 只读
    sync 数据直接写入磁盘
    async 数据先写入内存
    no_root_squash 对root用户不压制,在服务端都映射为服务端的root用户
    root_squash 如果客户端是用户root操作,会被压制成nobody用户
    all_squash 不管客户端的使用nfs的用户是谁,都会压制成nobody用户
    nonuid=uid: 指定uid的值
    anongid=gid:指定gid的值

 

  # exportfs -rv  # 立即生效

4. 启动NFS服务

  # systemctl enable --now nfs-server.service

  # showmount -e

 

 

NFS Client(方法一)

1. 安装nfs-client

  # yum install -y nfs-utils

2. 创建挂载目录

  # mkdir /var/nfs

3. 查看NFS Server目录

  # showmount -e nfs-server-ip

4. 挂载NFS Server目录

  # mount -t nfs nfs-server-ip:/nfs /var/nfs

 

NFS Client(方法二)

要实现开机自动挂载,通常将挂载配置信息直接写入到 /etc/fstab文件中。
​autofs自动挂载服务是一种Linux系统守护进程,当检测到用户访问一个尚未挂载的文件系统时,会自动根据配置文件进行挂载(动态挂载)。

 

1. 安装autofs

  # yum install autofs

2. 创建挂载目录

  # mkdir /var/nfs

3. 自动挂载NFS配置

  # echo "/var/nfs    /etc/auto.nfs" >> /etc/auto.master

  # echo "data -fstype=nfs nfs-server-ip:/nfs" >> /etc/auto.nfs

4. 启动autofs服务

  # systemctl enable --now autofs.service

相关文章:

  • 2021-11-28
  • 2021-08-18
  • 2022-01-23
  • 2021-09-06
  • 2021-10-01
  • 2022-02-05
  • 2021-09-03
  • 2022-03-06
猜你喜欢
  • 2021-06-19
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
相关资源
相似解决方案