2

Need some help here with NFS. Here's what I have (all servers running CentOS 5.6 with SELinux):

172.17.20.1 - Primary server with static IP. Varnish redirects requests to the web servers.
172.17.20.2 - Web server 1
172.17.20.3 - Web server 2

The application residing on the web servers is running Drupal and I need both of them to share the same files directory. I have created a folder in 172.17.20.1 called /var/nfs with root user. Here is my /etc/exports content:

/var/nfs    172.17.20.2(rw,sync,no_root_squash) 172.17.20.3(rw,sync,no_root_squash)

On both the web servers (172.17.20.2/3), I have it mounted like below:

[root@web2 ~]# mount
...
172.17.20.1:/var/nfs on /mnt/nfs/var/nfs type nfs (rw,sync,hard,intr,addr=172.17.20.1)

On all the servers, I've added the user apache to the root group to get the desired write access:

[root@main ~]# cat /etc/group
root:x:0:root,apache
....
....
apache:x:48:

[root@web1 ~]# cat /etc/group
root:x:0:root,apache
....
....
apache:x:48:

Folder permission on main:

drwxrwxr-x  4 root root 4096 Mar 11 15:49 nfs

Folder permission on web servers:

drwxrwxrwx   3 apache apache  4096 Feb 18 13:51 mnt

Despite all this, when I try to write files into the /mnt/nfs/var/nfs folder from Drupal/PHP, it cannot write to it. I even tried with a simple PHP upload script but it doesn't work, so the problem is not with Drupal.

Any help you guys can do is much appreciated. I've spent hours and hours with it, without any success :(

Thanks in advance.

Mohammad Emran
  • 195
  • 1
  • 2
  • 8

1 Answers1

1

I've added the user apache to the root group to get the desired write access

But you've not shown us what the permissions are on the files / directories. (and BTW this is not a good idea from a security stand point - similar for no_root_squash).

Why sync?

symcbean
  • 21,009
  • 1
  • 31
  • 52
  • I've updated the question with the permissions. I know its not a good idea, but I've tried everything desperately! Syncing is needed because files will be uploaded in both web nodes - unless synced to a central place, the servers will not have each others file. – Mohammad Emran Mar 26 '12 at 13:36
  • 1
    This does look like a simple permissions issue - unless you've got syncronised uids across server and client then the simplest solution will be to make the directory on the server rwx for other. – symcbean Mar 26 '12 at 15:03
  • http://serverfault.com/questions/554659/selinux-contexts-with-nfs-shares – c4f4t0r Feb 07 '15 at 16:16