Showing posts with label riak. Show all posts
Showing posts with label riak. Show all posts

Sunday, December 27, 2009

How I made the SlideBlast work on my Ubuntu server

We want to start with the clean Ubuntu server to test and then run the SlideBlast, created by Rusty Klophaus.
Yes, there is the SlideBlast.com, but we need to have an instance "at home".
So, let us do it!

We will need the Git,Mercurial to get the codes, and GhostScript and ImageMagick for the SlideBlast. The first lines are needed for Erlang.

sudo apt-get update
sudo apt-get install libssl-dev libncurses-dev build-essential m4 
sudo apt-get install git-core
sudo apt-get install mercurial
sudo apt-get install ghostscript
sudo apt-get install imagemagick
mkdir ~/src
cd src
Riak needs Erlang at least of version 5.7.4, so we need to compile it from the source:
wget http://erlang.org/download/otp_src_R13B03.tar.gz
tar zxf otp_src_R13B03.tar.gz 
cd otp_src_R13B03/
./configure 
make
sudo make install
cd ..
As of today, the SlideBlast does not work with Riak 0.7 - we need to roll it back a bit.
Let us take the last SlideBlast (with Nitrogen) and the label "riak-0.6" of Riak:
git clone git://github.com/rklophaus/SlideBlast.git
cd SlideBlast/deps
hg clone http://bitbucket.org/basho/riak
hg update -r riak-0.6
cd ../..
make
./start.sh
Now we would be ready to point your browser to http://localhost:8000 and start working.
Hey! What browser? We have Ubuntu Server, running as a virtual guest. Let us make the app visible: edit the SlideBlast/src/caster_mochiweb_app.erl to look like:
...
%%%Options = [{ip, "127.0.0.1"}, {port, 8000}],  %%% Just this one line to update
   Options = [{ip, "0.0.0.0"}, {port, 8000}],
...
Now we will re-compile it and try it from the host using the proper IP.
make 
./start.sh
From the outer box, we will try it as in our case, http://192.168.1.115:8000.
And it worked!
Your IP address of course will be different.

Word of advice for users: best works on FF, Safari. Chrome and IE show minor glitches, but work too. Best viewed slides have big fonts and little text. The client browser better be open full screen and "f" key is used to use all available browser window space.

Enjoy!

Tuesday, October 13, 2009

Riak on my Ubuntu


[EDIT] The situation with README being out of sync is already fixed. That was fast! Actually after all fixes in README the only bump on the road is to install a correct Erlang version. After that, clone, make, edit config/riak-demo.erlenv and start go very smoothly. Please disregard all "fighting" an "lying" below. It was actual just for me.[EDIT]

I wanted to install and launch Riak on my Ubuntu 9.04.
It did not work out first: my conveniently apt-get-installed Erlang 5.6.4 happened to be incompatible with Riak, so I needed the latest Erlang.

There is also a minor README issue, which is easily remediated below. I hope by the time you will read this that one will be fixed. But the routine I found works with current version OK anyway.

So, the terribly convenient packager sudo apt-get install erlang does not yet install the newer Erlang 5.7.3, so I had to compile the latest otp_src_R13B02-1.tar.gz myself.

Here is the sequence which led me to success:

0. sudo apt-get remove erlang
>> that depends on your installation. In my case I also needed
>> 0.1 sudo apt-get clean
>> 0.2 sudo apt-get remove erlang-base
-------------------------------------------------------------------
1. sudo apt-get install build-essential libncurses5-dev m4
2. sudo apt-get install openssl libssl-dev
3. tar -zxf otp_src_R13B02-1.tar.gz
4. cd otp_src_R13B02-1
5. ./configure
6. make
7. sudo make install

Now if you are lucky, you have the right version of Erlang:
serge@ubuntu:~$ erl
Erlang R13B02 (erts-5.7.3) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.3 (abort with ^G)
1>
Now we have to fight with Riak documentation, which is out of sync with Riak too. It seems to be the good sign: real hackers never write documentation! (c) some classics...

