Installation
- Download Riak 1.2.1( Newest at the time of writing this page) from Riak Downloads
- sudo dpkg -i
<downloaded file>
- Note the above steps are for ubuntu based systems.
System Configuration
- Modify
/etc/security/limits.conf to have these entries at the bottom. The value you set here depends on the number of partitions in the Riak Cluster and also the resources available.
* soft nofile 32768
* hard nofile 32768
- Create a file
/etc/default/riak
ulimit -n 8192
- Modify
/etc/sysctl.conf to have these entries at the end
vm.swappiness = 0
net.ipv4.tcp_max_syn_backlog = 40000
net.core.somaxconn=4000
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_tw_reuse = 1
- Modify
/etc/fstab to add noatime for mount options. Make sure you restart the machine for changes to affect.
UUID=55aa50cd-6281-4558-8282-10ae3b6c90cd / ext4 noatime,errors=remount-ro 0 1
- Make sure the machines in your Riak cluster have a different hostname . Modify
/etc/hostname for give different names to all the machines.
Riak Configuration
Configuration files for Riak are stored in /etc/riak folder. Two configuration files exists app.config and vm.args.
app.config
- In riak-api section change the pb_backlog and pb_ip keys.
{riak_api, [
%% pb_backlog is the maximum length to which the queue of pending
%% connections may grow. If set, it must be an integer >= 0.
%% By default the value is 5. If you anticipate a huge number of
%% connections being initialised *simultaneously*, set this number
%% higher.
{pb_backlog, 32},
%% pb_ip is the IP address that the Riak Protocol Buffers interface
%% will bind to. If this is undefined, the interface will not run.
{pb_ip, "ipaddress of the host being configured" },
%% pb_port is the TCP port that the Riak Protocol Buffers interface
%% will bind to
{pb_port, 8087 }
]},
%% Default ring creation size. Make sure it is a power of 2,
%% e.g. 16, 32, 64, 128, 256, 512 etc
{ring_creation_size, 512},
%% http is a list of IP addresses and TCP ports that the Riak
%% HTTP interface will bind.
{http, [ {"ipaddress of the host being configured", 8098 } ]},
- In riak_kv section set the storage backend to leveldb.
{riak_kv, [
%% Storage_backend specifies the Erlang module defining the storage
%% mechanism that will be used on this node.
{storage_backend, riak_kv_eleveldb_backend} ] }
- In riak_search section enable the search feature.
{riak_search, [
%% To enable Search functionality set this 'true'.
{enabled, true}
]},
- In eleveldb section have entries like below. For more information on how to configure leveldb LevelDB Backend
{eleveldb, [
{data_root, "/var/lib/riak/leveldb"},
{cache_size, 134217728},
{expire_secs, 5184000}
]}
vm.args
Modify the vm.args and set the -name key
## Name of the riak node
-name riak@ipaddress of the host being configured
Starting and joining to a cluster.
shell$ riak start
shell$ riak-admin cluster join riak@ip address of the first host configured
Why those configurations?
Here are the reasons for choosing those configs.
- pb_backlog by default is 32 . We expect creating a lot of connections hence I set it to 32.
- Ring size of 512 I chose because I wanted to grow the cluster at later point and wanted a sufficient set of partition to load balance. There is one more reason for choosing 512 because leveldb for 2i works best for less than or equal to 512 partitions.
- LevelDB backend : because it supports 2i ( secondary index) and has compression.
- More the cache size better the results but it depends on the total number of partitions(ring size) and available memory . I set a reasonable value depending on the memory present per node.