Skip to content

Instantly share code, notes, and snippets.

@arnab
Last active September 12, 2017 11:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnab/5891706 to your computer and use it in GitHub Desktop.
Save arnab/5891706 to your computer and use it in GitHub Desktop.
Install and run riak in a distributed mode on Mac OSX using homebrew

Install

  1. brew install riak
  2. cd `brew --prefix riak`
  3. copy the create_cluster.sh script into this dir
  1. run the script
  • chmod u+x create_cluster.sh
  • ./create_cluster.sh

Run

  1. Reset ulimit
  • ulimit -n 4096
  • Otherwise, you'll get a warning with Riak and your instances will keep dying:
  • WARNING: ulimit -n is 256; 4096 is the recommended minimum.
  • To make this permanent, put it in your ~/.zshrc or similar.
  1. ps -ef | grep riak
  • Kill the epmd daemon. That's cause we need it to restart after the config change above.
  1. Start the riak instances
  • /usr/local/Cellar/riak/dev/dev1/bin/riak start
  • make sure it responds to ping with a pong
  • /usr/local/Cellar/riak/dev/dev1/bin/riak ping
  • Repeat for instances 2-n
  1. Join the instances into a cluster:
  • /usr/local/Cellar/riak/dev/dev2/bin/riak-admin cluster join dev1@127.0.01
  • /usr/local/Cellar/riak/dev/dev3/bin/riak-admin cluster join dev2@127.0.01
  • etc.
#!/bin/bash
# from http://ottopoellath.github.io/blog/2012/04/08/running-a-three-node-riak-cluster-using-a-homebrew-installation/
CWD=$(cd $(dirname $0); pwd)
BASE_DIR="${CWD}/dev"
echo "Creating dev directory ${BASE_DIR}"
mkdir "${BASE_DIR}"
for node in 1 2 3 4; do
NODE_NAME="dev${node}"
NODE_DIR="$BASE_DIR/$NODE_NAME"
echo "Creating node ${NODE_NAME}"
cp -r $(brew --prefix riak) $NODE_DIR
echo " Removing data dir"
rm -rf "$NODE_DIR/libexec/data/"
HTTP="809${node}"
echo " Setting 'http' to '${HTTP}'"
perl -p -i.bak -e 's/({http, \[ {"\d+\.\d+\.\d+\.\d+", )(\d+)( } ]})/${1}'${HTTP}'${3}/g' "$NODE_DIR/libexec/etc/app.config"
HANDOFF_PORT="810${node}"
echo " Setting 'handoff_port' to '${HANDOFF_PORT}'"
perl -p -i.bak -e 's/({handoff_port, )(\d+)( })/${1}'${HANDOFF_PORT}'${3}/g' "$NODE_DIR/libexec/etc/app.config"
PB_PORT="808${node}"
echo " Setting 'pb_port' to '${PB_PORT}'"
perl -p -i.bak -e 's/({pb_port, )(\d+)( })/${1}'${PB_PORT}'${3}/g' "$NODE_DIR/libexec/etc/app.config"
NAME="dev${node}"
echo " Setting 'name' to '${NAME}'"
perl -p -i.bak -e 's/(-name )(\S+)(@.*)$/${1}'${NAME}'${3}/g' "$NODE_DIR/libexec/etc/vm.args"
NODE_BIN_DIR="$NODE_DIR/libexec/bin"
echo " Setting 'RUNNER_SCRIPT_DIR' to '${NODE_BIN_DIR}'"
perl -p -i.bak -e "s|RUNNER_SCRIPT_DIR=.*$|RUNNER_SCRIPT_DIR=${NODE_BIN_DIR}|g" "$NODE_DIR/bin/riak" \
"$NODE_DIR/bin/riak-admin" \
"$NODE_DIR/bin/search-cmd" \
"$NODE_DIR/libexec/bin/riak" \
"$NODE_DIR/libexec/bin/riak-admin" \
"$NODE_DIR/libexec/bin/search-cmd"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment