确认主机有没有安装nfs软件包
有nfs软件包就不用安装直接改配置文件,没有就安装。
[root@localhost ~]# yum install nfs-utils -y
启动nfs服务并设置为开机自启动
[root@hds ~]# systemctl start nfs-server.service
[root@hds ~]# systemctl enable nfs-server.service
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.
配置共享目录
单独准备一个20G的磁盘,作为nfs后端存储来使用。
对磁盘分区格式化
创建一个挂载nfs的目录并挂载
配置共享目录
[root@hds /]# vim /etc/exports
[root@hds /]# cat /etc/exports
/nfs 192.168.126.0/24(rw,no_root_squash)
重启nfs服务
[root@hds /]# systemctl restart nfs-server.service
在另一台centos上进行测试
启动nfs服务并设置为开机自启动
[root@node2 ~]# systemctl start nfs-server.service
[root@node2 ~]# systemctl enable nfs-server.service
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.
创建一个挂载目录
[root@node2 ~]# mkdir /nfs01
挂载nfs后端存储并查看
[root@node2 ~]# mount -t nfs 192.168.126.166:/nfs /nfs01
[root@node2 ~]# df -Th