Seven Databases in Seven Days – Riak
In this post I am summarizing the three days of Riak, which is the second database in the Seven Databases in Seven Days book. This post is actually in order for me to remember some tweaks I had to do while reading this chapter as sometimes the book wasn’t entirely correct.
A good blog, which I used a little, can be found at: http://blog.wakatta.jp/blog/2011/12/09/seven-databases-in-seven-weeks-riak-day-3/ (this link directs to the 3rd Riak’s day)
I have everything pushed to GitHub as raw material: https://github.com/eyalgo/seven-dbs-in-seven-weeks
Installing
The book recommends to install using the source code itself. I needed to install Erlang as well.
Besides the information in the book, the following link was mostly helpful: http://docs.basho.com/riak/latest/ops/building/installing/from-source/
I installed everything under /usr/local/riak/
.
Start / Stop / Restart
A nice command line to start/stop/restart all the servers:
# under /usr/local/riak/riak-1.4.8/dev for node in `ls`; do $node/bin/riak start; done # change start to restart or stop
Port
The port which was installed in my machine was: 10018 for dev1, 10028 for dev2 etc. The port is located in app.config file, under the etc folder.
Day 3 Issues
Pre-commit
I kept getting PUT aborted by pre-commit hook message instead of the one described in the book. I had to add the language (javascript) to the operation:
curl -i -X PUT http://localhost:10018/riak/animals -H "content-type: application/json" -d '{"props":{"precommit":[{"name":"good_score","language":"javascript"}]}}'
(see: http://blog.sacaluta.com/2012/07/riak-precommit-hook-example.html)
Running a solr query
Running the suggested query from the book ( curl http://localhost:10018/solr/animals/select?wt=json&q=nickname:rin%20breed:shepherd&q.op=and)
kept returning 400 – Bad Request. All I needed to do was to surround the URL with: ‘ (apostrophe).
Inverted Index
Running the link as mentioned in the book gives bad response:
Invalid link walk query submitted. Valid link walk query format is: ...
The correct way, as described in http://docs.basho.com/riak/latest/dev/using/2i/
curl http://localhost:10018/buckets/animals/index/mascot_bin/butler
Conclusion
Riak chapter gives a taste of this database. It explains more about the “tooling” of it rather than the application of it. I feel that it didn’t explain too much on why someone would use it instead of something else (let’s wait for Redis).
The book had errors in how to run commands. I had to find by myself how to fix these problems. Perhaps it’s because I’m reading eBook (PDF on my computer and mobi on my Kindle), and the hard-copy has less issues. The good part of this problem, is that I had to drill down and read more online and learn more from those mistakes.
Reference: | Seven Databases in Seven Days – Riak from our JCG partner Eyal Golan at the Learning and Improving as a Craftsman Developer blog. |