Talkback for article: 199, March2001

Realtime data mirroring on Linux

Back to: http://cgi.linuxfocus.org/English/March2001/article199.shtml

From: Neal Becker <nbecker(at)fred.net> [ date: 2001-03-05 ]
The FAM site seems very quiet. Is it alive? Where is 2.4.xxx support?
From: szaka <szaka (at) sienet.hu> [ date: 2001-03-06 ]
2.4.x supports file/directory notification out of the box,
for more see /usr/src/linux/Documentation/dnotify.txt
From: guido socher <guido(at)linuxfocus.org> [ date: 2001-03-09 ]
Thanks for this hint. Nobody from the LinuxFocus
team was really aware of this new 2.4 Kernel feature:
http://www.yggdrasil.com/cgi-bin/cvsweb.cgi/linux/Documentation/dnotify.txt?rev=1.1

Many other readers will find this information as well useful.
From: Atif Ghaffar <aghaffar(at)developer.ch> [ date: 2001-03-12 ]
Hi Szaka,
thanks for the info about dnotify.
I have asked about the possibility of using it with fam at the FAM mailing list.


From: Johan Isacsson <johan(at)mgon.com> [ date: 2001-03-13 ]
The dnotify approach requires a filehandle for each file being watched (at least that's how i understood it). For large directories that could be a problem.
I think the imon approach is more elegant :) There is a version of imon for 2.4 kernels, when i last checked it was for test9 i think.
Unfortunately imon and possibly fam has some limitations. Imon uses kmalloc to allocate memory for the hashtable where it keeps all inode numbers to monitor. For a large directory the hash table needed to be bigger than 128 k. Kmalloc can't allocate larger chunks than that.
I tried to use vmalloc instead but there seem to be something more that needs to be done (it could be in fam or imon).
I think what this article describes would be a very good thing to have working. If the fam/imon folks see a large interest in getting imon to work with large directories it will proibably be fixed soon. They have a mailinglist... :P

From: Atif Ghaffar <aghaffar(at)developer.ch> [ date: 2001-03-15 ]
Another File synchronizer I came through today is
Unison
http://www.cis.upenn.edu/~bcpierce/unison/

I havent tested it yet, just went through the online docs.



From: tom [ date: 2001-06-04 ]
hi,
very interesting article -thanks.
another question:
how you would sync two (failover) webservers with (postgres-)databases installed?

thanks in advance,
tom
From: Kelly McGranahan <sv1(at)myrealbox.com> [ date: 2001-09-05 ]
Database failover should always be done with database specific utilities. If you look on the Postgresql to list replication and failover are listed on the top as urgent. Hopefully, we will see some inherant abilities soon.
From: Vladimir Natalenko <vladimir(at)milo1.com> [ date: 2001-09-18 ]
Hi All!

I tried to set up Installing FAM and IMON. It was ok.
But when I tried to set up Installing SGI::FAM Perl module I had received the message:

[root@bkupdirector SGI-FAM-1.002]# perl Makefile.PL
Ignore "Not a known parameter name" warnings.'PRCS_PROJECT' is not a known MakeMaker parameter name.
Note (probably harmless): No library found for -lC

I could not find module "ExtUtils::MM_PRCS". It seems to me this module is required.
Could you please to help me. What should I do? Where can I find this module.
Thank you in advance for your prompt answer.

Vladimir Natalenko
From: Gonzalo <gonzalo(at)unixpac.com.au> [ date: 2001-11-19 ]
Vladimir,

Perhaps this will help?:

http://prcs.sourceforge.net/


From: Bill <bill(at)_REMOVEME_sanac.net> [ date: 2001-12-20 ]
Hi,

I've played a bit with many filesystems trying to solve the synchronisation problem...

do you think this solution could be adapted to a two-hosts cluster acting both as webservers AND ftpservers?

thanks!

Bill
From: Kingsley Tart <kingsley(at)skymarket.co.uk> [ date: 2002-01-03 ]
We have some web sites with active content - some sites have CGI programs that manage bulletin boards, for example. As far as I understand it, the scenario with one FTP server and a cluster of web servers replicating from it would fall down in this situation. Is this sort of thing beyond the current scope of FAM and IMON?

