2

I have two Linux servers ATM that are 100% clones of each other and they use NFS mounts for writing log files to a single NAS. The IPs get NAT'd to a unique IP so there are no IP conflicts and they can talk to the shared NAS. When both servers are on at the same time they are overwriting each other's logs because they are both writing the same file names. My easy solution is the change both of the machine's fstab to make the servers mount different locations:

Original Server1 fstab: nas1:/data /data

Original Server2 fstab: nas1:/data /data

Modified Server1 fstab: nas1:/server1/data /data

Modified Server2 fstab: nas1:/Server2/data /data

The issue here is scalability. If I was to make 10 clones it might be managable to modify the fstabs but not so much at 100+. I don't have control over how the clones are made I just get the servers pre-built with cloned images already loaded. So I'd be stuck manually modifying each server.

I'm wondering if there are any alternatives floating out there that can deal with something like this. I'd like a mechanism that could somehow translate the fstab entries: nas1:/data to nas1:/server1/data. The "server1" can be anything really just as long as it maps to something unique that I can use to distinguish between server logs.

Thanks!

0

A few options:

  1. Your configuration management system should be updating /etc/fstab for you.
  2. Use autofs which supports variable substitution and one variable is HOST.
  3. Use a more robust logging system such as syslog. Many syslog implementations let you specify log file paths that include variables such as hostname.
| improve this answer | |
  • The software is legacy and unfortunately won't be changing anytime soon. Our configuration management is giving us the official release image as it was delivered many years ago. New development is happening now but we still need to maintain the legacy until we are fully converted. Some of the services that write these logs run at boot. Would autofs have the mount points available during bootup? – umhelp Jul 23 '19 at 19:34
  • Depends on the OS. For Ubuntu Bionic /lib/systemd/system/autofs.service exists and contains [Install] WantedBy=multi-user.target so it will be available once the multi-user target is reached. Systemd is flexible though so you could create a dependency between it and a service that requires it. – Mark Wagner Jul 25 '19 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.