mogilefs. installation and configuration |
Sep 3 |
MogileFS is open source distributed filesystem. Its properties and features include:
- Application level — no special kernel modules required.
- No single point of failure — all three components of a MogileFS setup (storage nodes, trackers, and the tracker’s database(s)) can be run on multiple machines, so there’s no single point of failure. (you can run trackers on the same machines as storage nodes, too, so you don’t need 4 machines…) A minimum of 2 machines is recommended.
- Automatic file replication — files, based on their “class”, are automatically replicated between enough different storage nodes as to satisfy the minimum replica count as requested by their class. For instance, for a photo hosting site you can make original JPEGs have a minimum replica count of 3, but thumbnails and scaled versions only have a replica count of 1 or 2. If you lose the only copy of a thumbnail, the application can just rebuild it. In this way, MogileFS (without RAID) can save money on disks that would otherwise be storing multiple copies of data unnecessarily.
- “Better than RAID” — in a non-SAN RAID setup, the disks are redundant, but the host isn’t. If you lose the entire machine, the files are inaccessible. MogileFS replicates the files between devices which are on different hosts, so files are always available.
- Flat Namespace — Files are identified by named keys in a flat, global namespace. You can create as many namespaces as you’d like, so multiple applications with potentially conflicting keys can run on the same MogileFS installation.
- Shared-Nothing — MogileFS doesn’t depend on a pricey SAN with shared disks. Every machine maintains its own local disks.
- No RAID required — Local disks on MogileFS storage nodes can be in a RAID, or not. It’s cheaper not to, as RAID doesn’t buy you any safety that MogileFS doesn’t already provide.
- Local filesystem agnostic — Local disks on MogileFS storage nodes can be formatted with your filesystem of choice (ext3, XFS, etc..). MogileFS does its own internal directory hashing so it doesn’t hit filesystem limits such as “max files per directory” or “max directories per directory”. Use what you’re comfortable with.
installation and configuration:
- svn checkout http://code.sixapart.com/svn/mogilefs/trunk/
дальше ставим trunk/server по шагам:$ make Makefile.PL $ make $ make test $ make install
на шаге “make test” может оказаться, что не хватает перловских модулей. берем CPAN и ставим все, что нужно. CPAN в виде интерактивной оболочки запускаем как
$ sudo perl -MCPAN -e shell
- делаем схему в базе данных, делаем отдельного юзверя mogile, даем ему полные права на базу. Все необходимые таблицы сделает mogdbsetup с параметрами хоста, базы, пользователя, пароля в коммандной строке.
- для запуска tracker-серверов и storage-серверов сделаем пользователя mogile
- настраиваем конфиги tracker-серверов и storage-серверов: /etc/mogilefs/mogilefsd.conf и /etc/mogilefs/mogstored.conf на соответствующих серверах (на каждом storage- и tracker- сервере запускается по демону, которому нужен конфиг)
$ cat /etc/mogilefs/mogilefsd.conf #daemonize = 1 db_dsn = DBI:mysql:mogilefs:host=DBhost.host.com db_user = mogile db_pass = mogile listen = 0.0.0.0:7001 conf_port = 7001 listener_jobs = 5 delete_jobs = 1 replicate_jobs = 5 mog_root = /mnt/mogilefs reaper_jobs = 1
$ cat /etc/mogilefs/mogstored.conf httplisten=0.0.0.0:7500 docroot=/var/mogdata mgmtlisten=0.0.0.0:7501
нужно сделать /var/mogdata где и будет хранится контент FS
- запускаем tracker-сервера (нужны для запуска и конфигурирования storage-серверов) как
# su mogile $ mogilefsd -c /etc/mogilefs/mogilefsd.conf --daemon $ exit
- конфигурим хранилища:
$ mogadm --lib=/usr/local/share/perl5/5.8.5 --trackers=trackerhost.host.com:7001 host add mogilestorageN --ip=STORAGEIP --port=7500 --status=alive
где mogilestorageN - имя хранилища (любое), STORAGEIP - ip-шник хранилища. trackers-хосты с портами можно перечислять через запятую.
проверить факт добаления можно так:
$ mogadm --lib=/usr/local/share/perl5/5.8.5 --trackers=trackerhost.host.com:7001 host list
теперь нужно добавить devices (папки, в которых будет хранится контент)
$ mogadm --lib=/usr/local/share/perl5/5.8.5 --trackers=trackerhost.host.com:7001 device add mogilestorageN Y
где mogilestorageN - хранилище, на котором создаем device, YY - порядковый номер device-а.
Device-ы создаются с именами dev1, dev2, dev3 … (в лучших традициях
) и олицетворяют папки /var/mogdata/devNсписок девайсов смотрим так:
$ mogadm --lib=/usr/local/share/perl5/5.8.5 --trackers=trackerhost.host.com:7001 device list
и стартуем хранилища:
$ su mogile $ mogstored --daemon
- окончательная проверка:
$ mogadm --lib=/usr/local/share/perl5/5.8.5 --trackers=trackerhost1.host.com:7001,trackerhost2.host.com:7001 check Checking trackers... trackerhost1.host.com:7001 ... OK trackerhost2.host.com:7001 ... OK Checking hosts... [ 1] mogilestorage ... OK [ 2] mogilestorage2 ... OK Checking devices... host device size(G) used(G) free(G) use% ob state I/O% ---- ------------ ---------- ---------- ---------- ------ ---------- ----- [ 1] dev1 6.736 2.942 3.794 43.68% writeable 0.0 [ 2] dev2 6.736 5.242 1.494 77.82% writeable 0.0 ---- ------------ ---------- ---------- ---------- ------ total: 13.473 8.185 5.288 60.75%Не доверяя автоматическим тестам можем проверить работу хранилищ вручную:
$ telnet storagehost.host.com 7500 Trying 10.10.10.10... Connected to storagehost.host.com (10.10.10.10). Escape character is '^]'. PUT /dev1/test HTTP/1.0 Content-length: 4 test HTTP/1.0 200 OK Content-Type: text/html Content-Length: 18 Server: Perlbal Connection: close <h1>200 - OK</h1> Connection closed by foreign host. $
и смотрим, сохранились ли данные:
$ ll /var/mogdata/dev1/ total 324 -rw-r--r-- 1 mogile mogile 4 Sep 5 02:33 test drwxr-xr-x 2 mogile mogile 319488 Sep 5 02:30 test-write -rw-rw-rw- 1 mogile mogile 140 Sep 5 02:33 usage
папка test есть - все ok.
пара слов, чтобы утрясти в памяти и оставить steps-list на будущее.
поиск и борьба с java клиентом к этому цирку - в следующей серии
стей ин тач

