yum安装nfs并配置

yum安装nfs并配置

   张吉吉     2020年1月14日 01:36     1800    

1、yum安装

服务端和客户端必须软件nfs-utils,事实上在安装nfs-utils的同时,rpcbind作为依赖包被安装,因此无需再单独安装rpcbind。

但单独安装rpcbind时不会同时安装nfs-utils。

yum -y install nfs-utils

可能有得版本不会安装rpcbind,直接使用命令

yum -y install rpcbind去安装。

 

2、启动服务

(1)首先启动rpc

因为后边nfs会将端口注册到rpc中,所以需要先将rpc启动起来

systemctl start rpcbind

systemctl enable rpcbind

 

(2)启动nfs

systemctl start nfs

systemctl enable nfs

 

(3)放通防火墙

firewall-cmd --permanent --add-service=nfs

firewall-cmd --reload

 

3、示例

现在192.168.0.152服务器想要挂载192.168.60.156的/data目录。

默认网络已经连通,192.168.0.152服务器可以访问192.168.60.156。

(1)首先在192.168.60.156服务器创建目录

mkdir /data

(2)配置/etc/exports文件

/data 192.168.0.152/32(rw,no_root_squash,no_all_squash,sync)

ps:如果你是使用虚拟机做测试的话,需要配置你虚拟机的网关,才能链接。些客户端ip没有用的。

(3)生效配置

exportfs -r


4、在其他linux服务器上挂载

在客户端linux上创建目录data

只要网络能够通信,执行使用命令

mount -t nfs 192.168.60.156:/data /data

就可挂载

如果在挂载的时候遇到了

image.png 

那么可能是没有安装客户端

yum -y install nfs-utils
systemctl start nfs-utils
systemctl enable nfs-utils


5、配置windows

打开windows的NFS功能,在程序的添加和关闭windows功能里边。

这里不再详细描述。

1.png

在运行中输入ip目录

2.png

可以看到访问成功

3.png

 

 


文章评论

0

其他文章