Rqlite: Difference between revisions
Line 39: | Line 39: | ||
== A simple 3 nodes cluster == | == A simple 3 nodes cluster == | ||
This is assuming that you have working <code>rqlite</code> and <code>rqlited</code> on 3 different machines. | |||
'''Note:''' According to the documentation you need at least 3 nodes to test a fault tolerant cluster. In practice, to be fault tolerant, you need N/2 + 1 nodes up and running where N is the number of nodes in the cluster, to be fault tolerant. | |||
=== Create initial leader === | |||
To create a cluster you must first launch a node that can act as the initial leader. Do this as follows on host1: | |||
rqlited -node-id 1 -http-addr host1:4001 -raft-addr host1:4002 ~/node | |||
Note: host1 needs to resolve to an IP reachable by the other nodes. You can also directly used an IP, which can be useful for running rqlite with a VPN. | |||
=== Create subsequent node N === | |||
To join a second node to this leader, execute the following command on hostN: | |||
rqlited -node-id 2 -http-addr hostN:4001 -raft-addr hostN:4002 -join http://host1:4001 ~/node | |||
Note: hostN needs to resolve to an IP reachable by the other nodes. You can also directly used an IP, which can be useful for running rqlite with a VPN. | |||
== Testing the cluster! == | |||
=== on leader/host1 === | |||
* make sure rqlited is running (see above) | |||
* create some entries | |||
rqlite -H host1 | |||
FIXME | |||
=== on hostN === | |||
* make sure rqlited is running (see above) | |||
* create some entries | |||
rqlite -H host1 # YES it's host1! | |||
FIXME |
Revision as of 14:35, 29 May 2018
What: rqlite is a lightweight, distributed relational database built on SQLite.
Installation
Linux and macOS
Check the official binaries: https://github.com/rqlite/rqlite/releases
Installation on Raspberry Pi
Note: There are no rqlite binaries for the RPi, however it is possible to compile it quite easily. You only need to compile it on *one* RPi, after that you can simply copy the resulting binaries to other RPis of your cluster.
Compilation
- as root
- install latest version of golang for ARMv6 architecture (https://golang.org/dl/):
cd /usr/src wget https://dl.google.com/go/go1.10.2.linux-armv6l.tar.gz tar -C /usr/local -xzvf go1.10.2.linux-armv6l.tar.gz export PATH=$PATH:/usr/local/go/bin
- prepare environment for building rqlite (as root or regular user)
cd mkdir go cd go mkdir bin pkg src export GOPATH=$PWD
- build rqlite (this will take a while, monitor with (h)top if you like)
go get -u -t github.com/rqlite/rqlite/... # yes you need the '...' at the end cd $GOPATH/src/github.com/rqlite/rqlite/cmd/rqlite go build -v . sudo cp rqlite /usr/local/bin cd $GOPATH/src/github.com/rqlite/rqlite/cmd/rqlited go build -v . cp rqlited /usr/local/bin
That's it!
Installation on other nodes
You just need to copy the binaries rqlite
and rqlited
to /usr/local/bin
.
A simple 3 nodes cluster
This is assuming that you have working rqlite
and rqlited
on 3 different machines.
Note: According to the documentation you need at least 3 nodes to test a fault tolerant cluster. In practice, to be fault tolerant, you need N/2 + 1 nodes up and running where N is the number of nodes in the cluster, to be fault tolerant.
Create initial leader
To create a cluster you must first launch a node that can act as the initial leader. Do this as follows on host1:
rqlited -node-id 1 -http-addr host1:4001 -raft-addr host1:4002 ~/node
Note: host1 needs to resolve to an IP reachable by the other nodes. You can also directly used an IP, which can be useful for running rqlite with a VPN.
Create subsequent node N
To join a second node to this leader, execute the following command on hostN:
rqlited -node-id 2 -http-addr hostN:4001 -raft-addr hostN:4002 -join http://host1:4001 ~/node
Note: hostN needs to resolve to an IP reachable by the other nodes. You can also directly used an IP, which can be useful for running rqlite with a VPN.
Testing the cluster!
on leader/host1
- make sure rqlited is running (see above)
- create some entries
rqlite -H host1 FIXME
on hostN
- make sure rqlited is running (see above)
- create some entries
rqlite -H host1 # YES it's host1! FIXME