xfs文件系统 # ls /lib/modules/2.6.32-431.el6.x86_64/kernel/fs/
Netork File System
# cat /etc/centos-release
CentOS release 6.5 (Final)
# uname -r
2.6.32-431.el6.x86_64
# uname -m
x86_64
nfs-utils : rc.nfsd rpc.mountd
rpcbind
# rpm -qa rpcbind nfs-utils
# yum groupinstall "NFS file server" -y
# yum -y install rpcbind nfs-utils
/etc/init.d/rpcbind start
# ps -ef | grep rpc
rpc 1092 1 0 19:37 ? 00:00:00 rpcbind
rpcuser 1110 1 0 19:37 ? 00:00:00 rpc.statd
# rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 portmapper
# /etc/init.d/nfs start
chkconfig nfs on
chkconfig rpcbind on
# vi /etc/exports
#nfs shared date for by hequan at 20160403
/data 192.168.10.0/24(rw,sync)
# /etc/init.d/nfs reload 平滑重启 /usr/sbin/exportfs -r
# showmount -e localhost
Export list for localhost:
/data 192.168.10.0/24
# mount -t nfs 192.168.10.10:/data /mnt 挂载
#chmod o+w /data 共享目录的权限
-rw-r--r-- 1 nfsnobody nfsnobody 0 Mar 27 22:31 xx
# cat /var/lib/nfs/etab
/data 192.168.10.0/24(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)
[root@hequan data]# grep 65534 /etc/passwd
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
# ll /data -ld
drwxr-xrwx 2 nfsnobody nfsnobody 4096 Mar 27 22:33 /data
# /etc/init.d/rpcbind status
rpcbind (pid 40379) is running...
# /etc/init.d/nfs status
rpc.svcgssd 已停
rpc.mountd (pid 40423) is running...
nfsd (pid 40438 40437 40436 40435 40434 40433 40432 40431) is running...
rpc.rquotad (pid 40419) is running...
# ps -ef | grep -E "rpc|nfs"
# /etc/init.d/nfs restart
Shutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Shutting down RPC idmapd: [确定]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
正在启动 RPC idmapd: [确定]
man 进程名
/etc/exports 配置文件
/usr/sbin/exportfs 管理命令 -rv 加载配置剩下,等价优雅重启 ,直接共享目录
/usr/sbin/showmount 查看NFS配置 挂载结果
# cat /var/lib/nfs/etab 默认参数
/data 192.168.10.0/24(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)
#mount
192.168.10.10:/data on /mnt type nfs (rw,vers=4,addr=192.168.10.10,clientaddr=192.168.10.11)
EXAMPLE
# sample /etc/exports file
/ master(rw) trusty(rw,no_root_squash)
/projects proj*.local.domain(rw)
/usr *.local.domain(ro) @trusted(rw)
/home/joe pc001(rw,all_squash,anonuid=150,anongid=100)
/pub *(ro,insecure,all_squash)
/srv/www -sync,rw server @trusted @external(ro)
/foo 2001:db8:9:e54::/64(rw) 192.0.2.0/24(rw)
/build buildhost[0-9].local.domain(rw)
绝对路径 共享目录的本地权限(nfsnobody) 192.168.10.0/24
rw async异步 sync 同步 异步快,写到内存,不可靠
性能与可靠性
ro只读 all_squash 把用户变成匿名用户65534
确保所有服务器对NFS共享目录具备相同的权限
all_squash 把所有客户端都压缩成匿名用户
anonuid anngid
所有的客户端和服务端都需要有一个相同的UID和GID,nfsnobody(UID)
root_squash root映射成匿名用户
# useradd hequan -u 555 建立相同的UID的用户
vim /etc/exports
/data 192.168.10.0/24(rw,sync,all_squash,anonuid=555,anongid=555)
# mount 192.168.10.10:/data /mnt
将挂载信息写入fstab文件
vi /etc/fstab
192.168.10.10:/data /mnt/ nfs defaults 0 0
保存退出
mount -a
vi /etc/rc.local
/etc/init.d/rpcbind start
/bin/mount -t nfs 192.168.10.10:/data /mnt
开机自检,加载BIOS 读取MBR BOOT Loder 加载kernel内核 init进程 init进程执行rc.sysinit 启动内核模块 执行不同运行级别的脚本程序
不建议在fstab里面加载 网络NFS文件
自动挂载
维护模式或者救援模式:
文件系统只读
mount -o rw,remount / 重新挂载成可写
本文出自 “何全” 博客,请务必保留此出处http://hequan.blog.51cto.com/5701886/1759919
原文地址:http://hequan.blog.51cto.com/5701886/1759919