Skip to main content
 Web开发网 » 操作系统

CentOS NFS服务器怎么创建?

2021年10月13日4880百度已收录

  CentOS下搭建NFS平台的具体过程如下:

1、先在VM下装一个CentOS作为NFS服务器(nfs-server。example),再克隆一个作为NFS客户端(nfs-client。example),MINI安装即可。NFS服务器分配IP为192。

  168。1。100,NFS客户端分配IP为192。168。1。200。nfs-server。example配置如下:[root@nfs-server ~]# cat /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nfs-server。

  example[root@nfs-server ~]# cat /etc/hosts# Do not remove the following line, or various programs# that require network functionality will fail。

  127。0。0。1 localhost。localdomain localhost192。168。1。200 nfs-client。example nfs-clientnfs-client。example配置如下:[root@nfs-client ~]# cat /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nfs-client。

  example[root@nfs-client ~]# cat /etc/hosts# Do not remove the following line, or various programs# that require network functionality will fail。

  127。0。0。1 localhost。localdomain localhost192。168。1。100 nfs-server。example nfs-server2、配置NFS服务器(nfs-server。example)默认安装下已经装好NFS服务了,所以只用开启服务器即可。

  [root@nfs-server ~]# chkconfig nfs on比如要共享/data/目录:[root@nfs-server ~]# mkdir /data[root@nfs-server ~]# vi /etc/exports/data/ 192。

  168。1。200(rw,no_root_squash,no_all_squash,sync)现在就可以启动NFS服务了。[root@nfs-server ~]# service nfs start3、配置NFS客户端(nfs-client。

  example)测试NFS服务器。[root@nfs-client ~]# showmount -e nfs-serverExport list for share:/data 192。168。1。200如果没有出现以上信息,说明NFS服务器还没配置正确,一般是IP设置错误。

  MOUNT共享目录/data:[root@nfs-client ~]# mkdir /data[root@nfs-client ~]# mount -t nfs 192。168。1。100:/data /data接下来就测试共享目录/data是否可读写:[root@nfs-client ~]# echo hello world /data/test然后上NFS服务器看看是否有/data/test文件:)?如果想NFS客户端一开机就自动挂载共享目录,只需修改/etc/fstab,加 入以下一句就可以了:192。

  168。1。100:/data /data nfs rw 0 04、排错参考当/etc/exports设置的权限,不符合client端的来源时,则会出现以下错误信息:mount: hostname:/dir failed, reason given by server: Permission denied然而必须注意的是,若在nfs server的/etc/hosts內有设置IP与hostname的对照则nfs会先把来源IP转换成hostname,再与/etc/exports內的设置做对比若此时/etc/exports的设置使用IP而非hostname,则会产生? 法匹配的错误? 此而出现,虽然來源IP在/etc/exports已正确设置,却仍然发生Permission denied的现象解决方案是在/etc/exports內采用hostname,避免使用IP,或者是设置正确的IP段。

  来源:/。

评论列表暂无评论
发表评论
微信