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