How to: Setting up a Riak Linux node on VirtualBox
How to: Setting up a Riak Linux node on VirtualBox
The following step-by-step guide will walk you through the process of setting up Ubuntu Server and Riak on a VirtualBox virtual machine. If you have any problems following this guide, or want to give feedback, plese post it on our
Q/A site. Don't forget to write what platform your physical machine is running. This guide has been tested to work well on Windows 7.
- Download and install the latest VirtualBox for your platform.
VirtualBox is available from https://www.virtualbox.org/wiki/Downloads.
- Download the Ubuntu Server 11.10 64-bit image file.
The installation image is available from http://www.ubuntu.com/download/server/download.
- Start VirtualBox and create a new virtual machine. Specify Linux as operating system and Ubuntu (64 bit) as version. Name it 'Ubuntu Riak' or something similar. Use the default settings for memory and hard drive.
This will create a virtual hard drive with dynamic size. If you want to fine-tune performance you can use specific options here, but it is not necessary if you just want a quick start.
- Open the settings dialog for your new virtual machine and navigate to the Network section. Set the first adapter to be connected to a Bridged network card. Leave the rest at the default settings.
Bridged network means that your virtual machine will appear as a separate computer on the local network, and will obtain its IP address from the nearest router in the same way as your physical machine does.
- Start your new virtual machine and choose to use your Ubuntu Server image as installation media.
- Follow the instructions on the screen while Ubuntu Server is installing.
You don't have to add anything specific during the installation. A minimal installation is enough to get Riak up and running. Make sure the Ubuntu installation has completed before continuing to the next step.
- By default, your newly installed Ubuntu uses DHCP, which means that it will dynamically receive an IP address from the router each time it starts. Riak however, needs to be configured with a static IP address, so you need to set Ubuntu up for this.
Open /etc/network/interfaces in a text editor.
If you are unfamiliar with Linux and don't have a favorite text editor, perform the following steps.
- Type sudo apt-get install diakonos in the terminal. This will install the Diakonos text editor which is easy to use by Windows users because it has Windows-styled keyboard shortcuts. You may have to answer Y a few times during installation.
- Type sudo diakonos /etc/network/interfaces in the terminal. Press Ctrl+W to dismiss the welcome screen.
- You will find a line saying something like iface eth0 inet dhcp. Replace this line with the following lines.
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
The new IP address of your virtual machine is on the second line. We have chosen the IP address 192.168.1.200 because it is likely above the range that the router DHCP uses for dynamic allocation, so there should be little risk that it is in use. Note that this is an assumption based on common default settings in routers. If you get problems with this you should double-check your subnet settings in the router.
- Save the file (Ctrl+S in diakonos), and quit (Ctrl+Q).
- Restart the networking service by typing sudo /etc/init.d/networking restart in the terminal. Verify that the IP is correctly set by typing ifconfig. The inet addr of the eth0 adapter should be 192.168.1.200.
Now you will install and configure Riak with the static IP of the virtual machine.
- Open Riak's Installing on Debian and Ubuntu page and install Riak by typing in the commands listed under From our custom .deb package and 64-bit.
Before you start Riak for the first time, you need to configure the correct IP in two of its configuration files.
- Type sudo diakonos /etc/riak/app.config in the terminal to open Riak's app.config file.
- There are two lines in this file where you need to insert your static IP.
- The first is close to the top and reads {http, [ {"127.0.0.1", 8098} ]}.
- The second is one page down and reads {pb_ip, "127.0.0.1" }.
Leave the port numbers as they are for now. You need to change them for new virtual machines if you want to add more Riak nodes.
- Now type sudo diakonos /etc/riak/vm.args in the terminal.
- At the top, a line reads -name riak@127.0.0.1.
Change the line to have your IP instead.
Now you are ready to start your Riak node.
- Type riak start in the terminal. Then type riak-admin test.
Riak should respond that it has successfully completed one write/read cycle.
If you get a timeout error from riak-admin test then you might have the wrong version of an SSL library that Riak needs. You can easily fix this by typing sudo apt-get install libssl0.9.8 in the terminal. Then run the test again to make sure it is working.
You now have a working Riak node. You can now open up a uGameDB Unity project and start sending requests to it. If you want to add more nodes to the cluster, repeat the procedure above for each node and, once you have more working nodes, add them to the cluster by following the
Basho guide for Adding and Removing Nodes.