- Push them as BLOBs into the database (or your NoSQL system such as MongoDB).
- Store them on disk that is accessible by several servers.
- Store them on a "File Server as a Service" like Amazon S3.
This time we'll focus on the second option: DIY with Network Services The basic solution for DIY is installing a file sharing daemon on one of your servers and share a folder of it to the other web servers. There are three common file sharing protocols that may be used:
- SAMBA (that is common and supported by Windows as well).
- NFS (supported only on *NIX machines).
- CIFS that mostly used in Windows, but can be mounted to LINUX machines as well.
In this case I decided to focus on the NFS implementation, so stay tuned:
NFS Configuration First configure the NFS server
- Install the NFS RPM: yum -y install nfs-utils
- Start service: /etc/init.d/nfs start
- Open the relevant ports in the iptables FW (2049 and 111):
- iptables -I INPUT -p tcp -s 192.168.85.0/24 -m state --state NEW,RELATED,ESTABLISHED --dport 2049 -j ACCEPT
- iptables -I INPUT -p udp -s 192.168.85.0/24 -m state --state NEW,RELATED,ESTABLISHED --dport 2049 -j ACCEPT
- iptables -I INPUT -p tcp -s 192.168.85.0/24 -m state --state NEW,RELATED,ESTABLISHED --dport 111 -j ACCEPT
- iptables -I INPUT -p udp -s 192.168.85.0/24 -m state --state NEW,RELATED,ESTABLISHED --dport 111 -j ACCEPT
- Configure exported locations by editing /etc/exports according to the following examples:
- Provide every server behind the firewall R/W to this folder: /path/to/directory *(rw)
- Provide a single server read only permission to this folder: /path/to/directory 192.168.2.21(ro)
- Finally load these exported locations: /usr/sbin/exportfs -a
Finall mount this disk to all other servers:
- Create local directory: mkdir /local/directory
- Add line to /etc/fstab
- SOURCE_SERVER:/path/to/directory /local/directory nfs
- Mount the folder: mount /local/directory
Keep Performing, Moshe Kaplan