Posted by tobi — 01:09 PM Dec 31
After successfully installing thrift there are still a string of dependencies needed before you can install ThruDB.
Thanks in no small part to Jake Luciani for helping me with finding the dependencies.
MacPorts
First we need several packages from the macports. You may want to run sudo port selfupdate to get the latest versions of those packages.
sudo port install boost clucene libevent memcached ossp-uuid
I hit a weird compile error on boost. I fixed it by running sudo port clean boost and simply re-running the port install command. Same problem on both my machines.
Manual dependencies
Like mentioned above, we need facebook’s thrift. We will their public SVN version because this fixes a bug which makes compiling on OSX easier.
svn co http://svn.facebook.com/svnroot/thrift/trunk/ thrift cd thrift; ./bootstrap.sh ./configure --with-boost=/opt/local --with-libevent=/opt/local --prefix=/opt/local sudo make install
Don’t forget to install the thrift ruby libraries:
cd thrift/lib/rb ruby setup.rb
Next we need spread. Spread is a message bus which works much like you imagine a network of IRC server to work. ThruDB uses it for replication and two-phase commits amongst other things. Its a remarkable piece of software which should find its way in most server farms, regardless of ThruDB’s use or not. Once common usecase is to broadcast server logs to spread. This allows you to write a simple client which just listens to the messages and calculates user statistics, traffic and so on. Its also great for replication and keeping multiple systems in sync, such as a search server and the main database.
Unfortunately the spread team decided that everyone who wants to install it has to fill out a quick form so you will have to manually download it from http://www.spread.org/download/spread-src-4.0.0.tar.gz.
tar zxf spread-src-4.0.0 ./configure --prefix=/opt/local make sudo make install
ThruDB makes heavy usage of memcached, therefore it uses the up-and-coming c library by Brian Aker which is quickly establishing itself as the defacto standard client implementation due to its speed and use of Consistent Hashing. I actually wrote a ruby extension for this client library with some very encouraging performance metrics. I hope to release this soon.
curl http://download.tangent.org/libmemcached-0.12.tar.gz > libmemcached-0.12.tar.gz tar zxf libmemcached-0.12.tar.gz cd libmemcached-0.12 ./configure --prefix=/opt/local sudo make install
Lastly there is log4cxx to be installed. This is a pretty heavy library because of its use of apache apr. Jake said that he may dump it in an upcoming release to make the dependencies of ThruDB a bit more sane.
svn checkout http://svn.apache.org/repos/asf/logging/log4cxx/trunk apache-log4cxx cd apache-log4cxx ./autogen.sh ./configure --prefix=/opt/local sudo make install
Compiling ThruDB
svn co http://thrudb.googlecode.com/svn/trunk thrudb cd thrudb; ./autogen.sh env LDFLAGS="-L/opt/local/lib" CPPFLAGS="-I/opt/local/lib -I/opt/local/include -I/opt/local/include/thrift" ./configure --prefix=/opt/local sudo make install
If the compile fails with a missing thriftnb library than you didn’t compile thrift with—with-libevent=/opt/local . Just do that again, we’ll wait.
ThruDB & ruby.
# Run memcached server memcached -d # Setup lib shenanigans export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/local/lib/ #run thrudb tutorials cd tutorial # create the ruby client for the bookmarks.thrift service make # start thrudb ./thrudbctl start # run the tutorial cd rb; ruby BookmarkExample.rb # Profit! (to quote Jake)

Frederico 31 Dec 16:47
to build Boost on OSX leopard using macports make sure you do ”$sudo port sync”
there was a bug preventing Boost to build, which is fixed few days ago.
Alex Payne 31 Dec 17:05
Minor change: you need to ./autogen.sh before you can configure the build for apache-log4cxx.
Thanks for taking the time to document your steps!
tobi 31 Dec 17:20
Thanks alex,
i updated the article
Frederico 31 Dec 17:38
I Gentoo linux some steps are made easier :)
Frederico 31 Dec 17:40
and also these, of course.Mr eel 04 Jan 05:59
It appears that the steps for installing Thrift have changed slightly.
I had to use:
./bootstrap.sh ./configure --with-boost=/opt/local --with-libevent=/opt/local --prefix=/opt/local sudo make installtobi 06 Jan 16:46
Thanks, i corrected the article.
Sebastian 09 Jan 11:23
I was getting this error: BookmarkExample.rb:8:in `require’: no such file to load—Thrudoc (LoadError)
when trying to run BookmarkExample.rb
So I had to “cd clients/rb && make && sudo ruby setup.rb” inside the thrudb sources.
It looks like “make install” on thrudb does not include the clients?
Sebastian 09 Jan 11:25
Also, to run the tutorial example I had to “cd tutorial && make && cd gen-rb && ruby ../rb/BookmarkExample.rb”
brainopia 16 Jan 08:59
It will be so much easier if somebody makes thrift and thrudb work via macports.
jacqui 16 Jan 16:26
Btw, you have to run make before make install when installing spread.
So the instructions should read:
tar zxf spread-src-4.0.0 ./configure—prefix=/opt/local make sudo make install
I can’t tell you how many people got stuck on this, myself included. It’s one of those things that’s almost too obvious :) You might want to update your article.
tobi 20 Jan 11:49
Thanks! I updated the article for the 15th time.