1.在所有server安装nfs服务
yum install nfs-utils
2.检查是否安装成功
rpm -qa|grep nfs
rpm -qa|grep rpcbind
3.启动服务
service rpcbind start
service nfs start
4.在共享服务器中创建用来共享的文件夹(node01)
mkdir /share
5.在 /etc/exports 中添加配置
vim /etc/exports
/share 192.168.91.129(rw,no_root_squash,no_all_squash,sync)
解释:192.168.91.129就是需要挂载node01的服务器
6.添加配置之后需要重启rpcbind
service rpcbind restart
7.在node02中创建挂载目录
mkdir /share
8.测试挂载
mount -t nfs 192.168.91.128:/share /share
9.多个从机挂载NFS
在配置文件中增加对应的配置
vim /etc/exports
/share 192.168.91.130(rw,no_root_squash,no_all_squash,sync)
或者如果有配置安全组,可以将IP改为*,允许任何IP添加该共享目录
10.设置开机自动挂载
在从机 /etc/fstab中添加如下信息
192.168.91.128:/share /share nfs defaults 1 1
共享服务器IP 共享服务器的共享目录 本地目录 nfs defaults 1 1
需要注意的是,设置自动挂载,需要设置nfs为自动启动
设置开机服务命令:
chkconfig rpcbind on
chkconfig nfs on