最近学习kubernetes,需要搭建NFS服务器,就查了下如何安装NFS服务器,具体步骤如下。
关闭防火墙,并设置开机禁止启动
$ systemctl stop firewalld $ systemctl disable firewalld
安装NFS服务器,需要安装nfs-utils和rpcbind两个包,安装nfs-utils时会自动安装rpcbind
$ yum install nfs-utils -y
启动NFS服务,并设置开机自启
启动rpcbind
$ systemctl start rpcbind $ systemctl enable rpcbind $ systemctl status rpcbind
确认rpcbind状态,running表示启动成功
启动nfs
确认nfs状态,running表示启动成功
创建nfs共享目录/nfs/nfsdisk1,修改该目录权限为777,
修改nfs配置文件/etc/exports
配置文件说明
重启nfs并确认状态
$ systemctl restart rpcbind $ systemctl status rpcbind $ systemctl restart nfs $ systemctl status nfs
挂载nfs磁盘,可以在该安装NFS服务器的主机上挂载磁盘,也可以另外找一台和该主机通信的主机挂载磁盘
测试文件写入
在挂载该磁盘的机器上写入hellonfs.txt
在安装NFS服务器的主机上,确认hellonfs.txt是否写入到nfs共享目录
卸载nfs磁盘
原文:https://www.cnblogs.com/guoxiaobo/p/14138257.html