Skip to main content

MogileFS with Postgres

First of all, you need Postgres version 8.2 or newer since mogdbsetup refuses to run with older versions.

Anyways, I spent a quite a bit of time trying to install MogileFS with Postgres. I was getting "Can't create temporary test database:" errors. The answer was in the ~/.cpan/build/mogilefs-server-2.34/blib/lib/MogileFS/Test.pm file. The temp_store subroutine was defaulting to MySQL...

Here is the setup step by step on my Fedora 12:

yum install mogilefsd
yum install mogstored
yum install perl-CPAN // if needed
yum install perl-MogileFS-Client perl-MogileFS-Utils
yum install perl-DBD-Pg
yum install perl-IO-AIO


Setup services.

chkconfig --levels 345 mogilefsd on
chkconfig --levels 345 mogstored on


Setup a test database to be used during compilation.

$ createuser -SRlD mogile
$ createdb -E UTF8 -O mogile tmp_mogiletest


Setup environment variables for testing

$ MOGTEST_DBUSER=mogile
$ MOGTEST_DBHOST=dbhost
$ MOGTEST_DBNAME=tmp_mogiletest
$ MOGTEST_DBTYPE=Postgres
$ export MOGTEST_DBUSER MOGTEST_DBNAME MOGTEST_DBTYPE MOGTEST_DBHOST


Download and install MogileFS::Store::Postgres from CPAN. (This is going to download the whole mogilefs-server package)

$ cpan
cpan> install MogileFS::Store::Postgres


Setup database

template1=# create user mogilefs with encrypted password 'password';
template1=# create database mogilefs with owner=mogilefs encoding='UNICODE';


Run mogdbsetup

mogdbsetup --type=Postgres --dbhost=localhost --dbname=mogilefs --dbuser=mogilefs --dbpass=password


Setup config


db_dsn DBI:Pg:dbname=mogilefs;host=mogilefs-db
db_user mogilefs
db_pass password
conf_port 6001
listener_jobs 5


Start tracker
service mogilefsd start


Update mogstored.conf
httplisten=0.0.0.0:7500
mgmtlisten=0.0.0.0:7501
docroot=/var/mogdata


Define hosts and devices

mogadm host add mogilestorage-1 --ip=127.0.0.1 --port=7500 --status alive
mogadm host list
mogadm device add mogilestorage-1 1
mogadm device add mogilestorage-1 2
mkdir /var/mogdata/dev1
mkdir /var/mogdata/dev2
chown mogstored:mogstored /var/mogdata/dev1/
chown mogstored:mogstored /var/mogdata/dev2/
service mogstored start


Define domains and classes

mogadm domain add domain1
mogadm class add domain1 class1 --mindevcount=2


And don't forget to clean up the test user and database.

Comments

Popular posts from this blog

Securing Symfony2 REST services with FOSOAuthServerBundle

Overview In my previous article, I wrote about setting up a Symfony2 REST service using FOSRestBundle. However, this REST service was behind a firewall protected by a generic form_login provider. Not really ideal if you wish to open your REST API to other applications. So in this article, I will try to explain how to set up FOSOAuthServerBundle to protect your REST API methods using OAuth2. Before we start getting into the gritty details, it is a good idea to have a look at the official OAuth2 documentation . Let's begin... FOSOAuthServerBundle Installation You have to install v1.1.0 of FOSOAuthServerBundle if you are using Symfony 2.0.x. If not, see the docs . First, add the following entries to your deps file: [FOSOAuthServerBundle] git=git://github.com/FriendsOfSymfony/FOSOAuthServerBundle.git target=bundles/FOS/OAuthServerBundle version=origin/1.1.x [oauth2-php] git=git://github.com/FriendsOfSymfony/oauth2-php.git Run the vendors script to install these...

Unexpected token "name" of value "if" ("end of statement block" expected) in "WebProfilerBundle:Collector:logger.html.twig"

Encountered this WebProfilerBundle error message when I ran the bin/vendors script to update my Symfony2 bundles. Make sure your deps file is up to date; you need to pay special attention to your version values. In this case, update your twig version to v1.2.0 as illustrated below: [twig] git=http://github.com/fabpot/Twig.git version=v1.2.0 Run the vendors script to update your bundle and the error message should disappear. You can get the most up to date deps file from the symfony-standard repository located at: https://github.com/symfony/symfony-standard/blob/master/deps

Setting up a Symfony2 REST service with FOSRestBundle

Installation First thing is to download and setup the FOSRestBundle. If you are running Symfony 2.0.x, get the FOSRestBundle version 0.6, otherwise, download the code in the master branch. The FOSRestBundle depends on the JMSSerializerBundle so the following instructions are going to include some extra information for setting up this bundle to complete our REST service. First thing is to install our dependencies. Add the following to your deps file: [metadata] git=http://github.com/schmittjoh/metadata.git version=1.1.0 [JMSSerializerBundle] git=git://github.com/schmittjoh/JMSSerializerBundle.git target=bundles/JMS/SerializerBundle [FOSRest] git=git://github.com/FriendsOfSymfony/FOSRest.git target=fos/FOS/Rest [FOSRestBundle] git=git://github.com/FriendsOfSymfony/FOSRestBundle.git target=bundles/FOS/RestBundle version=origin/0.6 Run the vendors script to install these bundles: php bin/vendors install Next, update your app/autoload.php file...