Cheers,
Kingsley.
From: Kingsley Tart <kingsley(at)skymarket.co.uk> [ date: 2002-01-04 ]
We have some web sites with active content - some sites have CGI programs that manage bulletin boards, for example. As far as I understand it, the scenario with one FTP server and a cluster of web servers replicating from it would fall down in this situation. Is this sort of thing beyond the current scope of FAM and IMON?

Cheers,
Kingsley.
From: Brian McQueen <bqueen(at)nas.nasa.gov> [ date: 2002-02-22 ]
Here is a nice page on our technique for sync'ing our web servers using
fam and imon. The client/server code is available, but its beta:

http://www.nas.nasa.gov/Groups/WWW/subpages/topology.html

From: jib [ date: 2002-07-23 ]
I've got a problem to install SGI::FAM, this way don't works on my configuration (mandrake 8.2), it seems to be library problem and I'm not able to see where it is. Can somebody help me? I download last perl version.
From: jean francois panico <922354(at)sitoverde.com> [ date: 2002-08-01 ]
In MDK8.2 you have to install fam-...rpm, libfam-...rpm, and libfam-devel...rpm BEFORE installing SGI::FAM.
That's all you need to get it running.

Bye
JF

From: philippe <pizoret(at)free.fr> [ date: 2002-12-01 ]
it is possible to avoid the size limitation of imon ?
by exemple with several instance of script fam_mirror , launch on several part of the big arborescence ..

perhaps it's a folish thinks ...

Thanks .
From: Bernd Hinrichsen <hinrichsen(at)gamax.de> [ date: 2003-01-22 ]
Hallo all!
I have a problem running SGI::FAM scripts on my Redhat 7.2 box. I have no problems running the fam test script but all perl scripts result in a 'Your vendor has not defined SGI::FAM macro new at...'. This is after a successfull installation of SGI::FAM according to CPAN.

Any ideas?

Thnx
Bernd
From: MichaelPavlovsky <spavlov(at)t2.technion.ac.il> [ date: 2003-02-12 ]
Hi,
I think that "fam & imon" are nice tools but
there are tons of similar solutions for resource monitoring.
By resources I mean file system's trees or even shared memory.
The real problem in my opinion is a notification!.
Fam worths nothing without fast, " reliable " messaging system.
I think that current solution is not fast and clean enough.
If you know about anything worth looking please send me a link.

Thanks,
Michael Pavlovsky:
"spavlo@t2.technion.ac.il"
From: Penguin <penguin(at)linuxdumps.com> [ date: 2003-02-28 ]
Hey.... I have 2 file servers each with 400GB of data. Is it feesable to use your method to replicate in realtime between the 2?

thx

From: ponomario <ponomario(at)yahoo.es> [ date: 2003-03-21 ]
Hi....

I have a problem when try install the module SGI::FAM display follow errors:

BEGIN failed--- compilation aborted at t/fam.t line 1
t/fam... dobious
test returned status 2 (wstat 512 0x200)
FAILED test script could be run alas--no output ever seen
make *** [test_dynamic error 2]
/usr/bin/make test not Ok

running make install
make test had returned bad status, won't install without force

Any ideas?


thanks for the atention lent...


PD: sorry for my english
From: kapachov <ponomario(at)yahoo.es> [ date: 2003-03-26 ]
hi
I can install the module, I do manualy

#perl Maekefile.pl
#make
#make test (optional)
#make install

But now I try run the progrma monitor or fam_mirror.

for example:

#./monitor /var/www/

or

#./fam_mirror /var/www


this show me that error:


Your vendor has not defined SGI::FAM macro new at ./monitor (or ./fam_mirror) in the line ?


thanks for the atention lent....

From: Alguien [ date: 2003-05-15 ]
El error "Your vendor has not defined SGI::FAM" esta en el codigo
la funcion AUTOLOAD en FAM.pm:

sub AUTOLOAD {
my $constname;
($constname = $AUTOLOAD) =~ s/.*:://;
my $val = constant($constname);
if ($! != 0) {
if ($! =~ /Invalid/) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
} else {
croak "Your vendor has not defined SGI::FAM macro $constname";
}
}
eval "sub $AUTOLOAD { $val }";
goto &$AUTOLOAD;
}

