码迷,mamicode.com
首页 > 其他好文 > 详细

nfs

时间:2014-06-17 18:13:48      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:root权限   计算机   配置文件   服务器   软件包   

      NFS服务器的配置

1.1NFS概述

  NFS是一种分布式文件系统允许网络中的安装不同的操作系统的计算机之间共享文件。

   我的安装环境:redhat5.9

NFS服务器的主要软件包:

nfs-utils-1.0.9-66.el5

portmap-4.0-65.2.2.1

系统服务脚本:NFS      portmap

主配置文件:

/etc/exports

/etc/exports配置解析:

--共享目录客户机地址(参数,参数.. ..

参数的介绍:

Rw:可读可写

Ro:只读

Sync:同步写入:写入内存的同时写入硬盘

Async:异步写入:先写入内存在写入硬盘

N0_root_squash:保留来之客户端的root权限

All_squash:客户端的权限都降级为nfsnobody

1.2NFS的安装

    [root@ dhcpser~]# rpm -q nfs-utils portmap      //查看软件包是否安装

nfs-utils-1.0.9-66.el5

portmap-4.0-65.2.2.1

如果没有安装可以利用yum库进行安装

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

[root@ dhcper~]#yum-y install portmap

NFS服务器端配置:

[root@dhcpser ~]# cat /etc/exports      //编辑共享配置文件

/root  192.168.10.20(rw,sync,no_root_squash)   共享/root192.168.10.20,可写、同步,允许客户机以root权限访问

[root@dhcpser ~]#service portmap restart       //运行portmap脚本    

[root@dhcpser ~]#service nfs restart            //运行nfs脚本

[root@dhcpser ~]#chkconfig portmap on         // 配置开机启动

[root@dhcpser ~]#chkconfig nfs on              //配置开机启动

客户端配置:

[root@localhost~]# service portmap restart      //运行portmap脚本 

[root@localhost~]# showmount -e 192.168.10.253    //查看nfs共享列表

Export list for192.168.10.253:

/root    192.168.10.20                    //服务器端的共享

[root@localhost~]# mkdir -p /data/root/            //创建挂载目录

[root@localhost~]# mount 192.168.10.253:/root/ /data/root/  //挂载

[root@localhost~]# df -hT | grep nfs

               nfs     19G 2.7G   16G  15% /data/root

[root@localhost~]# cd /data/root/

[root@localhostroot]# touch file1.txt

[root@localhostroot]# ls -l file1.txt

-rw-r--r-- 1 rootroot 0 06-12 17:18 file1.txt

 

例如:

NFS服务器配置:

[root@dhcpser ~]#cat /etc/exports                 //编辑配置文件

/root   192.168.10.20(rw,sync,no_root_squash)

/usr/src        192.168.10.0/24(rw,async)    //共享给10.0网段,可写,异步

[root@dhcpser ~]#exportfs -rv                   //重新发布信息

[root@dhcpser ~]#setfacl -m u:nfsnobody:rwx /usr/src/   //添加读写权限

客户端操作:

[root@localhost~]# mkdir /data/src/         创建挂载点

[root@localhost~]# showmount -e 192.168.10.253       ///查看共享

Export list for192.168.10.253:

/root    192.168.10.20

/usr/src192.168.10.0/24

[root@localhost~]# mount 192.168.10.253:/usr/src/ /data/src/

[root@localhost~]# cd /data/src/

[root@localhostsrc]# touch file1.txt         //新建测试文件

[root@localhostsrc]# ls -l file1.txt           //查看文件内容

-rw-r--r-- 1nfsnobody nfsnobody 0 06-12 17:23 file1.txt

 

 

再有:

NFS服务端操作:

[root@dhcpser ~]#chmod o+w /usr/src/       //添加目录属性增加写的权限

NFS客户端操作:

[root@localhost~]# useradd tom               新建用户tom

[root@localhost~]# su – tom                切换用户

[tom@localhost ~]$cd /data/src/

[tom@localhostsrc]$ touch tom1.txt

[tom@localhostsrc]$ ls -l tom1.txt

-rw-rw-r-- 1 tomtom 0 06-12 17:29 tom1.txt      文件属主和属组都是Tom

NFS服务器修改主配置文件

[root@dhcpser ~]# Vim/etc/exports

/root   192.168.10.20(rw,sync,no_root_squash)

/usr/src        192.168.10.0/24(rw,async,all_squash)

[root@dhcpser ~]#exportfs -rv                    //重新发布信息

NFS客户端操作:     

[tom@localhostsrc]$ touch tom2.txt

[tom@localhostsrc]$ ls -l tom2.txt

-rw-rw-r-- 1nfsnobody nfsnobody 0 06-12 17:31 tom2.txt        //属主和属组都被改成nfsnobady


nfs,布布扣,bubuko.com

nfs

标签:root权限   计算机   配置文件   服务器   软件包   

原文地址:http://9052689.blog.51cto.com/9042689/1427099

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!