mogadm (admin console tool)

Justin Azoff JAzoff at uamail.albany.edu
Tue Aug 9 11:46:40 PDT 2005


On Tue, 2005-08-09 at 11:33 -0700, Mark Smith wrote:
> I'll be working on a MogileFS command line administration program over the
> next week or two.  Some of the things we've already slated for this program
> to handle:
> 
> * adding/configuring hosts, devices, namespaces, classes
> * marking hosts/devices up, temp_down, dead, etc
> * checking the status of all devices (mogcheck)
> * checking the status of the system overall (replication, deletion, ...)
> * upgrading the MogileFS database as necessary
> * installing and configuring fresh MogileFS database
> 
> Is there anything missing from that list that you wish you could do more
> easily with MogileFS?  Any database tweaks you find yourself doing that you
> wish you didn't have to do manually?
> 
> Any thoughts and ideas are welcome!
> 
> 
> --
> Junior (aka Mark Smith)
> junior at danga.com
> 
> Software Engineer
> Six Apart / Danga Interactive

Not sure if "Checking the filesytem" falls under any of those...   When
I was doing a lot of testing I would end up with orphaned files.. I
wrote up this script to find them..

#!/usr/bin/perl
use DBI;
use DBD::mysql;
use File::Find;
use strict;
#use warnings;

my $dbh = DBI->connect('DBI:mysql:mogilefs:tracker', 'user', 'pass') or die "can't connect";

my $fidhash = {};

my $fids = $dbh->selectall_arrayref("SELECT fid FROM tempfile UNION SELECT fid FROM file UNION SELECT fid FROM file_to_delete")
    or die "Invalid query";

foreach my $fida (@$fids) {
    my ($fid) = @$fida;
    $fidhash->{$fid} = 1;
}

my $len = scalar keys %$fidhash;
die("Length only $len, not > 100, possbile db error?") unless $len > 100;

sub wanted {
    return unless $_ =~ /fid$/;
    my ($name, $ext) = split(/\./, $_);
    $name += 0;
    print "$File::Find::name\n" unless exists $fidhash->{$name};
}

find(\&wanted, ("/var/mogdata", "/srv/mogdata")) ;

It just prints them, I would usually check the output and then pipe to xargs rm.

For a db with millions of files reading the list of every fid into
memory may not work so well.. could probably optimize it a bit to only
SELECT fids that are supposed to be on that host to begin with.


-- 
-- Justin Azoff
-- Network Performance Analyst



More information about the mogilefs mailing list