zoukankan      html  css  js  c++  java
  • NFS

    不少系统中,都有NFS的需要。那么在一些不产用以及开发系统中如何添加NFS平台呢?这里我们就来讲解一下CentOS的NFS服务器的创建。希望对大家有所帮助。CentOS下搭建NFS平台的具体过程:

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

    NFS服务器分配IP为192.168.1.100,NFS客户端分配IP为192.168.1.200.

    nfs-server.example.com配置如下:

    [root@nfs-server ~]# cat /etc/sysconfig/network

    NETWORKING=yes

    HOSTNAME=nfs-server.example.com

    [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 localhost

    192.168.1.200   nfs-client.example.com   nfs-client

    nfs-client.example.com配置如下:

    [root@nfs-client ~]# cat /etc/sysconfig/network

    NETWORKING=yes

    HOSTNAME=nfs-client.example.com
    [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 localhost

    192.168.1.100   nfs-server.example.com   nfs-server


    2、配置NFS服务器(nfs-server.example.com)

    默认安装下已经装好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 start


    3、配置NFS客户端(nfs-client.example.com)

    测试NFS服务器.

    [root@nfs-client ~]# showmount -e nfs-server

    Export 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 0


    4、排错参考

    当/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段.

  • 相关阅读:
    Go内建容器篇
    Go基础语法篇
    【区块链】比特币Merkle树
    【区块链】Fabric 术语
    Apache旗下项目
    【区块链】Fabric0.6 与1.0
    rc.local不起作用
    命令行模式启动VMWare虚拟机
    vsftpd 530 Login incorrect 根本原因和解决方案
    Oracle的undotbs01.dbf文件太大(占用大量磁盘空间)处理方法 ORA-01654 空间不足 ORA-01653
  • 原文地址:https://www.cnblogs.com/greencolor/p/2416204.html
Copyright © 2011-2022 走看看