项目: NFS服务的搭建

NFS服务端的搭建:

工作原理:

4

修改主机名:

[root@nfs ~]# sed -i 's#HOSTNAME=.*#HOSTNAME=liuwei_nfs#g' /etc/sysconfig/network

[root@liuwei_nfs ~]# mount /dev/sr0 /media/cdrom/

[root@liuwei_nfs ~]# yum -y install nfs-utils rpcbind
[root@liuwei_nfs ~]# rpm -qa nfs-utils rpcbind

启动rpcbind

[root@liuwei_nfs ~]# /etc/init.d/rpcbind start

[root@liuwei_nfs ~]# /etc/init.d/nfs start

[root@liuwei_nfs ~]# chkconfig rpcbind on 加入开机自启动

[root@liuwei_nfs ~]# chkconfig --list rpcbind

 chkconfig nfs on

 chkconfig --list nfs

修改NFS服务端配置文件:

创建nfs的共享目录路径: mkdir  /data

[root@liuwei_nfs ~]# vim /etc/exports

[root@liuwei_nfs ~]# cat /etc/exports

/data   192.168.200.0/24(rw,sync)

  • ·   命令说明:
  • ·   /data nfs的共享目录路径
  • ·   192.168.200.0/24允许挂载我的共享目录的IP地址段
  • ·  rw):可读可写
  • ·  sync):实时同步

修改配置文件以后,必须重启nfs服务

[root@liuwei_nfs /]# /etc/init.d/nfs restart

[root@liuwei_nfs /]# showmount -e localhost     #查看生效的nfs配置文件规则

给共享目录更改属主属组为nfsnobady

[root@liuwei_nfs /]#  id  nfsnobody

uid=65534(nfsnobody)  gid=65534(nfsnobody) groups=65534(nfsnobody)

[root@liuwei_nfs /]# chown -R nfsnobody.nfsnobody /data

进行本地挂载测试

[root@liuwei_nfs /]# mount 192.168.200.150:/data /mnt

[root@liuwei_nfs /]# echo $?

0

[root@liuwei_nfs /]# df -h

进行文件写入测试

1)给/data目录创建两文件 fuck hello

2)进/mnt目录下查看,是否文件共享

(总结1.服务器装 rpcbind nfs-utils)

            2 服务器建立一个 挂载目录data

            3,给datachown nfsnobody data

    4 修改配置文件 vim/etc/exports

             /data 192.168.200.0/24rw,sync

    5 开启rpcbind;第一得先启动这个:

                  /etc/init.d/rpcbind start

           6.然后开启 nfs:第二开启这个

            /etc/init.d/nfs start

          7,关闭防火墙:

           Service iptables stop

          8  挂载

NFS客户端:远程设置

 

客户端必须安装nfs-utils软件

[root@LW_nfs_kh ~]# yum -y install nfs-utils

检查NFS挂载远端情况showmount -e 192.168.200.150 服务端主机

客户端挂载 

[root@LW_nfs_kh /]# mount 192.168.200.150:/data /weiwei

(说明:把IP为150的服务器的/data共享目录。挂载到我的客户端的/weiwei目录下。实现我的/tmp与服务器/data 信息的共享)

(注意:远程NFS挂载出现卡顿,可能的原因是 防火墙 没有关闭要注意关闭)

远程NFS客户端 与 服务端 数据共享测试:

(1)客户端挂载目录(共享)是:/weiwei

(2)服务端挂载目录(共享)是:/data

原文地址:https://www.cnblogs.com/creater-wei/p/10010103.html