Categories
Linux

NFS4

In my post to NFS I decribed how to create and attach a NFS folder.

Last week a colleague asked me to double check the version of this NS folder on the client. It turns out, that it was NFS3 only and not NFS4.

Interestingly this depends on the file permissions of the parent folder. The parend folder has to be read- and executable for others.

myAppServer1 – Server

chmod o+rx /app/myApp
exportfs -r
exportfs -s

myAppServer2 – Client

umount /app/myApp/uploads
mount /app/myApp/uploads
mount
-> myAppServer1.mynetwork.net:/app/myApp/uploads on /misc/myapp_uploads type nfs4 
Categories
Linux

NFS

NFS - Network File System

We have two Linux servers, each with one Tomcat application server. Both application servers must have access to one folder to up- and download files.

We will create a folder on the first server and enable access through the network on this server for the second server.

Operating System: RedHat Enterprise Linux 7

myAppServer1 - Server

vim /etc/exports

systemctl list-units *nfs-server*
# if 0 loaded units, you have to enable and start

systemctl enable nfs-server.service
systemctl start nfs-server.service
systemctl list-units *nfs-server*
exportfs -r
exportfs -s
/app/myApp/uploads myAppServer2.mynetwork.net(rw,sync)

myAppServer2 - Client

vim /etc/fstab
vim /etc/auto.master
vim /etc/auto.misc

systemctl enable autofs.service
systemctl start autofs.service

su tomcat
ls -lisah /app/myApp/uploads
# add:
myAppServer1.mynetwork.net:/app/myApp/uploads   /app/myApp/uploads     nfs     user,timeo=3,bg 0       0
# add:
/misc   /etc/auto.misc  --timeout 0 --negative-timeout 5
# add:
myapp_uploads     -fstype=nfs,bg,timeout=-1,timeo=5,rw,tcp,soft,intr,nosuid myAppServer1.mynetwork.net:/app/myApp/uploads

Test

Reboot both servers and doublecheck that the folder is still available and accessible from both servers.

reboot now

su tomcat
ls -lisah /app/myApp/uploads

Open webapplication in your browser on myAppServer1 and upload a file. Test download of the file.
Switch to myAppServer2 and download file.

Open webapplication in your browser on myAppServer2 and upload a file. Test download of the file.
Switch to myAppServer1 and download file.

NFS4 - Update

Please also note this post: NFS4