Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have twin web servers (FC1) that are pseudo loadbalanced via DNS round robin. I need a way to replicate new content to both servers instantly. So far I have come up with this.
Run at startup:
dnotify -MCDRB /webroot -e /rsync-script &
The /rsync-script will simply propogate changed files from the first webserver over to the second fairly instantaneously, using rsync.
The only thing im uneasy about is having the /rsync-script invoked every time a file is transferred via FTP to the first server. During the transfer of some smaller files, this couldmean the script is run hundreds of times a second. Even If it does run reliably at that speed, I think I may run into problems because dnotify will invoke rsync at the end of every file transfer, yet rsync will attempt to transfer all files that have changed. It is my understanding that dnotify can not specify which individual files have changed in a directory - only that files ave indeed changed, so we cant just transfer them one at a time.
Does anyone else have a more elegant solution to this problem?
I was thinking you could use dnotify to write a timestamp into a file (date +%s > timestampfile) or just use the touch command to update its timestamp. Then, you'd know the last time a file in the directory was changed.
The next step is to have a cron job running that checks the file every so often, and if sufficient time has passed since the timestamp file was updated, run rsync.
One drawback is rsync will run unnecessarily quite a few times.