2 Dec 2008

MogileFS - installation tutorial

MogileFS was originally created by Danga Interactive to be used by LiveJournal project.
It's goal was to provide the means of securely storing a huge number of files using 'cheap disks' on the network. This way it is possible to get low cost efficient storage that can grow with the project, without using proprietary on-disk file formats. The system requires a specific API to access the files and there are client implementations for several languages:

Perl - http://search.cpan.org/~bradfitz/MogileFS-Client/
Java - http://github.com/eml/java-mogilefs/tree/master
Ruby - http://seattlerb.rubyforge.org/mogilefs-client/
PHP - http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/MogileClient/
Python - http://www.albany.edu/~ja6447/mogilefs.py

Now for the installation.


Get the required modules from CPAN:

wget http://search.cpan.org/CPAN/authors/id/D/DO/DORMANDO/mogilefs-server-2.20.tar.gz
wget http://search.cpan.org/CPAN/authors/id/D/DO/DORMANDO/MogileFS-Utils-2.13.tar.gz
wget http://search.cpan.org/CPAN/authors/id/B/BR/BRADFITZ/MogileFS-Client-1.08.tar.gz
wget http://search.cpan.org/CPAN/authors/id/D/DO/DORMANDO/Perlbal-1.72.tar.gz
wget http://search.cpan.org/CPAN/authors/id/B/BR/BRADFITZ/Danga-Socket-1.61.tar.gz


Use CPAN to install required modules:livejournal
sudo cpan Sys::Syscall
sudo cpan BSD::Resource
sudo cpan Gearman::Client
sudo cpan -f Gearman::Client::Async ( use -f to force isntallation as tests fail )
sudo cpan Gearman::Server
sudo cpan Net::Netmask
sudo cpan IO::AIO


# The next dependency is only for MogileFS Client
sudo cpan IO::WrapTie




Unpack and install required modules:
tar xvzf Danga-Socket-1.61.tar.gz
cd Danga-Socket-1.61/
perl Makefile.PL
make
sudo make install
cd ..

tar xvzf Perlbal-1.72.tar.gz
cd Perlbal-1.72
perl Makefile.PL
make
sudo make install
cd ..


Unpack, compile and install mogilefs-server:
tar xvzf mogilefs-server-2.20.tar.gz
cd mogilefs-server-2.20/
perl Makefile.PL
make
sudo make install

Unpack, compile and install mogilefs-utils:
tar xvzf MogileFS-Utils-2.13.tar.gz
cd MogileFS-Utils-2.13/
perl Makefile.PL
make
sudo make install

Unpack, compile and install mogilefs-client (Optional):
tar xvzf MogileFS-Client-1.08.tar.gz
cd MogileFS-Client-1.08/
perl Makefile.PL
make
sudo make install


Create the configuration files:
sudo mkdir /etc/mogilefs
sudo vi /etc/mogilefs/mogilefsd.conf

# Configuration for MogileFS Daemon
db_dsn DBI:mysql:dbname=mogilefs:host=127.0.0.1
db_user mogile
db_pass sekrit
conf_port 6001
listener_jobs 5

sudo vi /etc/mogilefs/mogstored.conf

# Configuration for Storage Nodes
httplisten=0.0.0.0:7500
mgmtlisten=0.0.0.0:7501
# set the directory where the files will be stored
docroot=/var/mogdata

Create mogile user to run Mogile Tracker jobs
sudo adduser --shell /bin/false mogile


Setup the database:
mogdbsetup --dbrootuser=<root username> --dbrootpass=<password> --dbuser=mogile --dbpass=sekrit --dbname=mogilefs


Start the Storage node:
mogstored --daemon

Start the Tracker node as mogile user:
su mogile
mogilefsd -c /etc/mogilefs/mogilefsd.conf --daemon
exit


Let the tracker node know there is a storage node available
mogadm --lib=/usr/local/share/perl/5.8.4 --trackers=<tracker-node>:6001 host add <storage-node-name> --ip=<storage-node> --port=7500 --status=alive


Check the host is recognized:
mogadm --lib=/usr/local/share/perl/5.8.4 --trackers=<tracker-node>:6001 host list

Add a device to the storage node, where files will be kept:
mogadm --lib=/usr/local/share/perl/5.8.4 --trackers=<tracker-node>:6001 device add <storage-node-name> 1

Create a directory for device just created (dev1):
mkdir -p /var/mogdata/dev1

Check that the device information is listed:
mogadm --lib=/usr/local/share/perl/5.8.4 --trackers=<tracker-node>:6001 device list


Add domain to store files:
mogadm --lib=/usr/local/share/perl/5.8.4 --trackers=<tracker-node>:6001 domain add


List the domains:
mogadm --lib=/usr/local/share/perl/5.8.4 --trackers=<tracker-node>:6001 domain list


Add a class to the previous file domain:
mogadm --lib=/usr/local/share/perl/5.8.4 --trackers=<tracker-node>:6001 class add


List the classes:
mogadm --lib=/usr/local/share/perl/5.8.4 --trackers=<tracker-node>:6001 class list

No comments: