Skip to content

Commit

Permalink
Import riak cookbook, currently at version 0.14.4. (riak v0.14.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
seancribbs committed Jul 18, 2011
0 parents commit a56d86c
Show file tree
Hide file tree
Showing 26 changed files with 2,569 additions and 0 deletions.
120 changes: 120 additions & 0 deletions README.md
@@ -0,0 +1,120 @@
Riak Cookbook
=============

Overview
========

Riak is a Dynamo-inspired key/value store that scales predictably and easily. Riak combines a decentralized key/value store, a flexible map/reduce engine, and a friendly HTTP/JSON query interface to provide a database ideally suited for Web applications. And, without any object-relational mappers and other heavy middleware, applications built on Riak can be both simpler and more powerful. For complete documentation and source code, see the Riak home page at [Basho][1].


Getting Started
===============

The Riak cookbook can be used just by adding "riak" to the runlist for a node. The default settings will cause Riak to be installed and configured. Creating a cluster of nodes requires you set appropriate attributes, particularly the Erlang `node_name`, and either manually join nodes to the cluster or use the gossip seed configuration option.


Package Installation
--------------------

There are two options for package installation: source and binary. If you are using a RedHat or Debian/Ubuntu system, binary installation is recommended and is the default. If you choose to do a source installation, be sure you are using Erlang/OTP R13B04 or later.

The package parameters available are version, type and, optionally for source installation, an install prefix:

node[:riak][:package][:version][:major] = "0"
node[:riak][:package][:version][:minor] = "11"
node[:riak][:package][:version][:incremental] = "0"
node[:riak][:package][:type] = ("binary" | "source")
node[:riak][:package][:prefix] = "/usr/local"


Basic Configuration
-------------------

Most Riak configuration is for networking, Erlang, and storage backends. The only, interesting configuration options outside of those is the filesystem path where ring state files should be stored.

node[:riak][:core][:ring_state_dir] = "/var/lib/riak/ring"


Networking
----------

Riak clients communicate with the nodes in the cluster through either the HTTP or Protobufs interfaces, both of which may be used simultaneously. Configuration for each interface includes the IP address and TCP port on which to listen for client connections. The default for the HTTP interface is localhost:8098 and for Protobufs 0.0.0.0:8087, meaning client connections to any address on the server, TCP port 8087, are accepted. As the default HTTP configuration is inaccessible to other nodes, it must be changed if you want clients to use the HTTP interface.

node[:riak][:core][:http] = [["127.0.0.1", 8098]]
node[:riak][:kv][:pb_ip] = "0.0.0.0"
node[:riak][:kv][:pb_port] = 8087

Intra-cluster handoff occurs over a dedicated port, which defaults to 8099.

node[:riak][:core][:handoff_port] = 8099

Finally, by default, options are included in the configuration to define the set of ports used for Erlang inter-node communication.

node[:riak][:kernel][:limit_port_range] = true
node[:riak][:kernel][:inet_dist_listen_min] = 6000
node[:riak][:kernel][:inet_dist_listen_max] = 7999

On Debian/Ubuntu platforms, IPTables rules corresponding to these settings to explicitly allow required ports and addresses are automatically generated.


Erlang
------

A number of Erlang parameters may be configured through the cookbook. The node name and cookie are most important for creating multi-node clusters. The rest of the parameters are primarily for performance tuning, with kernel polling and smp enabled by default. Any available Erlang environment variable may be set with the env vars hash.

node[:riak][:erlang][:node_name] = "riak@#{node[:fqdn]}"
node[:riak][:erlang][:cookie] = "riak"
node[:riak][:erlang][:kernel_polling] = (true | false)
node[:riak][:erlang][:async_threads] = 64
node[:riak][:erlang][:smp] = ("enable" | "disable")
node[:riak][:erlang][:env_vars][:ERL_MAX_PORTS] = 4096
node[:riak][:erlang][:env_vars][:ERL_FULLSWEEP_AFTER] = 10


Storage Backends
================

Riak requires specification of a storage backend along with various backend storage options, specific to each backend. While Riak supports specification of different backends for different buckets, the Chef cookbook does not yet allow such configurations. The most common backends are Bitcask (the default), Innostore, and DETS. The typical configuration options and their defaults are given below.


Bitcask
-------

By virtue of its architecture, Bitcask requires much less tuning to achieve good performance than Innostore.

node[:riak][:bitcask][:data_root] = "/var/lib/riak/bitcask"
node[:riak][:bitcask][:max_file_size] = 2147483648
node[:riak][:bitcask][:open_timeout] = 4
node[:riak][:bitcask][:sync_strategy] = :none
node[:riak][:bitcask][:frag_merge_trigger] = 60
node[:riak][:bitcask][:dead_bytes_merge_trigger] = 536870912
node[:riak][:bitcask][:frag_threshold] = 40
node[:riak][:bitcask][:dead_bytes_threshold] = 134217728
node[:riak][:bitcask][:small_file_threshold] = 10485760
node[:riak][:bitcask][:expiry_secs] = -1


DETS
----

DETS is the default storage backend for Riak. It's very simple to setup, only requiring a path where it should store data files. However, for production use Innostore and Bitcask are better choices.

node[:riak][:kv][:riak_kv_dets_backend_root] = "/var/lib/riak/dets"
\

Innostore
---------

Innostore is an Erlang wrapper around embedded InnoDB, a transactional storage engine developed for and generally used with MySQL. It has an enormous set of tuning parameters, all of which are documented at the [InnoDB site][2]. The most common parameters are set to reasonable defaults by the Riak cookbook.

node[:riak][:innostore][:log_buffer_size] = 8388608
node[:riak][:innostore][:log_files_in_group] = 8
node[:riak][:innostore][:log_file_size] = 268435456
node[:riak][:innostore][:flush_log_at_trx_commit] = 1
node[:riak][:innostore][:data_home_dir] = "/var/lib/riak/innodb"
node[:riak][:innostore][:log_group_home_dir] = "/var/lib/riak/innodb"
node[:riak][:innostore][:buffer_pool_size] = 2147483648


[1]: http://basho.com/
[2]: http://www.innodb.com/doc/embedded_innodb-1.0/#config-vars
31 changes: 31 additions & 0 deletions attributes/bitcask.rb
@@ -0,0 +1,31 @@
#
# Author:: Benjamin Black (<b@b3k.us>) and Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default.riak.bitcask.data_root = "/var/lib/riak/bitcask"
default.riak.bitcask.max_file_size = 2147483648
default.riak.bitcask.open_timeout = 4
# Sync strategy is one of: :none, :o_sync, {:seconds => N}
default.riak.bitcask.sync_strategy = :none
default.riak.bitcask.frag_merge_trigger = 60
default.riak.bitcask.dead_bytes_merge_trigger = 536870912
default.riak.bitcask.frag_threshold = 40
default.riak.bitcask.dead_bytes_threshold = 134217728
default.riak.bitcask.small_file_threshold = 10485760
default.riak.bitcask.expiry_secs = -1

23 changes: 23 additions & 0 deletions attributes/core.rb
@@ -0,0 +1,23 @@
#
# Authors:: Benjamin Black (<b@b3k.us>) and Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default.riak.core.cluster_name = "default"
default.riak.core.http = [["127.0.0.1",8098]]
default.riak.core.ring_state_dir = "/var/lib/riak/ring"
default.riak.core.handoff_port = 8099
27 changes: 27 additions & 0 deletions attributes/default.rb
@@ -0,0 +1,27 @@
#
# Author:: Benjamin Black (<b@b3k.us>) and Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include_attribute "riak::package"
include_attribute "riak::core"
include_attribute "riak::erlang"
include_attribute "riak::kernel"
include_attribute "riak::kv"
include_attribute "riak::sasl"
include_attribute "riak::err"
include_attribute "riak::luwak"
20 changes: 20 additions & 0 deletions attributes/dets.rb
@@ -0,0 +1,20 @@
#
# Author:: Benjamin Black (<b@b3k.us>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default.riak.kv.riak_kv_dets_backend_root = "/var/lib/riak/dets"
28 changes: 28 additions & 0 deletions attributes/erlang.rb
@@ -0,0 +1,28 @@
#
# Author:: Benjamin Black (<b@b3k.us>) and Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include_attribute "riak::core"

default.riak.erlang.node_name = "riak@127.0.0.1"
default.riak.erlang.cookie = "riak"
default.riak.erlang.kernel_polling = true
default.riak.erlang.async_threads = 64
default.riak.erlang.smp = "enable"
default.riak.erlang.env_vars.ERL_MAX_PORTS = 4096
default.riak.erlang.env_vars.ERL_FULLSWEEP_AFTER = 0
21 changes: 21 additions & 0 deletions attributes/err.rb
@@ -0,0 +1,21 @@
#
# Author:: Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default.riak.err.term_max_size = 65536
default.riak.err.fmt_max_bytes = 65536
28 changes: 28 additions & 0 deletions attributes/innostore.rb
@@ -0,0 +1,28 @@
#
# Author:: Benjamin Black (<b@b3k.us>) and Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default.riak.innostore.log_buffer_size = 8388608
default.riak.innostore.log_files_in_group = 8
default.riak.innostore.log_file_size = 268435456
default.riak.innostore.flush_log_at_trx_commit = 1
default.riak.innostore.data_home_dir = "/var/lib/riak/innodb"
default.riak.innostore.log_group_home_dir = "/var/lib/riak/innodb"
default.riak.innostore.buffer_pool_size = 2147483648
default.riak.innostore.flush_method = "O_DIRECT"

22 changes: 22 additions & 0 deletions attributes/kernel.rb
@@ -0,0 +1,22 @@
#
# Author:: Benjamin Black (<b@b3k.us>) and Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default.riak.kernel.limit_port_range = true
default.riak.kernel.inet_dist_listen_min = 6000
default.riak.kernel.inet_dist_listen_max = 7999
34 changes: 34 additions & 0 deletions attributes/kv.rb
@@ -0,0 +1,34 @@
#
# Author:: Benjamin Black (<b@b3k.us>) and Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


default.riak.kv.mapred_queue_dir = "/var/lib/riak/mr_queue"
default.riak.kv.mapper_batch_size = 5
default.riak.kv.map_js_vm_count = 8
default.riak.kv.reduce_js_vm_count = 6
default.riak.kv.hook_js_vm_count = 2
default.riak.kv.js_max_vm_mem = 8
default.riak.kv.js_thread_stack = 16
default.riak.kv.mapred_name = "mapred"
default.riak.kv.raw_name = "riak"
default.riak.kv.riak_kv_stat = true
default.riak.kv.stats_urlpath = "stats"
default.riak.kv.pb_ip = "127.0.0.1"
default.riak.kv.pb_port = 8087
default.riak.kv.storage_backend = :riak_kv_bitcask_backend
20 changes: 20 additions & 0 deletions attributes/luwak.rb
@@ -0,0 +1,20 @@
#
# Author:: Sean Cribbs (<sean@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2010 Basho Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default.riak.luwak.enabled = false

0 comments on commit a56d86c

Please sign in to comment.