Skip to Content Skip to Search Go to Top Navigation Go to Side Menu


"Software" Category


Networking in Debian 4.0 (Etch) VMWare images


Sunday, April 19, 2009

Recently I’ve come across a couple of vmware images of Debian Linux 4.0 (Etch) where the network didn’t work. A call to ifconfig didn’t show ‘eth0′ at all.

I’ve tried to compare the configuration difference between a successully running Debian Linux 5.0 (Lenny) and these Etch image without success.

I found the solution by chance on a vmware image vendor’s web site:

rm /etc/udev/rules.d/z25_persistent-net.rules && reboot

Git


Friday, October 17, 2008

I’ve been kind of working on a git tutorial for a while now.
I’ve recently realized that there are two different work flows ( git+subversion  and github.com) that I use regularly and that trying to describe them both in one tutorial made it quite confusing.

I’m going to remake them in two tutorials instead of one. In the meantime here’s the content of my bash profile with the elements I use to smooth my daily experience of git:

#### start Git #####
alias g='git'
alias gco='git checkout'
alias gma='git checkout master'
alias gst='git status'
alias glo='git log'
alias gca='git commit -a'
alias gsd='git svn dcommit'
alias gcav='git commit -v -a'
alias squash='git merge --squash'
alias gpatch='git format-patch'
alias saw='git branch -D'
alias rollback='git reset --hard git-svn'
alias uncommit='git reset --mixed HEAD'
alias fixlastcommit='git commit --amend'
alias branches='git branch -a'
alias grow='git checkout -b'
alias plant='git svn init'
alias gclone='git clone'
alias hide='git stash'
alias unhide='git stash apply'

export PS1='\w $(git branch &>/dev/null; if [ $? -eq 0 ]; then \
echo "(\[\033[00m\]$(git branch | grep ^*|sed s/\*\ //)) "; fi)\$\[\033[00m\] '

#### end Git #####

Testing flash.now with rspec


Friday, September 26, 2008

I’ve spent a couple of hour trying to test a Rails controller. More specifically one of the action is suppose to display flash.now notice and I want to test that and it works. It took me awhile and some googling to realise that the content of a flash.now is deleted after the action, so that you cannot test it the same way as a normal flash (that last for the duration of the current action and the next one).

I came an across an elegant solution  to this problem as decribed on this blog.

Setting up high availability storage with MogileFS


Thursday, July 3, 2008

1. Environment

I used 4 Xen virtual images running ubuntu 8.04.
Two will run a tracker and the database, the other two will be the storage nodes.

Lets say the IP addresses will be:


192.168.0.195
192.168.0.196
192.168.0.197
192.168.0.198

2. Initial Setup

Install iptables:


apt-get install iptables

then apply initial setup


iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -j DROP
iptables-save -c > /etc/iptables.rules

you can save the rule for beyond machine reboot by adding the two lines below to /etc/network/interfaces

pre-up iptables-restore < /etc/iptables.rules
post-down iptables-save -c > /etc/iptables.rules

install mysql and wget and perldoc


apt-get install mysql-server
apt-get install wget
apt-get install perl-doc
apt-get install libio-aio-perl
apt-get install subversion
apt-get install build-essential

3. Common steps for installing MogileFS

retrieve the code (ripped of the how to wiki):


cd /usr/local/src
mkdir mogilefs-src
cd mogilefs-src
svn checkout http://code.sixapart.com/svn/mogilefs/trunk

install perl dependencies


cpan Danga::Socket
cpan Gearman::Client
cpan Gearman::Server
cpan Gearman::Client::Async
cpan Net::Netmask
cpan Perlbal
cpan IO::WrapTie

install the servers:


cd mogilefs-src/trunk/server
perl Makefile.PL
make
make test
make install

At the moment the test seems to need mysql to be installed and user root without password, so some tests are skipped

you will need to install MogileFS::Client
(the tests expect a tracker to run locally on port 7001)


cd mogilefs-src/trunk/api/perl/MogileFS-Client
perl Makefile.PL
make
make test
make install

and some admin tools:


cd mogilefs-src/trunk/utils
perl Makefile.PL
make
make test
make install

4. Tracker install

create the database:


mysql -uroot -p
mysql> CREATE DATABASE mogilefs;
mysql> GRANT ALL ON mogilefs.* TO 'mogile'@'%';
mysql> SET PASSWORD FOR 'mogile'@'%' = OLD_PASSWORD( 'sekrit' );
mysql> FLUSH PRIVILEGES;
mysql> quit

Create the schema


./mogdbsetup --dbname=mogilefs --dbuser=mogile --dbpassword=sekrit

(admin privilege is required for the initial setup, so if you’re admin user is not root with no password, you will need to specify –dbroopassword and –dbrootuser)

create /etc/mogilefs/mogilefsd.conf:


db_dsn DBI:mysql:mogilefs
db_user mogile
db_pass ******
conf_port 7001
listener_jobs 5

create a mogile user:


adduser mogile

and starts the tracker under that user:


su - mogile
mogilefsd

open a port for the tracker


iptables -A INPUT -p tcp --dport 7001 -j ACCEPT

5. Storage node

On the storage server, create a configuration file at /etc/mogilefs/mogstored.conf with the following:


httplisten=0.0.0.0:7500
mgmtlisten=0.0.0.0:7501
docroot=/var/mogdata

open a port:


iptables -A INPUT -p tcp --dport 7500 -j ACCEPT

iptables -A INPUT -p tcp --dport 7501 -j ACCEPT

register a new storage node:


mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001 host add mogilestorage --ip=192.168.0.197 --port=7500 --status=alive

it should now appears in the list:


mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001 host list

Add a device to the storage:


mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001 device add mogilestorage 1

and create the directory:


mkdir -p /var/mogdata/dev1

make sure /var/mogdata/* is owned by mogile:mogile


chown -R mogile:mogile /var/mogdata/*

6. Starting the storage server

as root:

mogstored --daemon

7. Starting the tracker


su - mogile
mogilefsd -c /etc/mogilefs/mogilefsd.conf --daemon
exit

8. Testing

check that mogilefs components are online:


mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001 check

Quick sanity check of the storage daemon:


~/Projects/mogilefs $ telnet 192.168.0.197 7500
Trying 192.168.0.197...
Connected to 192.168.0.197.
Escape character is '^]'.
PUT /dev1/test HTTP/1.0
Content-length: 4
\n
test
HTTP/1.0 200 OK
Content-Type: text/html
Content-Length: 18
Server: Perlbal
Connection: close
200 - OK
Connection closed by foreign host.

create a domain


mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001 domain add mydomain

and a class


mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001 class add mydomain images

Quick sanity check of the tracker:


root@bbc-01:~# mogtool --trackers=127.0.0.1:7001 --domain=mydomain --class=images inject osname osname

on the store node, check /var/mogdata/dev1/0/000/000 for a file named xxxxxxxxxx.fid .
If the file exists it’s all good.

9. setting up the second pair

Replay instructions 1 to 8, then:

when you’ve got the second storage set up, you will need to register the second storage and its device to all trackers:


mkdir -p /var/mogdata/dev2
mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001 host add mogilestorage2 --ip=192.168.0.198 --port=7500 --status=alive
mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001 device add mogilestorage2 2
mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.196:7001 host add mogilestorage2 --ip=192.168.0.198 --port=7500 --status=alive
mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.196:7001 device add mogilestorage2 2

you will also need to register the first storage and its device to the second tracker:


mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.196:7001 host add mogilestorage --ip=192.168.0.197 --port=7500 --status=alive
mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.196:7001 device add mogilestorage 1

sanity check the installation:


mogadm --lib=/usr/local/share/perl/5.8.8 --trackers=192.168.0.195:7001,192.168.0.196:7001 check

Checking trackers…
192.168.0.195:7001 … OK
192.168.0.196:7001 … OK

Checking hosts…
[ 1] mogilestorage2 … OK
[ 2] mogilestorage … OK

Checking devices…
host device size(G) used(G) free(G) use% ob state I/O%
—- ———— ———- ———- ———- —— ———- —–
[ 1] dev2 9.921 0.757 9.164 7.63% writeable 0.0
[ 2] dev1 9.921 0.600 9.321 6.05% writeable 0.0
—- ———— ———- ———- ———- ——
total: 19.842 1.357 18.485 6.84%

And voila.

Ruby on Rails with_scope and returning


Thursday, June 19, 2008

This week in my current project I’ve come across two ruby constructs that were new to me.

with_scope and returning.

Found a blog where they are both nicely explained:

Microformats and Safari


Wednesday, March 19, 2008

Firefox users have been able to use microformats-enabled web sites (like the schedules on Upcoming or BBC Programmes) for a long time thanks to a couple of extensions (Operator and Tails Exports).

Now coming alongside the release of Safari 3.1, there’s a new Safari plugin that allow the parsing of microformats for integration in various Mac OS X applications (Adress book, iCal).

For Mac OSX users, the integration with Address Book and iCal could make Safari a better microformat reader than Firefox. I cannot test the plugin myself as I don’t have Leopard which is a requirement.

Alternatively the latest version of my feed reader NetNewsWire can also parse microformats but it requires you (obviously by the very definition of microformats) to render the web page in Netnewswire not just the summary.

Safari 3.1 is available for Tiger and Windows though.

Your Company’s App


Sunday, March 16, 2008

A funny but familiar comic strip :-)

Your Company’s App: “Company’s”

(Via Daring Fireball.)

Proposed solution for Microsoft’s browser issues and illustrative pie chart


Wednesday, February 20, 2008

I’ve started to miss making blog posts with fancy diagramme, mind-blowing pie charts.

The Open letter from Opera’s CTO published in The Register has given me the opportunity to drawn this blog under the total wisdom of yet another pie chart as buried in the comments to the article, I found this:

it's funny

You’ll notice it’s in the same vein as that one from last year :-D

When subversion is not good enough


Monday, February 18, 2008

I hate subversion right now.

For reasons outside my control I have to keep development branches open for a long time and therefore I need to sync them regularly with trunk and these merge operations are quite annoying and source of headaches.

Additionally, in the recent months I found myself coding disconnected from a network more often than before and I wished I could commit my changes locally and sync them when back online.

Some perl developers around me have played with SVK in the past, and at the end of last year I came across a blog post reviewing several Distributed Version Control System (DVCS).

And Let’s not forget DARCS.

I’ll play with a couple of these, but my choice may be simpler as two developers in my team have already started using Git with the git-svn hook between themselves.

Ruby On Rails tips


Saturday, February 16, 2008

Recently, I’ve been working on a Rails project for the first time.
It’s a nice change after years of perl.

There are quite a few little things that I knew how to do in perl, that I didn’t have clue on how to do it in Rails. Also I run into issue peculiar to Rails or ruby.

I solved all these issues so far and the links below give pointers to some helpful information.