linux学习笔记--NFS
NFS分为客户端,服务端。客户端要访问服务端,要写从RPC服务获得端口。
整个流程分为:
1,服务端rpc服务先启动
2,nfs服务把端口上报给rpc服务
3,rpc客户端通过服务端的rpcbind拿到访问端口
4,rpc客户端通过端口访问文件
rpc服务,在centos5.x下叫portmap,在centos6.x下叫rcpbind
客户端也要有rpc才能访问服务端
所以NFS的软件列表:
nfs-utils
rpcbind
安装NFS
yum install nfs-utils rpcbind
最好客户端也要安装
查看是否已安装
rpm -qa nfs-utils
lsof -i:111
查看状态
/etc/init.d/rpcbind status
查看rpc池的信息
rpcinfo -p localhost
注意:一定要先启动rpcbind,然后再启动nfs。因为nfs会把端口上报给rpc
[root@nfsServer init.d]# /etc/init.d/nfs status
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
[root@nfsServer init.d]#
[启动nfs服务
[root@nfsServer init.d]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
再看rpc池的信息就有很多了
[root@nfsServer init.d]# rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 875 rquotad
100011 2 udp 875 rquotad
100011 1 tcp 875 rquotad
100011 2 tcp 875 rquotad
100005 1 udp 36696 mountd
100005 1 tcp 59667 mountd
100005 2 udp 36644 mountd
100005 2 tcp 36430 mountd
100005 3 udp 49056 mountd
100005 3 tcp 55778 mountd
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 2 tcp 2049 nfs_acl
100227 3 tcp 2049 nfs_acl
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
NFS的配置文件:
/etc/exports
格式:
nfs共享目录 nfs客户端地址(参数1,参数2)
把/image文件夹共享给103 104的机器
[root@nfsServer log]# cat /etc/exports
/image 192.168.1.103(rw,sync) 192.168.1.104(rw,sync)
共享给所有用户
/data *(rw,sync)
重启nfs
/etc/init.d/nfs reload
查看共享的文件夹
[root@nfsServer ~]# showmount -e 192.168.1.102
Export list for 192.168.1.102:
/image 192.168.1.104,192.168.1.103
挂在本机上试试
[root@nfsServer image]#
[root@nfsServer image]# mount -t nfs 192.168.1.102:/image /mnt
[root@nfsServer image]# cd /mnt/
[root@nfsServer mnt]# ls
baseImage.log
但是这时候通过/mnt 写入权限不足???
[root@nfsServer image]# cd /mnt/
[root@nfsServer mnt]# touch xc.log
touch: cannot touch `xc.log': Permission denied
因为有些权限没有配置,所以在服务端看来,所有有的访问都是65534(nfsnobody)的用户权限
[root@nfsServer mnt]# cat /var/lib/nfs/etab
/image 192.168.1.*(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,
no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,root_squash,no_all_squash)
这时候如果客户端写的文件权限是nfsnobody,服务端的是root(服务端的用户)
[root@nfsServer mnt]# ls -l
total 0
-rwxrwxrwx 1 root root 0 Jul 23 03:09 baseImage.log
-rw-r--r-- 1 nfsnobody nfsnobody 0 Jul 23 03:44 vv.log
参数说明:
sync 写入到磁盘,同步写
async 异步写
root_squash 如果用户是root的话,回映射成匿名用户
no_root_squash 客户端访问共享文件夹,客户端用户如果是root的话,有root权限
all_squash 不管用户权限如何,都会压缩成匿名用户nfsnobody(anonuid=65534,anongid=65534),uid gid是可以改的
客户端:
要启动bind服务
[root@nfsClient01 etc]# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
客户端查看是不是能和服务端连上
[root@nfsClient01 etc]# showmount -e 192.168.1.102
Export list for 192.168.1.102:
/image 192.168.1.*
没有问题的话,客户端就可以mount挂载了
排查错误:
先ping 看能不能通
111是nfs的主端口
telnet 102.168.1.102 111
exportfs -rv 等价于 /etc/init.d/nfs reload
服务端的参数
cat /var/lib/nfs/etab
客户端的参数
cat /proc/mounts
linux学习笔记--NFS的更多相关文章
- Linux 学习笔记
Linux学习笔记 请切换web视图查看,表格比较大,方法:视图>>web板式视图 博客园不能粘贴图片吗 http://wenku.baidu.com/view/bda1c3067fd53 ...
- Linux 学习笔记之超详细基础linux命令 Part 7
Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 6----------------- ...
- Linux 学习笔记之超详细基础linux命令 Part 5
Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 4----------------- ...
- linux学习笔记2-linux的常用命令
第一篇博客:linux学习笔记1-ubuntu的安装与基本设置 之中,已经介绍了如何安装linux操作系统,以及一些基本的设置修改. 本篇博客主要介绍linux中的一些常用的终端命令 ======== ...
- Linux学习笔记(一)2015.4.13
研究生由单片机转Linux学习 首先安装VMware虚拟机,用的是VMware 10.0 在VMware 10.0上安装视频上推荐的Red Hat Linux 5 安装后正式进入Linux学习 笔记1 ...
- 20160127 linux 学习笔记
Linux学习笔记第一天 Linux基本介绍 Linux的起源和发展: 简单说linux是一种操作系统,可以安装在包括服务器.个人电脑,乃至PDA.手机.打印机等各类设备中. 起源: Linux起源于 ...
- linux —— 学习笔记(汇总)
笔记目录:一.系统知识 和 基本概念 二.常用操作 三.系统管理(内存.设备.服务等管理) ...
- Linux学习笔记-林耐斯Notes-Linux就该这么学
Linux学习笔记... 参考的优秀Linux网站: http://www.w3cschool.cn/linux/ http://www.linuxeye.com/ http://linux.vbir ...
- Linux~学习笔记目录索引
回到占占推荐博客索引 本篇文章是对自己学习Linux及在它的环境下部署工具的一个总结,以方便自己查阅,也给他人一个帮助,本文章同时会不断的更新,欢迎大家订阅! 本目录包括的内容会包括linux基础命令 ...
随机推荐
- sqlalchemy
#!/usr/bin/env python #coding:utf8 from sqlalchemy import create_engine,and_,or_,func,Table from sql ...
- Unsupported major.minor version 51.0解决办法
问题: 之前使用的是高版本的myeclipse2015ci,然后换成了myeclipse10.5,之前的workspace的内容没有改变,结果工程都出现了感叹号,运行时提示 Unsupported m ...
- NDK问题总结
转自 这篇文章中很多东西!!:http://blog.chinaunix.net/uid-20746260-id-3910616.html 1. 创建JNI头文件 在工程目录下输入: javah -c ...
- Ajaxtoolkit Combobox位置显示不对解决
当父级容器设置positon是absolute或relative,combobox显示的就会出现偏移,解决办法如下: 添加这个样式 .ajax__combobox_itemlist{ posit ...
- Momo自定义DialogFragment
在Fragnment弹窗提示 XML <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&q ...
- fdfdfdfdfdfdfdfdfdfdfd
len := Length( Face[integer(FaceType)][Line-1] ); SetLength( Face[integer(FaceType)][Line-1], Len+1 ...
- Java使用Mysql数据库实现批量添加数据
EmployeeDao.java //批处理添加数据 public int saveEmploeeBatch(){ int row = 0; try{ con = DBCon.getConn(); S ...
- 1,SFDC 开发篇 - 类对象和SOQL查询
1,类对象 & 接口 & 属性 2, Object & SOQL
- Effective c++
static 声明在堆上申请静态存储 对于局部变量,将存储方式改为静态存储 对于全局变量,将连接方式局限在文件内 类中static变量:属于整个类,独立存储,没有this指针 inline inlin ...
- nodeJs 模块cookie-session api文档中文翻译,偶自己翻译的
原文英文文档链接点击 说明 简单的 基于cookie的 session中间件 安装 它是一个可以用npm注册的node模块,可以通过npm install命令安装 npm install cookie ...