Professional Documents
Culture Documents
Running A Cluster
Running A Cluster
Contents
Configuring a Riak cluster involves instructing each node to listen on a non-local interface, i.e.
not 127.0.0.1, and then joining all of the nodes together to participate in the cluster.
The commands below presume that you are running from a source install, but if you have installed Riak with a
binary install, you can substitute the usage of bin/riak with sudo /usr/sbin/riak and bin/riak-
admin with sudo /usr/sbin/riak-admin. The riak and riak-admin scripts are located in
the /bin directory of your installation.
If possible, you should avoid starting Riak prior to editing the name of a node. This setting corresponds to
the nodename parameter in the riak.conf file if you are using the newer configuration system, and to the -
name parameter in vm.args (as described below) if you are using the older configuration system. If you have
already started Riak with the default settings, you cannot change the -name setting and then successfully
restart the node.
If you cannot restart after changing the -name value you have two options:
Discard the existing ring metadata by removing the contents of the ring directory. This will
require rejoining all nodes into a cluster again.
*Rename the node using the riak-admin cluster replace command. This will not work if you have
previously only started Riak with a single node.
SHELL
riak stop
RIAK.CONF
APP.CONFIG
listener.protobuf.internal = 127.0.0.1:8087
becomes
RIAK.CONF
APP.CONFIG
listener.protobuf.internal = 192.168.1.10:8087
Note on upgrading to 2.0
If you are upgrading to Riak version 2.0 or later from an pre-2.0 release, you can use either your
old app.config/ vm.args configuration files or the newer riak.conf if you wish. If you have installed Riak
2.0 directly, you should use only riak.conf.
Below, examples will be provided for both the old and new configuration systems. Bear in mind that you need
to use either the older or the newer but never both simultaneously.
RIAK.CONF
APP.CONFIG
listener.http.internal = 127.0.0.1:8098
becomes
RIAK.CONF
APP.CONFIG
listener.http.internal = 192.168.1.10:8098
RIAK.CONF
VM.ARGS
RIAK.CONF
VM.ARGS
Use fully qualified domain names (FQDNs) rather than IP addresses for the cluster member node names. For
example, riak@cluster.example.com and riak@192.168.1.10 are both acceptable node naming
schemes, but using the FQDN style is preferred.
Once a node has been started, in order to change the name you must either remove ring files from
the /data/ring directory or riak-admin cluster force-replace the node.
SHELL
riak start
If the Riak node has been previously started, you must use the riak-admin cluster
replace command to change the node name and update the node’s ring file.
SHELL
riak-admin cluster replace riak@127.0.0.1 riak@192.168.1.10
Note on single nodes
If a node is started singly using default settings, as you might do when you are building your first test
environment, you will need to remove the ring files from the data directory after you edit your configuration
files. riak-admin cluster replace will not work since the node has not been joined to a cluster.
As with all cluster changes, you need to view the planned changes by running riak-admin cluster
plan and then running riak-admin cluster commit to finalize those changes.
The node is now properly set up to join other nodes for cluster participation. You can proceed to adding a
second node to the cluster.
SHELL
riak-admin cluster join riak@192.168.1.10
Output from the above should resemble:
SHELL
riak-admin cluster plan
riak-admin cluster commit
After the last command, you should see:
1. Using the riak-admin command:
SHELL
SHELL
ring_members : [ 'riak@192.168.1.10','riak@192.168.1.11']
2. Running the riak attach command. This will open up an Erlang shell, into which you can type
the following command:
ERLANG
{ok,{chstate,'riak@ 192.168.1.10',.........
(riak@ 192.168.52.129)2> riak_core_ring:all_members(R).
['riak@ 192.168.1.10','riak@192.168.1.11']
To join additional nodes to your cluster, repeat the above steps. You can also find more detailed instructions
about adding and removing nodes from a cluster.
All nodes in the cluster must have the same initial ring size setting in order to join, and participate in cluster
activity. This setting can be adjusted in your configuration file using the ring_creation_size parameter if
you’re using the older configuration system or ring_size in the new system.
Check the value of all nodes if you receive a message like this: Failed: riak@10.0.1.156 has a
different ring_creation_size
Note: If you have installed the .deb or .rpm package, then you will need to download and build Riak from
source to follow the directions below.
If you ran make all rel, then this can be found in ./rel/riak under the Riak source root
directory.
If you are running Mac OS X, then this is the directory where you unzipped the .tar.gz file.
1. Set your handoff port and your Protocol Buffers or HTTP port (depending on which interface you are
using) to different values on each node. For example:
o RIAK.CONF
o APP.CONFIG
2. # For Protocol Buffers:
3. listener.protobuf.internal = 127.0.0.1:8187
4.
5. # For HTTP:
6. listener.http.internal = 127.0.0.1:8198
7.
8. # For either interface:
9. handoff.port = 8199
10. Change the name of each node to a unique name. Now, start the nodes, changing path names and
nodes as appropriate:
SHELL
./rel/riak1/bin/riak start
./rel/riak2/bin/riak start
./rel/riak3/bin/riak start
# etc
Next, join the nodes into a cluster:
SHELL
./rel/riak2/bin/riak-admin cluster join riak1@127.0.0.1
./rel/riak3/bin/riak-admin cluster join riak1@127.0.0.1
./rel/riak2/bin/riak-admin cluster plan
./rel/riak2/bin/riak-admin cluster commit