User:XenGi
From the project home page:
- rqlite is a lightweight, distributed relational database, which uses SQLite as its storage engine.
Installation
Install the rqliteAUR package.
Forming a cluster
Let's create a cluster with 3 nodes which have the IP addresses 10.0.0.1, 10.0.0.2 and 10.0.0.3.
On the first node, edit /etc/default/rqlite
:
RQLITED_ARGS="-http-addr 10.0.0.1:4001 -raft-addr 10.0.0.1:4002"
On the second node:
RQLITED_ARGS="-http-addr 10.0.0.2:4001 -raft-addr 10.0.0.2:4002 -join http://10.0.0.1:4001,http://10.0.0.3:4001"
On the third node:
RQLITED_ARGS="-http-addr 10.0.0.3:4001 -raft-addr 10.0.0.3:4002 -join http://10.0.0.1:4001,http://10.0.0.2:4001"
Now Start/enable the rqlite.service
on the first node. In the journal you should see something like that:
[rqlited] 2020/01/07 16:18:16 rqlited starting, version v5.0.0, commit dd61a7a221bc3f8b0841dc298cdccc4fe4a81c6b, branch master [rqlited] 2020/01/07 16:18:16 go1.13, target architecture is amd64, operating system target is linux [store] 2020/01/07 16:18:16 opening store with node ID 10.0.0.1:4002 [store] 2020/01/07 16:18:16 ensuring directory at /run/rqlite exists [store] 2020/01/07 16:18:16 SQLite in-memory database opened 2020-01-07T16:18:16.468+0100 [INFO] raft: Initial configuration (index=0): [] [store] 2020/01/07 16:18:16 bootstrap needed 2020-01-07T16:18:16.468+0100 [INFO] raft: Node at 10.0.0.1:4002 [Follower] entering Follower state (Leader: "") [rqlited] 2020/01/07 16:18:16 no join addresses set 2020-01-07T16:18:17.861+0100 [WARN] raft: Heartbeat timeout from "" reached, starting election 2020-01-07T16:18:17.861+0100 [INFO] raft: Node at 10.0.0.1:4002 [Candidate] entering Candidate state in term 2 2020-01-07T16:18:17.934+0100 [DEBUG] raft: Votes needed: 1 2020-01-07T16:18:17.935+0100 [DEBUG] raft: Vote granted from 10.0.0.1:4002 in term 2. Tally: 1 2020-01-07T16:18:17.935+0100 [INFO] raft: Election won. Tally: 1 2020-01-07T16:18:17.935+0100 [INFO] raft: Node at 10.0.0.1:4002 [Leader] entering Leader state [store] 2020/01/07 16:18:17 waiting for up to 2m0s for application of initial logs [http] 2020/01/07 16:18:18 service listening on 10.0.0.1:4001
Now you can add the other two nodes. In their journal it should look like this:
[rqlited] 2020/01/07 16:18:33 rqlited starting, version v5.0.0, commit dd61a7a221bc3f8b0841dc298cdccc4fe4a81c6b, branch master [rqlited] 2020/01/07 16:18:33 go1.13, target architecture is amd64, operating system target is linux [store] 2020/01/07 16:18:33 opening store with node ID 10.0.0.2:4002 [store] 2020/01/07 16:18:33 ensuring directory at /run/rqlite exists [store] 2020/01/07 16:18:33 SQLite in-memory database opened 2020-01-07T16:18:33.907+0100 [INFO] raft: Initial configuration (index=0): [] [store] 2020/01/07 16:18:33 no bootstrap needed [rqlited] 2020/01/07 16:18:33 join addresses are: http://10.0.0.3:4001 2020-01-07T16:18:33.908+0100 [INFO] raft: Node at 10.0.0.2:4002 [Follower] entering Follower state (Leader: "") 2020/01/07 16:18:33 [DEBUG] raft-net: 10.0.0.2:4002 accepted connection from: 10.0.0.1:59672 2020-01-07T16:18:33.922+0100 [WARN] raft: Failed to get previous log: 4 log not found (last: 0) [rqlited] 2020/01/07 16:18:33 successfully joined cluster at http://10.0.0.1:4001/join [store] 2020/01/07 16:18:34 waiting for up to 2m0s for application of initial logs 2020/01/07 16:18:34 [DEBUG] raft-net: 10.0.0.2:4002 accepted connection from: 10.0.0.1:59674 [http] 2020/01/07 16:18:34 service listening on 10.0.0.2:4001
When the 3 nodes formed a cluster you should edit the file /etc/default/rqlite
on the first node to include the others:
RQLITED_ARGS="-http-addr 10.0.0.1:4001 -raft-addr 10.0.0.1:4002 -join http://10.0.0.2:4001,http://10.0.0.3:4001"
After that restart the first node. Now also the first node will always try to reconnect to the others when restarted.