[EDIT]
Actually, I have to credit this team with a bunch of nice intros and comments:
  1. the demo,
  2. the big one of course,
  3. the docs in the distro - my favorite,
  4. the very cool movie presentation from NYC NOSQL '09
  5. For those (including me) who keep thinking what in the wind is going on here - a bit of theory is a great help.
[/EDIT]

Here it goes. First, we will replace $RIAK with the path-to-riak in the config/riak-demo.erlenv: line 11 in there will look like
{riak_heart_command, "(cd /home/serge/src/riak; ./start-restart.sh /home/serge/src/riak/config/riak-demo.erlenv)"}.

Now we are ready to launch Riak
./start-fresh.sh config/riak-demo.erlenv

Nothing happens. Riak is supposed to work in the backround now.
Is it?

serge@ubuntu:~/src/riak$ ./start-fresh.sh config/riak-demo.erlenv
Attempting to connect to 'riakdemo@127.0.0.1' with cookie riak_demo_cookie...
Connected successfully
Looking for pre-existing object at {<<"riak_demo">>, <<"demo">>}...
Pre-existing object found, modifying
Storing object with new value...
Written successfully
Fetching object at {<<"riak_demo">>, <<"demo">>}...
Fetched successfully
Object contained correct value
SUCCESS
"SUCCESS" looks like success!

Now there is the point where README is [EDIT] no longer! [/EDIT] "lying", so we will do the right thing on our own:
serge@ubuntu:~/src/riak$ erl -name riaktest@127.0.0.1 -pa ebin -setcookie riak_demo_cookie
Erlang R13B02 (erts-5.7.3) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.3 (abort with ^G)
(riaktest@127.0.0.1)1> net_adm:ping('riakdemo@127.0.0.1').
pong

So far so good, the Riak node is found. Let's work with it:

(riaktest@127.0.0.1)6> {ok,C}=riak:client_connect('riakdemo@127.0.0.1').
{ok,{riak_client,'riakdemo@127.0.0.1',
<<"20091014003214-riaktest@127.0.0.1-riakdemo@127.0.0.1-13736">>}}
Now the README doc is good to go with again:

(riaktest@127.0.0.1)6> O0 = riak_object:new(<<"groceries">>, <<"mine">>, ["bread"]).
{r_object,<<"groceries">>,<<"mine">>,
[{r_content,{dict,0,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],[],[],...}}},
["bread"]}],
[],
{dict,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],[],[],[],...}}},
undefined}
(riaktest@127.0.0.1)7> C:put(O0, 1).
ok
(riaktest@127.0.0.1)8> {ok, O1} = C:get(<<"groceries">>, <<"mine">>, 1).
{ok,{r_object,<<"groceries">>,<<"mine">>,
[{r_content,{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],...}}},
["bread"]}],
[{<<"20091014003214-riaktest@127.0.0.1-riakdemo@127.0.0.1-13736">>,
{1,63422699573}}],
{dict,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],[],...}}},
undefined}}
(riaktest@127.0.0.1)9> V = riak_object:get_value(O1).
["bread"]
(riaktest@127.0.0.1)10> O2 = riak_object:update_value(O1, ["milk"|V]).
{r_object,<<"groceries">>,<<"mine">>,
[{r_content,{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],[[...]],[],...}}},
["bread"]}],
[{<<"20091014003214-riaktest@127.0.0.1-riakdemo@127.0.0.1-13736">>,
{1,63422699573}}],
{dict,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],[],[],[],...}}},
["milk","bread"]}
(riaktest@127.0.0.1)11> C:put(O2, 1).
ok
(riaktest@127.0.0.1)12> C:list_keys(<<"groceries">>).
{ok,[<<"mine">>]}
(riaktest@127.0.0.1)13>

Now Riak is really ready for experiments.