zl程序教程

您现在的位置是:首页 >  系统

当前栏目

centos系统安装搭建nfs-server

2023-06-13 09:18:27 时间

CentOS 8

  1. 安装nfs-utils软件包 使用以下命令安装nfs-utils软件包: sudo yum install nfs-utils
  2. 创建共享目录 创建一个共享目录,例如: sudo mkdir /data/share 并将其权限设置为可写: sudo chmod 777 /data/share
  3. 配置nfs 编辑/etc/exports文件以配置nfs。在文件末尾添加以下行: /data/share *(rw,sync,no_subtree_check) 这将允许所有客户端访问/data/share目录,并授予读写权限。
  4. 启动nfs服务 启动nfs服务: sudo systemctl start nfs-server 并使其在系统启动时自动启动: sudo systemctl enable nfs-server

CentOS 7

  1. 安装NFS服务器和相关软件 sudo yum install nfs-utils rpcbind
  2. 创建共享目录 sudo mkdir /nfs_share
  3. 配置NFS服务器 打开NFS配置文件 sudo vi /etc/exports 添加以下内容: /nfs_share *(rw,sync,no_root_squash,no_all_squash)
  4. 重新加载NFS配置文件 sudo exportfs -a
  5. 启动NFS服务 sudo systemctl enable rpcbind sudo systemctl enable nfs-server sudo systemctl start rpcbind sudo systemctl start nfs-server

补充

配置文件/etc/exports说明:

/nfs_share 是共享目录的路径。

*表示允许任何IP地址访问此共享目录。

rw 表示允许读写访问。

sync 表示同步写入,即数据写入服务器后立即返回确认。

no_root_squash 表示允许root用户访问。

no_all_squash 表示允许所有用户访问。