Setting Up RIAK
Since RIAK is not available on
windows we need to use Linux(Ubuntu ) to
install and use RIAK .
Installing Ubuntu
We want to run Linux in a virtual machine
so first thing we will be looking is to install VMware. We can find VMware at
the following link to download.
Second step is to get the ISO image
for Ubuntu which we can find here
I tried 32 bit version and when
everything is downloaded we need to fire VMware and to create a new virtual
machine by using downloaded ISO image for Ubuntu.
You can install Ubuntu from a
disk, or directly from the ISO file you can download (link
below). This is the simplest method if you’re simply wanting to
use Ubuntu in VMware Player. However, if you do have an Ubuntu disk, then
feel free to choose that instead. Once you’ve selected your install
media, VMware Player will automatically detect Ubuntu and will show that it
will be installed with Easy Install. Click next to continue.
Now, choose a name for your
virtual machine and where to save it. Simply click next to accept the
defaults.
You can choose how large you
want your virtual hard drive to be; the default is 20Gb, but you can choose a
different size if you wish. Please note that the entire 20Gb will not be
used up on your hard drive initially. Ours only took up 3.6Gb with a
clean install, but this will increase as you install programs and save files.
And that’s it! You can
review your settings and change them here if you wish, or simply click Finish
to start installing Ubuntu!
VMware player will now
install Ubuntu without any further input. The window may show cryptic
commands, but don’t worry, as you don’t have to do anything else to install
Ubuntu.
During the install, you may
be prompted to download and install VMware tools for Linux. Simply click
Download and the tools will automatically download and install, though you may
have to approve the UAC prompt.
VMware will continue
installing Ubuntu even while the tools are downloading. Once the install
is finished, you will be presented with your Ubuntu login screen. The
full install took about 30 minutes in our test.
Installing RIAK
Once you are done with installation of Ubuntu Next step is
to install RIAK .
Since we are using 32 bit version we will look into 32 bit
version of RIAK which can be find here http://docs.basho.com/riak/latest/tutorials/installation/Installing-on-Debian-and-Ubuntu/
To begin installation we need to First go to Command line
Terminal by pressing CTRL + ALT + T then
we need to provide following commands to start installation of RIAK
wget http://downloads.basho.com.s3-website-us-east-1.amazonaws.com/riak/1.3/1.3.0/ubuntu/lucid/riak_1.3.0-1_i386.deb
sudo dpkg -i riak_1.3.0-1_i386.deb
RIAK is set up by end of this execution.
Update Configurations
Next Step is to update RIAK Configurations so that client
can successfully communicate with RIAK
First Stop RIAK server if it is already running by issuing
the following command on Terminal
RIAK stop
Then need to move to app.config file to make necessary
changes.
In our case aap.config will be placed in /etc/riak folder we can find it by moving into this folder from
FileSystem .
Note:
In order to make changes to a file you need to use root
permissions
So first create root user and assign permissions to this
user then logout and log in with root user to make changes to app.config file.
Root user can be activated by firing following commands on
terminal.
sudo passwd root
and then
sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'
Your virtual machine by default
will be configured to use auto assignment of ip address make sure to assign it manual
so that the clients may not suffer if IP address changes.
Open app.config and change address
127.0.0.1 to the IP Address of the
machine
This setting will be required at
following two locations.
{http, [ {"127.0.0.1",
8098 } ]},
Will become
{http, [ {"192.168.112.128",
8098 } ]},
AND
{pb_ip, "127.0.0.1" },
Will become
{pb_ip, "192.168.112.128" },
That’s all
Save File Go to Terminal and start
your RIAK server with the following command
RIAK Start
And make confirmation of running
and listening of server by issue Riak Ping Command it should respond with Pong J
Setting Up Client
Once the Server part is done next is to use C# to connect with it.
We need to use CorrugatedIron package as a client to our
RIAK server we can get it by using Nuget package .
Once this package is installed it will automatically add
required references and configurations section in our app.config(Desktop
application) or in our web.config(web application) files.
Like below.
<configSections>
<section name="riakConfig" type="CorrugatedIron.Config.RiakClusterConfiguration,
CorrugatedIron" />
</configSections>
<riakConfig nodePollTime="5000" defaultRetryWaitTime="200" defaultRetryCount="3">
<nodes>
<node name="dev1" hostAddress="192.168.112.128" pbcPort="8087" restScheme="http" restPort="8098" poolSize="20" />
<node name="dev2" hostAddress="riak-test" pbcPort="10027" restScheme="http" restPort="10028" poolSize="20" />
<node name="dev3" hostAddress="riak-test" pbcPort="10037" restScheme="http" restPort="10038" poolSize="20" />
<node name="dev4" hostAddress="riak-test" pbcPort="10047" restScheme="http" restPort="10048" poolSize="20" />
</nodes>
</riakConfig>
We can set up hostaddress and ports in our nodes
configuration with the address and ports configured for RIAK server.
Need to import some namespaces as follows
using CorrugatedIron;
using CorrugatedIron.Containers;
using CorrugatedIron.Config;
using CorrugatedIron.Comms;
and can get connected with RIAK as follows
var cluster = RiakCluster.FromConfig("riakConfig");
var client = cluster.CreateClient();
RiakResult result = client.Ping();
MessageBox.Show(result.IsSuccess.ToString());
Try stopping and starting RIAK server to make sure of
your connection.













No comments:
Post a Comment