Posted on

Riak on SmartOs outside Joyent SDC

Here is a quick step by step on how to set up a test Riak cluster on SmartOs outside Joyent Smartdatacenter.

The first step is to author a json file describing the VM. Here is mine as an example:
{
"alias": "riak1",
"hostname": "riak1",
"brand": "joyent",
"dataset_uuid": "399e09fc-c448-11e1-b3c8-a3d517dfbb07",
"max_physical_memory": 4096,
"quota": 0,
"nics": [
{
"nic_tag": "admin",
"ip": "10.50.XX.XX",
"netmask": "255.255.255.0",
"gateway": "10.50.XX.XX"
}
]
}

It is almost the minimal file. Let’s have a look at the different parts:

  • alias: an alias to your VM, it appears when you do vmadm list in the global zone.
  • hostname: the name of the VM, it appears when you log into it instead of the UUID.
  • brand: stick with joyent as it is a SmartOs VM.
  • dataset_uuid: the uuid of the Joyent dataset to use. To know what to put there, see Stu Radnidge’s explanations.
  • max_physical_memory: in MiB.
  • quota: the size of the disk available for the VM.
  • nics: the network interface:
    • nic_tag: if you are going to only use one, put “admin”.
    • ip, netmask, gateway: although the docs state you can put dhcp there, it does not quite work: it ip obtained by dhcp will not be put in the several config files and your VM will not work properly.

Write at least three of them, changing the names and ips to make them different and push them to the GZ.
You can then create your VMs using vmadm create -f riak1.json and log into them using zlogin and the uuid. It is the only way at this point as the root user does not have a password.
With riak ping and riak version, you will see that riak is running, but an old version (1.1.4).
Here is the way to upgrade to the latest version:

  1. stop riak: svcadm disable riak (sometimes, it doesn’t work and you required to do a riak stop.)
  2. get the tar.gz from Basho’s website. 1.2.1 is at http://downloads.basho.com.s3-website-us-east-1.amazonaws.com/riak/1.2/1.2.1/smartos/11/riak-1.2.1-SmartOS-i386.tgz
  3. remove the current riak package: pkg_delete riak
  4. add the newer package: pkg_add riak-1.2.1-SmartOS-i386.tgz.
  5. modify app.config (located in /opt/local/etc/riak) to fit your installation:
    1. replace 127.0.0.1 by the correct ip in three location.
    2. if you want to use 2i, replace the storage_backend value by riak_kv_eleveldb_backend. 
  6. modify vm.argsto fit your installation:
    1. set -name to riak@<yourip>
    2. set -setcookie to any value, but it has to be the same on all the VMs that will join the cluster.
  7. as it is a fresh installation, remove the ring folder in /var/db/riak to take into account the modifications of vm.args.
  8. start riak with svcadm enable riak-epmd and svcadm enable riak. Sometimes, you may need to use riak start.
  9. it may take a while. You can check that something is happening by checking prstat.

Once you have done that to all the VMs you want to have in your cluster, you can have them form a cluster. On one of the node, issue a riak-admin cluster join riak@,anothernodeip> for each of the other nodes you want to have in your cluster. The command riak-admin status | grep ring_members should echo an array of all the your cluster nodes:
[root@riak1 ~]# riak-admin status | grep ring_members
ring_members : ['riak@10.50.XX.X1','riak@10.50.XX.X2','riak@10.50.XX.X4']

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s