- install Golang
- go build -o rdoc main.go
./rdoc --id 1 --cluster http://127.0.0.1:12379 --port 8080
# each rdoc process is a single raft instance
# id: node ID of this instance, id is incremental and starts from 1.
# cluster: address list of all the nodes in a cluster. In this example, the raft address for node 1 is http://127.0.0.1:12379, so this process will also listen on 12379 for raft request connection.
# port: document database service port.
Using goreman
goreman is a process manager, it can start multiple instances.
goreman start
This will bring up three rdoc instances.
# start three instances
./rdoc --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 8080
./rdoc --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 8081
./rdoc --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 8082
# this will start three rdoc instances
# the first instance have ID 1, raft service address:http://127.0.0.1:12379, and document database service port 8080;
# the second instance have ID 2, raft service address:http://127.0.0.1:22379, and document database service port 8081;
# the third instance have ID 3, raft service address:http://127.0.0.1:32379, and document database service port 8082;
All three instances can accept CRUD requests, you can use a HTTP proxy for load-balancing.
If you want to add a node to a running cluster, you have to:
- Call addnode API ;
- Start the new node.
./rdoc --id 4 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379,http://127.0.0.1:42379 --port 42380 --join
- Stop the node
- Call delnode API