Giter Site home page Giter Site logo

thejaspm / docker-riak Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hectcastro/docker-riak

0.0 2.0 0.0 197 KB

A Docker project to bring up a local Riak cluster.

Home Page: https://registry.hub.docker.com/u/hectcastro/riak/

License: Apache License 2.0

Makefile 4.82% Shell 95.18%

docker-riak's Introduction

docker-riak Build Status

This is a Docker project to bring up a local Riak cluster.

Prerequisites

Install Docker

Follow the instructions on Docker's website to install Docker.

From there, ensure that your DOCKER_HOST environmental variable is set correctly:

$ export DOCKER_HOST="tcp://127.0.0.1:2375"

Note: If you're using boot2docker ensure that you forward the virtual machine port range (49000-49900). If you want to set DOCKER_RIAK_BASE_HTTP_PORT, ensure that you forward that port range instead:

$ for i in {49000..49900}; do
 VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
 VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
done

sysctl

In order to tune the Docker host housing Riak containers, consider applying the following sysctl settings:

vm.swappiness = 0
net.ipv4.tcp_max_syn_backlog = 40000
net.core.somaxconn = 40000
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

Running

Clone repository and build Riak image

$ git clone https://github.com/hectcastro/docker-riak.git
$ cd docker-riak
$ make build

Environmental variables

  • DOCKER_RIAK_CLUSTER_SIZE – The number of nodes in your Riak cluster (default: 5)
  • DOCKER_RIAK_AUTOMATIC_CLUSTERING – A flag to automatically cluster Riak (default: false)
  • DOCKER_RIAK_DEBUG – A flag to set -x on the cluster management scripts (default: false)
  • DOCKER_RIAK_BASE_HTTP_PORT - A flag to use fixed port assignment. If set, manually forward port DOCKER_RIAK_BASE_HTTP_PORT + $index to 8098 (Riak's HTTP port) and forward DOCKER_RIAK_BASE_HTTP_PORT + $index + DOCKER_RIAK_PROTO_BUF_PORT_OFFSET to 8087 (Riak's Protocol Buffers port).
  • DOCKER_RIAK_PROTO_BUF_PORT_OFFSET - Optional port offset (default: 100)
  • DOCKER_RIAK_BACKEND - Optional Riak backend to use (default: bitcask)

Launch cluster

$ DOCKER_RIAK_AUTOMATIC_CLUSTERING=1 DOCKER_RIAK_CLUSTER_SIZE=5 DOCKER_RIAK_BACKEND=leveldb make start-cluster
./bin/start-cluster.sh

Bringing up cluster nodes:

  Successfully brought up [riak01]
  Successfully brought up [riak02]
  Successfully brought up [riak03]
  Successfully brought up [riak04]
  Successfully brought up [riak05]

Please wait approximately 30 seconds for the cluster to stabilize.

Testing

From outside the container, we can interact with the HTTP or Protocol Buffers interfaces.

HTTP

The HTTP interface has an endpoint called /stats that emits Riak statistics. The test-cluster Makefile target hits a random container's /stats endpoint and pretty-prints its output to the console.

The most interesting attributes for testing cluster membership are ring_members:

$ make test-cluster | egrep -A6 "ring_members"
    "ring_members": [
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]"
    ],

And ring_ownership:

$ make test-cluster | egrep "ring_ownership"
    "ring_ownership": "[{'[email protected]',3},\n {'[email protected]',4},\n {'[email protected]',3},\n {'[email protected]',4},\n {'[email protected]',3},\n {'[email protected]',4},\n {'[email protected]',3},\n {'[email protected]',4},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3},\n {'[email protected]',3}]",

Together, these attributes let us know that this particular Riak node knows about all of the other Riak instances.

SSH

The phusion/baseimage-docker image has the ability to enable an insecure key for conveniently logging into a container via SSH. It is enabled in the Dockerfile by default here:

RUN /usr/sbin/enable_insecure_key

In order to login to the container via SSH using the insecure key, follow the steps below.

Use docker inspect to determine the container IP address:

$ docker inspect $CONTAINER_ID | grep IPAddress
        "IPAddress": "172.17.0.2",

Download the insecure key, alter its permissions, and use it to SSH into the container via its IP address:

$ curl -o insecure_key -fSL https://github.com/phusion/baseimage-docker/raw/master/image/insecure_key
$ chmod 600 insecure_key
$ ssh -i insecure_key [email protected]

Note: If you're using boot2docker, ensure that you're issuing the SSH command from within the virtual machine running boot2docker.

Destroying

$ make stop-cluster
./bin/stop-cluster.sh
Stopped the cluster and cleared all of the running containers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.