Incluye una comprobacion de error en "ingles":

" if ($! =~ /Invalid/) { "

en las versiones en castellano deberia ser:

" if ($! =~ /inválido/) { "

Se me ha ocurrido usar "use English" pero no funciona. Una solucion de urgencia es modificar el esa linea de codigo de FAM.pm:

" if ($! =~ /inv/i) { "

Si a alguien se le ocurre otra cosa....


From: Stanislav Brabec <sbrabec(at)suse.cz> [ date: 2003-06-09 ]
"LANG=C LC_ALL=C fam_mirror" works around "Your vendor has not defined SGI::FAM macro new at ./fam_mirror line 50" for all locales.
From: Siti Muna Payordueramae [ date: 2003-07-17 ]
i think FAM is very intresting.. but i'm haven't basic in peal.. just have a little bit basic in unix... can anybody tell me how to install FAM, i means from the first step untill how to run the programming... thank u
From: Maurizio <matalla(at)inwind.it> [ date: 2003-07-17 ]
Hi,
i'm trying to get through with fam_monitor but my (maybe stupid) problem is: how do i transfer my RSA (DSA) data in order to go through ssh without authorization ..better with key-pair authorization ?

Thanks

Maurizio
From: james bya <hustjby(at)sohu.com> [ date: 2003-11-26 ]
i could not make the perl script run rightly because the same no vendor something like this.So i rewrite it by c.Now it works.But it has not been well tested.Anyone who are interesting plz mail hustjby@sohu.com and maybe u can give me some suggestion
From: Zia <zia(at)zort.org> [ date: 2003-12-12 ]
Hi Atif,

Great script (fam_mirror).

I just needed it to be a daemon instead appending a & with it and putting in background. So, worked on it a bit, came up with a decent Daemon. Here is the patch:

--- patch starts here ---

--- fam_mirror 2003-12-12 00:05:11.000000000 +0800
+++ fam_mirrord 2003-12-12 22:16:38.000000000 +0800
@@ -45,6 +45,7 @@
use File::Basename;
use File::Find;
use SGI::FAM;
+use POSIX;

#start a fam object
my $fam=new SGI::FAM;
@@ -102,7 +103,38 @@
# for the timebeing you can run it with &
# perhaps I will use POE at somepoint with this

