NFS配置要求:
1、 将oracle文件写入到NFS Server端,注意权限要与oracle端一致。
2、 Oracle端目录文件所属用户为oracle, uid:500 gid 501。
格式约定:
命令显示过程
NFS挂载问题一: Client端挂载后无权限写入
一、server端配置:
[root@db-0415 ~]# useradd
[root@db-0415 tmp]# tail -1 /etc/passwd #确认新建用户是否符合要求
oracle:x:501:500::/home/oracle:/bin/bash
[root@db-0415 ~]# vim /etc/exports
/opt/tmp
[root@db-0415 ~]# exportfs
exportfs: No options for /opt/tmp 10.0.0.0/16: suggest 10.0.0.0/16(sync) to avoid warning
exportfs: No host name given with /opt/tmp (rw,sync,all_squash,anonuid=501,anongid=500), suggest *(rw,sync,all_squash,anonuid=501,anongid=500) to avoid warning
exporting 10.0.0.0/16:/opt/tmp
exporting *:/opt/tmp
[root@db-0415 ~]# showmount
mount clntudp_create: RPC: Port mapper failure - RPC: Unable to receive
[root@db-0415 ~]# /etc/init.d/portmap start
Starting portmap:
[root@db-0415 ~]# /etc/init.d/nfs start
Starting NFS services:
exportfs: No host name given with /opt/tmp (rw,sync,all_squash,anonuid=501,anongid=500), suggest *(rw,sync,all_squash,anonuid=501,anongid=500) to avoid warning
Starting NFS quotas:
Starting NFS daemon:
Starting NFS mountd:
Starting RPC idmapd:
[root@db-0415 ~]# chkconfig
[root@db-0415 ~]# chkconfig
[root@db-0415 ~]# showmount -e
Export list for 127.0.0.1:
/opt/tmp (everyone)
二、Client 挂载测试无法写入:
[root@NFSclient1 ~]# mount -t
[root@NFSclient1 ~]# cd /opt/oracle/tmp/
[root@NFSclient1 tmp]# touch tt
touch: cannot touch `tt': Permission denied
三、开始排查NFS权限相关设置问题:
首先检查client端gid uid 与server端对应正常。
[root@NFSclient1 tmp]# su - oracle
-bash-3.2$ id
uid=501(oracle) gid=500(oinstall) groups=500(oinstall)
-bash-3.2$ exit
logout
第二、检查client本地文件系统针对目录/opt/oracle/tmp/读写权限,并使用oracle用户写入文件测试。
[root@NFSclient1 oracle]# ll /opt/oracle/tmp/ -d
drwxr-xr-x
[root@NFSclient1 oracle]# su - oracle
-bash-3.2$ cd /opt/oracle/
-bash-3.2$ touch 1
-bash-3.2$ rm 1
#可是挂载以后还是报权限错误:
[root@NFSclient1 ~]#
[root@NFSclient1 ~]# cd /opt/oracle/tmp/
[root@NFSclient1 tmp]# touch tt
touch: cannot touch `tt': Permission denied
[root@NFSclient1 tmp]# ll -d
drwxr-xr-x
[root@NFSclient1 tmp]# ls
tt
[root@NFSclient1 tmp]# ll
total 0
-rw-r--r--
[root@NFSclient1 tmp]# rm tt
rm: remove write-protected regular empty file `tt'? y
rm: cannot remove `tt': Permission denied
第三、确认NFS Server端rw权限设置,因为一直记得设置的rw权限,总觉着这没有问题。但其他方面都没有问题,配置文件参数较多需要细心再看看。
[root@db-0415 ~]# cat /etc/exports
/opt/tmp
[root@db-0415 ~]# cat /var/lib/nfs/etab
/opt/tmp
# 乍一看似乎两个文件内容没有问题,仔细对比之发现主配置文件ip段后多了一个空格“ 10.0.0.0/16 (rw”,这个应该就是问题所在。
第四、重新编辑配置文件exports :
[root@db-0415 ~]# vim /etc/exports
/opt/tmp
[root@db-0415 ~]# exportfs
exporting 10.0.0.0:/opt/tmp
[root@db-0415 tmp]# cat /var/lib/nfs/etab
/opt/tmp
第五、Client再次挂载测试:
[root@NFSclient1 ~]# mount -t
[root@NFSclient1 ~]# cd /opt/oracle/tmp/
[root@NFSclient1 tmp]# touch tt
[root@NFSclient1 tmp]# ls
test
[root@NFSclient1 tmp]# ll
total 4
-rwxrwxr-x
-rw-r--r--
[root@NFSclient1 tmp]# rm -rf test
[root@NFSclient1 tmp]# rm -rf tt
[root@NFSclient1 tmp]# chkconfig --list portmap #检查客户端portmap是否随机启动
portmap
[root@NFSclient1 tmp]# chkconfig portmap on
[root@NFSclient1 tmp]# chkconfig --list portmap #确认设置正确
portmap
[root@NFSclient1 tmp]# umount
四、设置NFS随机启动挂载:
方法一:
1、编辑fstab
[root@NFSclient1 tmp]# cd /etc
[root@NFSclient1 etc]# cp fstab fstab.bak$(date +%F)
[root@NFSclient1 etc]# vim fstab
10.0.4.15:/opt/tmp on /opt/oracle/tmp type nfs (rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,nfsvers=3,timeo=600,actimeo=0,addr=10.0.4.15)
2、确认修改内容
[root@NFSclient1 etc]# diff fstab fstab.bak2012-03-21
10d9
< 10.0.4.15:/opt/tmp
3、挂载测试。
[root@NFSclient1 etc]# mount -a
[root@NFSclient1 etc]# mount
………………省略内容………………
10.0.4.15:/opt/tmp on /opt/oracle/tmp type nfs (rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,nfsvers=3,timeo=600,actimeo=0,addr=10.0.4.15)
#再次确认权限正常
[root@NFSclient1 etc]# cd /opt/oracle/tmp/
[root@NFSclient1 tmp]# touch test
[root@NFSclient1 tmp]# ll
total 0
-rw-r--r--
[root@NFSclient1 tmp]# rm test
rm: remove regular empty file `test'? y
方法二(生产中推荐的方式):
避免系统无法正常启动,推荐将挂载命令写入rc.local
echo ' /bin/mount
至此已经满足要求,NFS配置完毕。
问题一解决过程涉的知识点:
NFS Server和client端的配置
1、修改NFS挂载匿名账户。
2、NFS挂载权限问题分析解决过程。
3、设置NFS开机自动挂载。
4、创建指定uid、gid用户
5、NFS服务相关命令mount、showmont、exportfs、chkconfig
6、记录NFS server完整权限的配置文件/var/lib/nfs/etab
挂载问题二: Client端挂载后一直不动要等很久才有错误输出,原因因为没有启动portmap服务。
[root@study ~]# mount -t
mount.nfs: Input/output error
[root@study ~]# /etc/init.d/portmap status
portmap is stopped
[root@study ~]# /etc/init.d/portmap start
Starting portmap:
[root@study ~]# mount -t
[root@study ~]# chkconfig portmap on
问题二结论:
NFS client 必须要启用portmap服务
NFS server 必须要先启动portmap服务然后启用nfs服务。
注意设置随机启动。
总结:
NFS权限需要注意三个条件:
1、用户账户的UID GID及对应用户名组名。
2、NFS服务器端主配置文件/etc/exports允许读写权限。
3、文件系统需要具有读写的权限,特别说明这个权限不是以用户名组名为根据,了解文件系统的同学应该知道,这个权限是比对uid、gid。
老男孩
1、杀鸡不用牛刀,这个要注意!
[root@NFSclient1
[root@NFSclient1
2、另外,nfs放fstab里不是很妥。
老男孩
本文出自 “Dreamway的linux博客” 博客,请务必保留此出处http://blog.sina.com.cn/s/blog_506ed9e6010113z2.html