linux 深入应用 NFS
以下实验大家用主机名来区分服务器端和客户端,
服务器端为 NFS_Server ip-192.168.1.4;
客户端为 NFS_Client ip-192.168.1.5;
实例一
将/tmp 分享给大家使用,让所有的人都可以存取,让 root 写入档案还是具有 root 的权限
[NFS Server]
[root@NFS_Server ~]# ll -d /tmp/ #目录 tmp 文件系统本身具有读写权限
drwxrwxrwt. 3 root root 4096 May 3 21:39 /tmp/ [root@NFS_Server ~]# vim /etc/exports
/tmp 192.168.1.5(rw,root_squash)
[root@NFS_Server ~]# exportfs -r #重新载入配置文件 [root@NFS_Server ~]# ll /tmp
total 0
-rw-------. 1 root root 0 Apr 23 15:05 yum.log
[root@NFS_Client ~]# mkdir /share1 #创建挂载目录
[root@NFS_Client ~]# ll
/share1/
total 0
[root@NFS_Client ~]# mount -t nfs 192.168.1.4:/tmp/ /share1/ #挂载 [root@NFS_Client share1]# ll
#已同步到客户端的/share1 目录
total 0
-rw-------. 1 root root 0 Apr 23 15:05 yum.log
[root@NFS_Client share1]# whoami #查看当前用户
root
[root@NFS_Client share1]# touch a.sh
#以 root 用户创建一个测试文件
[root@NFS_Client share1]# ll #查看
a.sh 的宿主宿组都是 root
total 0
-rw-r--r--. 1 root root 0 May
3
2014 a.sh
-rw-------. 1 root root 0 Apr 23 15:05 yum.log
[NFS Server]
[root@NFS_Server tmp]# ll #查看
a.sh 是否同步,查看 a.sh 的宿主宿组是否是 root
total 0
-rw-r--r--. 1 root root 0 May
3 22:15 a.sh
-rw-------. 1 root root 0 Apr 23 15:05 yum.log
---End---
实验一总结:主要的就是共享权限 no_root_squash
要想明白 no_root_squash 就要先明白 root_squash 的意思
root_squash:如果客户端是以 root 身份进行对 nfs 分区操作,那么会被 root_squash 压缩成
nfsnobody。
no_root_squash:与 root_squash 意思相反,就是不压缩,仍然是以 root 用户进行进行操作 nfs
分区,安全性没有保证
同一目录针对不同范围开放不同的权限
我们将一个公共的目录/www/onair 公开出去,但是我们只限定我的局域网络 192.168.1.0/24 这个 网且加入 Allentunsgroup 的用户才能够读写,其它来源则只能读取
[ON Server]
[root@NFS_Server ~]# mkdir /www/onair -pv mkdir: created directory `/www'
mkdir: created directory `/www/onair'
[root@NFS_Server ~]# touch /www/onair/a.sh
[root@NFS_Server ~]# groupadd -g 500 Allentunsgroup
[root@NFS_Server ~]# useradd -g Allentunsgroup -r 500 Allentuns
[root@NFS_Server ~]# setfacl -m g:Allentunsgroup:rwx /www/onair #设置 Allentunsgroup
组对/www/onair 文件的读写执行权限
[root@NFS_Server ~]# ll
-d /www/onair/
drwxrwxr-x+ 2 root root 4096 May
4 01:45 /www/onair/
[root@NFS_Server ~]# cat /etc/group |grep Allentunsgroup #查看对应的 gid 后面会用到
Allentunsgroup:x:500:
[root@NFS_Server ~]# vim /etc/exports
/www/onair 192.168.1.0/24(rw)
*(ro)
[root@NFS_Server ~]# exportfs -r
[ON Client]
[root@NFS_Client ~]# mkdir /usr/local/onair
[root@NFS_Client ~]# showmount -e 192.168.1.4
Export list for 192.168.1.4:
/www/onair (everyone)
[root@NFS_Client ~]# mount -t nfs 192.168.1.4:/www/onair /usr/local/onair/
[root@NFS_Client ~]# cd /usr/local/onair/
total 0
-rw-r--r--. 1 root root 0 May
4 01:45 a.sh
[root@NFS_Client onair]# whoami
root
[root@NFS_Client onair]# touch b.sh #拒绝
touch: cannot touch `b.sh': Permission denied
root 用户拒绝写入
然后创建一个新账号,并加入到 Allentunsgroup 组中测试是否有写入权限
[root@NFS_Client ~]# groupadd -g 500 Allentunsgroup
[root@NFS_Client ~]# cat /etc/group |grep Allentunsgroup
Allentunsgroup:x:500:
[root@NFS_Client ~]# useradd -g Allentunsgroup scott
[root@NFS_Client ~]# id scott
uid=500(scott) gid=500(Allentunsgroup) groups=500(Allentunsgroup)
[root@NFS_Client ~]# passwd scott
Changing password for user scott.
New password:
BAD PASSWORD: it is
too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@NFS_Client onair]# su scott
[scott@NFS_Client onair]$ whoami scott
[scott@NFS_Client onair]$ ll total 0
[scott@NFS_Client onair]$ touch b.sh #写入成功
[scott@NFS_Client onair]$ ll total 0
-rw-r--r--. 1 root root 0 May
4 01:45 a.sh
-rw-r--r--. 1 nobody Allentunsgroup 0 May
4
2014 b.sh
[ON Server]
[root@NFS_Server ~]# ll
/www/onair/
total 0
-rw-r--r--. 1 root root 0
May 4 01:45 a.sh
-rw-r--r--. 1 Allentuns Allentunsgroup 0 May 4 02:11 b.sh
已经同步到 Server 端,并且同步到 server 端的用户是 Allentuns,用户组为 Allentunsgroup
setfacl 的用法
setfacl 命令可以用来细分 linux 下的文件权限。
chmod 命令可以把文件权限分为 u,g,o 三个组,
而 setfacl 可以对每一个文件或目录设置更精确的文件权限。
比较常用的用法如下:
setfacl –m u:apache:rwx file 设置 apache 用户对 file 文件的 rwx 权限
setfacl –m g:market:rwx file 设置 market 用户组对 file 文件的 rwx 权限
setfacl –x g:market file
删除 market 组对 file 文件的所有权限
getfacl file 查看 file 文件的权限
Error1
[root@NFS_Server onair]# service rpcbind stop
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No
such file or
directory
解决办法
退出当前目录,重新执行此命令
---End---
linux 深入应用 NFS的更多相关文章
- 【Oracle 集群】11G RAC 知识图文详细教程之RAC在LINUX上使用NFS安装前准备(六)
RAC在LINUX上使用NFS安装前准备(六) 概述:写下本文档的初衷和动力,来源于上篇的<oracle基本操作手册>.oracle基本操作手册是作者研一假期对oracle基础知识学习的汇 ...
- linux下使用NFS挂载文件系统
转自linux如何使用NFS挂载文件系统 设备:一台服务器和一台客户端,这里我们把装在PC机上的RedHat作为服务器,而客户端则是嵌入式linux开发板. 环境:开发板已启动,连接好串口和网线,串口 ...
- Linux 文件服务---------- nfs Server
Linux 文件服务nfs (Network file system)#网络文件系统 ---> 远程文件调用samba #文件共享(unix /linux /windows ) ,只能适用于局域 ...
- linux下面重启nfs报错:nfs-server.service:main process exited
linux下面重启nfs报错:nfs-server.service:main process exited [root@dhcp-66-83-39 images]# service rpcbind s ...
- 转载:【Oracle 集群】RAC知识图文详细教程(六)--RAC在LINUX上使用NFS安装前准备
文章导航 集群概念介绍(一) ORACLE集群概念和原理(二) RAC 工作原理和相关组件(三) 缓存融合技术(四) RAC 特殊问题和实战经验(五) ORACLE 11 G版本2 RAC在LINUX ...
- 【转】【Oracle 集群】11G RAC 知识图文详细教程之RAC在LINUX上使用NFS安装前准备(六)
原文地址:http://www.cnblogs.com/baiboy/p/orc6.html 阅读目录 目录 介绍 下载软件 操作系统安装 Oracle安装先决条件 创建共享磁盘 参考文献 相关文章 ...
- Linux 客户端访问 NFS报Permission Denied错误
在Linux服务器上访问NFS共享目录时,报错:Permission denied. 如下截图所示: 因为这个NFS是系统管理员配置的,我又不了解具体情况,而系统管理员休假中,联系不上.那么我只能先多 ...
- linux pxe+dhcp+nfs+tftp
yum -y install vsftpd dhcp xinetd tftp-server syslinux(安装"syslinux"才有pxelinux.0) tftp 服务(v ...
- linux服务之nfs
开发语言:rpc编程环境 服务器端:在linux平台下部署 客户端:一般是cli界面下的mount命令 相关包:rpcbind,nfs-utils 背景 http://nfs.sourceforge. ...
- linux点滴:NFS
介绍 NFS,Network File System,网络文件系统.主要功能是通过网络让不同的主机系统间共享资源,类似于windows下的文件共享.适用于互联网中小型企业. 工作原理 客户端发送请求 ...
随机推荐
- wannafly 练习赛11 E 求最值(平面最近点对)
链接:https://www.nowcoder.com/acm/contest/59/E 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit ...
- JAVA 第十一周学习总结
20175308 2018-2019-2 <Java程序设计>第十一周学习总结 教材学习内容总结 13.1 URL类: URL类是java.net包中的一个类,用URL创建的对象可以获取U ...
- 安装mysql数据库要注意的
只安装基本功能即可,以后要的话可以加 需要配置环境变量 最好不要将数据存放在c盘,默认在 C:\ProgramData\MySQL\MySQL Server 5.6 里面存放建的表和存放的数据
- VS调试异常代码 HRESULT:0x80070057 (E_INVALIDARG)解决方法
我目前在做的一个系统是VS2010写的的B/S架构程序, 主要技术是:C#.SQLSERVER2008.NHibernate,Python,Nhibernate 的*.hbn.xml是映射数据库的表结 ...
- 快速入门分布式消息队列之 RabbitMQ(3)
目录 目录 前文列表 前言 通道 Channel 一个基本的生产者消费者实现 消费者 生产者 运行结果 应用预取计数 应用 ACK 机制 最后 前文列表 快速入门分布式消息队列之 RabbitMQ(1 ...
- 郝斌_GUI
85事件处理 import java.awt.Button; import java.awt.Frame; import java.awt.event.ActionEvent; import java ...
- PHP5和PHP7引用对比(笔记)
php5在引入引用计数后,使用了refcount_gc来记录次数,同时使用is_ref_gc来记录是否是引用类型. 例如 $a = 'hello'; //$a->zval1(type=IS_ST ...
- rename批量修改文件名
批量改名: 如文件,批量修改,把hello去掉[root@localhost wang]# ll-rw-r--r-- 1 root root 0 5月 14 02:36 a.hello.txt-rw- ...
- HTTPS测试
1.首先理解HTTPS的含义,清楚http与HTTPS的区别 2.相对于http而言,https更加安全,因 3.使用数字证书使传输更安全,数字证书使用keytool工具生成 测试准备: 创建公钥和秘 ...
- python 并发编程 多进程 队列
队列介绍 进程彼此之间互相隔离,要实现进程间通信(IPC),multiprocessing模块支持两种形式:队列和管道,这两种方式都是使用消息传递的 创建队列的类(底层就是以管道和锁定的方式实现) 制 ...