-while (1) {
+# Put the program in DAEMON mode... Zia (zia at zort dot org)
+my $pidFile = '/var/run/fam_mirrord.pid';
+chdir("/")
+ or die "Couldn't chdir to /: $!";
+open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
+open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
+open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
+umask 0;
+my $pid = fork;
+if ($pid) # parent: save PID
+{
+ open PIDFILE, ">$pidFile" or die "can't open $pidFile: $!\n";
+ print PIDFILE $pid;
+ close PIDFILE;
+ exit 0;
+}
+die "Couldn't fork: $!" unless defined($pid);
+
+POSIX::setsid()
+ or die "Can't start a new session: $!";
+
+my $time_to_die = 0;
+
+sub signal_handler {
+ $time_to_die = 1;
+}
+
+$SIG{INT} = $SIG{TERM} = $SIG{HUP} = &signal_handler;
+# trap or ignore $SIG{PIPE}
+
+
+while ($time_to_die) {
do {
$event=$fam->next_event;
$dir=$fam->which($event);

--- patch end here ---

If you want the whole code with the daemon code in it, you can get it here: http://zort.org/work/codes/fam/fam_mirrord

I have also created a startup (/etc/init.d/fam_mirrord) script for Redhat, you can get it here: http://zort.org/work/codes/fam/fam_mirrord-redhatstartup

Regards,

Zia
From: Travis L. Bean [ date: 2003-12-26 ]
If anyone could shed some light on this problem I am experiencing, I would be very grateful: The fam_mirrord daemon fails to start when there are multiple directories under /home. A couple of directories and it starts just fine. I don't experience this problem when mirroring /var/www. It doesn't matter how many directories are created under /var/www; the daemon always starts just fine. This stall problem only happens when mirroring /home. I am using Fedora Linux Core 1.
From: Travis L. Bean [ date: 2003-12-27 ]
When I execute (DEBUG=1 INIT_MIRROR=1 CREATE_DIRS=1 /bin/fam_mirrord /home) I get debugging output and then it stalls at random. I haven't been able to track down what would be causing this stall problem. I also notice that when I am mirroring /var/www (fam_mirrord correctly reads the /var/www directory structure without stalling - unlike /home) if I create a directory structure, the directories mirrored on the replica host only go two levels deep (e.g. If I create a structure of pdc-srv/var/www/test/test2/test3, only the test directory and test2 subdirectory appear on the bdc-srv, but not the test3 subdirectory). So on the primary domain controller there would be /var/www/test/test2/test3, but the backup domain controller would only receive /var/www/test/test2. I have used a wide variety of rsync switches and none of them seem to make a difference on the results I am getting. I am currently using: ($rsync="rsync --archive --checksum --update --delete -e 'ssh -l root' ";).

One more thing I noticed about the fam_mirrord script. The only way I have been successful in getting directories to delete properly on the replica host (backup domain controller) is to edit line 178 ($cmd="$rsh $host 'rm $filepath'";) and change it to ($cmd="$rsh $host 'rm -rf $filepath'";).
From: manish <manishc(at)hitechexport.com> [ date: 2004-03-29 ]
We at Hi-Tech Export have simple 1-Linux Server(RedHat-9.0) running SAMBA server providing files to all windows and linux desktops. We are planning to setup other 2-Linux Server, How can we simply setup mirroring or anything such so that all of the 1-Linux Server (including system changes etc...) is mirrored to 2-Linux Server. We are not knowldgeable for this. Kindly help us out and thanks in advance.
Help would be appreciable.
From: Kelly Sidener <kelly.sidener(at)nexinnovations.com> [ date: 2004-04-30 ]
Atif, are you still monitoring this? If you are, have you resolved the large directories known problem? I have a need to implement this with a file system that has a directory with currently 18000 subdirectories. The administrator thinks he can get it down to 12000, and wants to go to more of a tree structure at some point in the future.

Please let me know.

Thanks, Kelly
From: Bikr <bikr(at)bikr.net> [ date: 2004-08-30 ]
Hey guys I'm having some trouble with this. It works flawlessly as far as mirroring the information , but whether I use the original script or the Daemon script , I get this:


"stdin: is not a tty"


Everytime I change a file I get that message times 2.
I have tried suppressing errors , piping to /dev/null etc. I just can't get it to work without those errors.

Let me know if you can think of anything.

--Josh
bikr@bikr.net
From: Johnny Bandwith <linuxfocus.org(at)icarus.hafnet.com> [ date: 2004-09-26 ]
I have fam_mirror working properly on my identical (and I mean Identical, except for the hostnames and IP addresses) RH9 boxes. It works nice, although I have to ru fam_mirror multiple times for multiple directories or else it gets a bit slow.
My problem can be reproduced:

# fam_mirror /tmp/
# mkdir /tmp/dir1
# mkdir /tmp/dir1/dir2
# mkdir /tmp/dir1/dir2/dir3

So far so good; everything within tmp, tmp/dir1 and tmp/dir1/dir2 is being mirrored. When you go deeper:

mkdir /tmp/dir1/dir2/dir3/dir4

fam_mirror doesn't mirror. It seems it can only look at directories three levels deep- no deeper. And that's where my problem lies: I have users creating directory trees deeper than three (who doesnt?)...

Any hints?

Kind regards,

rogier AT icarus DOT hafnet DOT com

From: Travis L. Bean <support(at)biologicaqua.com.nospam> [ date: 2004-11-09 ]
I posted back in 2003-12-27 in regard to what I consider to be a bug in this script. It does not replicate directories correctly and does not recurse deep enough to be useful for anything in a production environment (such as a Samba file server or Apache webserver). If anyone could shed some light on how to get this script parsing multiple directories correctly, it would be much appreciated.

Travis L. Bean
Systems Administrator
Bio-Logic Aqua Technologies
Grants Pass, OR - United States

From: peter koegel <pkoegel(at)azxws.com> [ date: 2005-10-30 ]
How about FAM and system load ? We get a lot collision on our switch (100 Mb/s). Do we need gigabit? FAM slows our system ~ 50 % down.
So what you recoment ssh ftp or nfs?
Any recommedation?
Peter



From: Keith Reynolds [ date: 2005-11-25 ]
The following patch fixes the deep directory problem, and properly handles removing directories.

--- fam_mirror 2005-11-25 08:51:57.000000000 -0800
+++ fam_mirror.new 2005-11-25 10:16:16.000000000 -0800
@@ -53,11 +53,15 @@ my $event;
#define the rsh command. This could be rsh, ssh or whatever
my $rsh="ssh -l root ";
#define the rsync command with the flags that you want
-my $rsync="rsync -rlopgztC --delete -e 'ssh -l root' ";
+my $rsync="rsync -rlopgztC --delete -e '$rsh'";

#define replica hosts separated by space
my @replicaHosts=qw(host1 host2 host3);

+#keep track of what we're monitoring; SGI::FAM doesn't give us enough info
+#when a tree is removed with rm -r.
+my %monitored;
+
#fill up the @directories list
my @directories;
find(sub { -d && -e && push @directories, $File::Find::name; }, @ARGV);
@@ -81,6 +85,7 @@ for (@directories){

print "setting monitor on $directory\n" if $ENV{'DEBUG'};
$fam->monitor(realpath($_));
+ $monitored{$_}=1;
}


@@ -104,53 +109,91 @@ if ($ENV{'INIT_MIRROR'}){

while (1) {
do {
+ my $isDirectory=0;
+ my $filepath;
+
$event=$fam->next_event;
$dir=$fam->which($event);
$file=$event->filename;
#dont copy swap files
next if $file=~/(\.swp|\~)$/;
if ($dir eq $file){
- $file="";
+ $filepath=$file;
+ } else {
+ #set correct filename. dir/file
+ $filepath="$dir/$file";
}

- #set correct filename. dir/file
- my $filepath="$dir/$file";

#remove multiple / from filepath
$filepath=~s/\/+/\//g;
-
+
#set dirname
$dirname=dirname($filepath);


+ if (-d $filepath)
+ {
+ $isDirectory=1;
+ }
+

# if there a change or create event then
# rsync the file to the replica hosts

if ($event->type =~/^(change|create)$/){
+ if ($isDirectory && $event->type eq "create")
+ {
+ #
+ # A new directory has been created;
+ # monitor it. There is a race condition
+ # here; new subdirectories might get
+ # created before we can install the
+ # monitor. So, monitor all existing
+ # subdirectories as well.
+ #
+ find(sub {
+ my $path=$File::Find::name;
+ if (-d _) {
+ print "setting monitor on $path\n" if $ENV{'DEBUG'};
+ $fam->monitor($path);
+ $monitored{$path}=1;
+ };
+ }, $filepath);
+ }
for my $host(@replicaHosts){
$cmd="$rsync $filepath $host:$dirname/";
print "$cmd\n" if $ENV{'DEBUG'};
- system ("$cmd 2>&1 >/dev/null");
+ system ("$cmd > /dev/null 2>&1");
}
}
-
+
# if the file or directory is deleted
# then delete it on the server too
# This needs some testing
- if ($event->type =~/^(delete)$/){
+ if ($event->type eq "delete"){
+ if
From: Fran CASSEL [ date: 2006-11-23 ]
HI,

I can install fam and SGI::FAM on debian successfuly but when I run the fam_mirror script I've the following error :

SGI::FAM: Address already in use at ./fam_mirror line 50

If someone can help me, thanks in advance.

38 talkbacks in English
Other talkbacks:   Castellano Francais




Due to the increased amount of web spam we have deciced to removed the talkback posting possibility. You can read old talkbacks but you can no longer post new ones.

Back to http://cgi.linuxfocus.org/English/March2001/article199.shtml

Please contact webmaster(at)linuxfocus.org if you have any questions with regards to this talkback

lftalkback version 3.10