Skip to content

Instantly share code, notes, and snippets.

@nisaacson
Last active January 2, 2016 10:39
Show Gist options
  • Save nisaacson/8291222 to your computer and use it in GitHub Desktop.
Save nisaacson/8291222 to your computer and use it in GitHub Desktop.
Use vagrant and docker to quickly start a riak server. Supports virtualbox and vmware_fusion providers

Usage

cd /path/to/this/gist
vagrant up --provision

After the virtual machine has started up and finished provisioning, open a web browser to http://localhost:8098 to confirm that riak is running.

Enable search

By default riak buckets do not support search indexing. To enable search on a bucket foo, execute the following

BUCKET="foo"
URL="http://localhost:8098/riak/$BUCKET"
DATA='{"props":{"precommit":[{"mod":"riak_search_kv_hook","fun":"precommit"}]}}'
curl --silent -H 'Content-type: application/json' -X PUT -d "$DATA" $URL
echo "enabled search on bucket: $BUCKET"
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
###################
# Port Forwarding
###################
config.vm.define "develop" do |develop|
develop.vm.host_name = "develop"
develop.vm.network "forwarded_port", guest: 8087, host: 8087 # riak pbc
develop.vm.network "forwarded_port", guest: 8098, host: 8098 # riak http
end
###################
# Docker Provisioning
###################
config.vm.provision "docker" do |docker|
# pull images
docker.pull_images "nisaacson/riak"
# run riak server container
docker.run "nisaacson/riak",
args: "-p 3333:22 -p 8087:8087 -p 8098:8098"
end
###################
# Virtualbox Provider
###################
config.vm.provider :virtualbox do |vb, override|
override.vm.box = "precise64_virtualbox"
override.vm.box_url = "http://files.vagrantup.com/precise64.box"
# Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "1"]
end
###################
# Vmware Fusion Provider
###################
config.vm.provider :vmware_fusion do |v, override|
# override box and box_url when using the "--provider vmware_fusion" flag
override.vm.box = "precise64_fusion"
override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"
v.gui = false
v.vmx["memsize"] = "1024"
v.vmx["numvcpus"] = "1"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment