Setting up a Riak cluster is very simple to do. Simply install the software, make a few configuration changes, and startup the service. In the example below, we will show how to create a very small development cluster using only (5) servers.



Prerequisites
Each node must be correctly configured before starting the cluster.

Tuning:

echo deadline > /sys/block/sda/queue/scheduler

echo 1024 > /sys/block/sda/queue/nr_requests

# vi /etc/sysctl.conf (for 10G performance)

net.ipv4.tcp_max_syn_backlog = 40000
net.core.somaxconn = 40000
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
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
net.ipv4.tcp_moderate_rcvbuf = 1
#
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.tcp_mem = 134217728 134217728 134217728
net.ipv4.tcp_rmem = 4096 277750 134217728
net.ipv4.tcp_wmem = 4096 277750 134217728
net.core.netdev_max_backlog = 300000
#
fs.file-max = 50384
vm.swappiness=0

# /sbin/sysctl –p

# vi /etc/fstab

UUID=0b5e90e8-8749-47a5-9819-a14b1e7d0acf / ext4 noatime 0 1

Pre-Install:

# ulimit -n 65536 (session only change)

# vi /etc/security/limits.conf
* – nofile 65536
riak soft nofile 4096
riak hard nofile 65536

NOTE: Make sure hostnames are in /etc/hosts.
10.xxx.xxx.73 inet10073.yourdomain.com inet10073
10.xxx.xxx.74 inet10074.yourdomain.com inet10074
10.xxx.xxx.75 inet10075.yourdomain.com inet10075
10.xxx.xxx.76 inet10076.yourdomain.com inet10076
10.xxx.xxx.77 inet10077.yourdomain.com inet10077

Install Riak:

# apt-get install curl

# curl https://packagecloud.io/gpg.key | sudo apt-key add –

# sudo apt-get install -y apt-transport-https

# sudo apt-get install libpam0g-dev

# sudo apt-get install libssl0.9.8

# vi install-script

#!/bin/bash

HOSTNAME=`hostname -f`
FILENAME=/etc/apt/sources.list.d/basho.list
OS=ubuntu
DIST=precise
PACKAGE_CLOUD_RIAK_DIR=https://packagecloud.io/install/repositories/basho/riak
curl “${PACKAGE_CLOUD_RIAK_DIR}/config_file.list?os=${OS}&dist=${DIST}&name=${HOSTNAME}” > $FILENAME

# chmod 777 install-script
# ./install-script

# sudo apt-get update

# sudo apt-get install riak

Erlang Install:

# sudo apt-get install build-essential libncurses5-dev openssl libssl-dev fop xsltproc unixodbc-dev

# sudo apt-get install libwxbase2.8 libwxgtk2.8-dev libqt4-opengl-dev

Remove Ring Info:

# cd /var/lib/riak
# rm –rf ring

Configure Riak:

# vi /etc/riak/riak.conf

nodename = riak@10.x.x.xx
listener.http.internal = 10.x.x.xx:8098
listener.protobuf.internal = 10.x.x.xx:8087
listener.https.internal = 10.x.x.xx:8069

## ssl.keyfile = $(platform_etc_dir)/key.pem
ssl.certfile = $(platform_etc_dir)/inet.crt

## ssl.keyfile = $(platform_etc_dir)/key.pem
ssl.keyfile = $(platform_etc_dir)/inet.key

Generate Key/Cert
# sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/riak/inet.key -out /etc/riak/inet.crt

Starting Node:

# riak start
# riak ping
# riak stop

Join to cluster:

# riak-admin cluster join riak@10.201.x.xx
# riak-admin cluster plan
# riak-admin cluster commit

# riak-admin member-status

Riak Search:

# vi /etc/riak/riak.conf

search = on

Riak Control: (one unit only)

Enable Riak Control
# vi /etc/riak/riak.conf

riak_control = on

riak_control.auth.mode = userlist

riak_control.auth.user.riak.password = 123test123 (example only)

Access Riak Control:
https://xxx.xxx.xxx.xxx:8069/admin

Leave a Reply

Your email address will not be published. Required fields are marked *