CentOS安装NFS服务端和客户端

在服务器上:

1、服务器上安装 NFS 服务器所需的软件包:
yum install -y nfs-utils

2、编辑exports文件,添加从机
vi /etc/exports
/data/   172.16.231.4(rw,sync,fsid=0,all_squash,anonuid=1000,anongid=1000)

3、先为rpcbind和nfs做开机启动:    
systemctl enable rpcbind.service    
systemctl enable nfs-server.service    

4、然后分别启动rpcbind和nfs服务:   
systemctl start rpcbind.service    
systemctl start nfs-server.service    

5、通过查看service列中是否有nfs服务来确认NFS是否启动。

showmount -e localhost

6、确认NFS服务器启动成功:   
rpcinfo -p    

7、firewalld 放行NFS:
firewall-cmd --permanent --zone public --add-service mountd
firewall-cmd --permanent --zone public --add-service rpc-bind
firewall-cmd --permanent --zone public --add-service nfs
firewall-cmd --reload

客户端配置:

1、安装rpcbind

yum install  -y rpcbind

2、启动服务

systemctl enable rpcbind.service
systemctl start rpcbind.service

3、检查 NFS 服务器端是否有目录共享
showmount -e 172.16.10.122

4、挂载文件
mkdir  /data/
mount -t nfs -o nolock   172.16.10.122:/data/ /data/

5、设置开机挂载
vi /etc/fstab
增加一下行
172.16.10.122:/data/ /data/   nfs defaults ,_rnetdev 1 1

猜你喜欢

转载自blog.csdn.net/songchaofly/article/details/122255246