Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1216852
  • 博文数量: 259
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 2518
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-13 16:12
个人简介

科技改变世界,技术改变人生。

文章分类

全部博文(259)

分类: 系统运维

2016-03-03 14:32:27

业务开发部署需要共享一个目录,采用nfs方式,整理了一下操作方法,共享出来,需要了解nfs的网上搜索下。

一、规划:
业务
10.111.32.50
10.111.32.51

NFS server
10.111.32.52


二、操作
a)Nfs server 10.111.32.52
mkdir /share1
chmod o+w /share1
vim /etc/exports
/share1    10.111.32.50(sync,rw,no_root_squash) *(sync,rw)
service nfs start
chkconfig nfs on


b)client 10.111.32.50
mkdir /sharedisk
[root@testserver1 /]# showmount -e 10.111.32.52
Export list for 10.111.32.52:
/share1 (everyone)


mount 10.111.32.52:/share1 /sharedisk

开机启动
10.111.32.52:/share1 /sharedisk nfs    defaults 0 0

c)client 10.111.32.51
mkdir /sharedisk
[root@testserver1 /]# showmount -e 10.111.32.52
Export list for 10.111.32.52:
/share1 (everyone)

mount 10.111.32.52:/share1 /sharedisk

开机启动
vi /etc/fstab
10.111.32.52:/share1 /sharedisk nfs    defaults 0 0

vi /etc/rc.local
/bin/mount -t nfs -o rw 10.111.32.52:/share1 /sharedisk


检查是不是有挂载NFS
nfsstat -m




三、问题
问题1:卸载的时候报错
umount.nfs: /media/nfs_share: device is busy
解决方法:
fuser -km /sharedisk 强制umount
如果上边的不好用使用 umount -f /sharedisk

问题2:
[root@server data2]# service nfs restart
Shutting down NFS daemon:                                  [FAILED]
Shutting down NFS mountd:                                  [FAILED]
Shutting down NFS quotas:                                  [FAILED]
Shutting down NFS services:                                [  OK  ]
Starting NFS services:                                     [  OK  ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
                                                           [FAILED]
Starting NFS mountd:                                       [FAILED]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
rpc.nfsd: unable to set any sockets for nfsd
                                                           [FAILED]

解决方法:启动rpcbind&rpcidmap rpcbind是6.0版本后默认的RPC服务,所以要先于nfs启动。如果不启动rpcidmap则会造成用户权限的映射错误,用户的权限看起来是一串数字。

# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
# /etc/init.d/rpcidmapd start
Starting RPC idmapd: [ OK ]
# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]


问题3:
服务器没有showmount命令
yum install showmount



问题4:
普通用户没有删除权限。
rm: remove write-protected regular empty file monitor

错误的权限:
-rwxrwxrwx 3 nobody nobody 4096 Mar 11 14:26 monitor
发现文件都是nobody

正确的权限:
-rwxrwxrwx 3 www www 4096 Mar 11 14:26 monitor

解决方法:
[root@centos etc]# vi /etc/idmapd.conf
[Mapping]
Nobody-User = www
Nobody-Group = www

[root@centos etc]# service rpcidmapd restart
正在启动 RPC idmapd:[确定]
正在启动 RPC idmapd:[确定]

可以在多个客户端设置不同的用户名,查看的时候文件显示不同属主属组。

参考:
http://blog.csdn.net/lhfeng/article/details/7297963
http://blog.sina.com.cn/s/blog_5ca0198e0101j68n.html

阅读(1883) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~