验证码文件保存NFS配置

inspect ip under centOS:
sudo su -
ifconfig
#eth0      Link encap:Ethernet  HWaddr 00:25:90:00:85:C4
#             inet addr:10.37.30.70  Bcast:10.37.30.127  Mask:255.255.255.192

#server
sudo su
mkdir -p /home/sharing
chown app:app /home/sharing
mkdir -p /home/sharing/captchas
chown app:app /home/sharing/captchas

vi /etc/exports
#add line, 10.37.30.70为客户端IP
# /home/sharing 10.37.30.70(rw,sync,no_root_squash)
#10.37.30.70 (rw,sync,no_root_squash)  ip和括号间不能有空格   对应的客户端touch会出错 touch: cannot touch `/home/sharing/captchas/test5': Read-only file system


修改/etc/exports后必须重启下面的服务
/etc/init.d/nfs restart
/etc/init.d/portmap restart


#client 
sudo su
mkdir -p /home/sharing
chown app:app /home/sharing
mkdir -p /home/sharing/captchas
chown app:app /home/sharing/captchas

#要保证app的uid和服务器的app的uid是一致的,su 到app用id命令查看, 不一致要用/usr/sbin/usermod命令改为一致,
# eg:/usr/sbin/usermod -u 788 app
#修改后退出重新登录,并修改/home/www目录的owner:sudo chown app:app -R /home/www

/etc/init.d/portmap start

#10.18.36.130为服务器IP
mount 10.18.36.130:/home/sharing/captchas /home/sharing/captchas
mount
#看效果,应该有类似:
#10.18.36.130:/home/sharing/captchas on /home/sharing/captchas type nfs (rw,addr=10.18.36.130)


vi /etc/fstab
#add line: 
# 10.18.36.130:/home/sharing/captchas /home/sharing/captchas nfs defaults 0 0

su app
touch /home/sharing/captchas/test
ll /home/sharing/captchas/

#服务器
su app
ll /home/sharing/captchas/

如果都看到test文件了,说明配置OK


mount: 10.16.254.130:/home/sharing/captchas failed, reason given by server: Permission denied
可能的原因:
1、/etc/hosts里指定了IP--主机名,删之(建议不要擅自修改/etc/hosts);
2、可能是NFS服务器端/etc/exports设置的权限不对;
3、SELinux的问题:
[root@rhel5 ~]# setsebool -P nfs_export_all_rw on

你可能感兴趣的:(centos)