1
0
Fork 0

Move to clearer command-line options

master
Philip O'Toole 7 years ago
parent 1633f85585
commit ebfa38d726

@ -1,6 +1,7 @@
## 4.0.0 (unreleased)
The 4.0 codebase is currently compatible with the 3.x series and nodes can be upgraded without any special steps. However, this will not be the case when 4.0 is actually released, and upgrade instructions will be provided at that time.
**The 4.0 release has renamed command-line options relative to earlier releases.** This means that previous commands used to launch rqlited will not work. However the command-line changes are cosmetic, and each previous option maps 1-to-1 to a renamed option.
- [PR #308](https://github.com/rqlite/rqlite/pull/308): Move to clearer command-line options.
- [PR #307](https://github.com/rqlite/rqlite/pull/307): Support node-to-node encryption. Fixes [issue #93](https://github.com/rqlite/rqlite/issues/93).
## 3.14.0 (May 4th 2017)

@ -35,10 +35,10 @@ Alternatively you can pull the latest release via `docker pull rqlite/rqlite`. [
### Forming a cluster
While not strictly necessary to run rqlite, running multiple nodes means you'll have a fault-tolerant cluster. Start two more nodes, allowing the cluster to tolerate failure of a single node, like so:
```bash
rqlited -http localhost:4003 -raft localhost:4004 -join http://localhost:4001 ~/node.2
rqlited -http localhost:4005 -raft localhost:4006 -join http://localhost:4001 ~/node.3
rqlited -http-addr localhost:4003 -raft-addr localhost:4004 -join http://localhost:4001 ~/node.2
rqlited -http-addr localhost:4005 -raft-addr localhost:4006 -join http://localhost:4001 ~/node.3
```
_This demonstration shows all 3 nodes running on the same host. In reality you probably wouldn't do this, and then you wouldn't need to select different -http and -raft ports for each rqlite node._
_This demonstration shows all 3 nodes running on the same host. In reality you probably wouldn't do this, and then you wouldn't need to select different -http-addr and -raft-addr ports for each rqlite node._
With just these few steps you've now got a fault-tolerant, distributed relational database. For full details on creating and managing real clusters check out [this documentation](https://github.com/rqlite/rqlite/blob/master/doc/CLUSTER_MGMT.md).
@ -76,7 +76,7 @@ rqlite replicates SQLite for fault-tolerance. It does not replicate it for perfo
Depending on your machine and network, individual INSERT performance could be anything from 1 operation per second to more than 100 operations per second. However, by using transactions, throughput will increase significantly, often by 2 orders of magnitude. This speed-up is due to the way SQLite works. So for high throughput, execute as many operations as possible within a single transaction.
### In-memory databases
By default rqlite uses an [in-memory SQLite database](https://www.sqlite.org/inmemorydb.html) to maximise performance. In this mode no actual SQLite file is created and the entire database is stored in memory. If you wish rqlite to use an actual file-based SQLite database, pass `-ondisk` to rqlite on start-up.
By default rqlite uses an [in-memory SQLite database](https://www.sqlite.org/inmemorydb.html) to maximise performance. In this mode no actual SQLite file is created and the entire database is stored in memory. If you wish rqlite to use an actual file-based SQLite database, pass `-on-disk` to rqlite on start-up.
#### Does using an in-memory database put my data at risk?
No.

2
Vagrantfile vendored

@ -15,7 +15,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
port = 4001
(2..ENV['CLUSTER_SIZE'].to_i).each do |i|
port = port + 1
config.vm.provision :shell, :inline => "rqlited -join localhost:4001 -raft localhost:#{port} ~/node.#{i} &"
config.vm.provision :shell, :inline => "rqlited -join localhost:4001 -raft-addr localhost:#{port} ~/node.#{i} &"
end
end

@ -20,7 +20,7 @@ type argT struct {
Host string `cli:"H,host" usage:"rqlited host address" dft:"127.0.0.1"`
Port uint16 `cli:"p,port" usage:"rqlited host port" dft:"4001"`
Prefix string `cli:"P,prefix" usage:"rqlited HTTP URL prefix" dft:"/"`
Insecure bool `cli:"insecure" usage:"do not verify rqlited HTTPS certificate" dft:"false"`
Insecure bool `cli:"i,insecure" usage:"do not verify rqlited HTTPS certificate" dft:"false"`
}
func main() {

@ -95,32 +95,32 @@ const desc = `rqlite is a lightweight, distributed relational database, which us
storage engine. It provides an easy-to-use, fault-tolerant store for relational data.`
func init() {
flag.StringVar(&httpAddr, "http", "localhost:4001", "HTTP server bind address. For HTTPS, set X.509 cert and key")
flag.StringVar(&httpAdv, "httpadv", "", "Advertised HTTP address. If not set, same as HTTP server")
flag.StringVar(&x509Cert, "x509cert", "", "Path to X.509 certificate for HTTP endpoint")
flag.StringVar(&x509Key, "x509key", "", "Path to X.509 private key for certificate HTTP endpoint")
flag.BoolVar(&noVerify, "noverify", false, "Skip verification of remote HTTPS cert when joining cluster")
flag.BoolVar(&nodeEncrypt, "encrypt", false, "Enable node-to-node encryption")
flag.StringVar(&nodeX509Cert, "nodex509cert", "cert.pem", "Path to X.509 certificate for node-to-node encryption")
flag.StringVar(&nodeX509Key, "nodex509key", "key.pem", "Path to X.509 private key for node-to-node encryption")
flag.BoolVar(&noNodeVerify, "nonodeverify", false, "Skip verification of a remote node cert")
flag.StringVar(&httpAddr, "http-addr", "localhost:4001", "HTTP server bind address. For HTTPS, set X.509 cert and key")
flag.StringVar(&httpAdv, "http-adv-addr", "", "Advertised HTTP address. If not set, same as HTTP server")
flag.StringVar(&x509Cert, "http-cert", "", "Path to X.509 certificate for HTTP endpoint")
flag.StringVar(&x509Key, "http-key", "", "Path to X.509 private key for certificate HTTP endpoint")
flag.BoolVar(&noVerify, "http-no-verify", false, "Skip verification of remote HTTPS cert when joining cluster")
flag.BoolVar(&nodeEncrypt, "node-encrypt", false, "Enable node-to-node encryption")
flag.StringVar(&nodeX509Cert, "node-cert", "cert.pem", "Path to X.509 certificate for node-to-node encryption")
flag.StringVar(&nodeX509Key, "node-key", "key.pem", "Path to X.509 private key for node-to-node encryption")
flag.BoolVar(&noNodeVerify, "node-no-verify", false, "Skip verification of a remote node cert")
flag.StringVar(&authFile, "auth", "", "Path to authentication and authorization file. If not set, not enabled")
flag.StringVar(&raftAddr, "raft", "localhost:4002", "Raft communication bind address")
flag.StringVar(&raftAdv, "raftadv", "", "Advertised Raft communication address. If not set, same as Raft bind")
flag.StringVar(&raftAddr, "raft-addr", "localhost:4002", "Raft communication bind address")
flag.StringVar(&raftAdv, "raft-adv-addr", "", "Advertised Raft communication address. If not set, same as Raft bind")
flag.StringVar(&joinAddr, "join", "", "Comma-delimited list of nodes, through which a cluster can be joined (proto://host:port)")
flag.StringVar(&discoURL, "disco", "http://discovery.rqlite.com", "Set Discovery Service URL")
flag.StringVar(&discoID, "discoid", "", "Set Discovery ID. If not set, Discovery Service not used")
flag.StringVar(&discoURL, "disco-url", "http://discovery.rqlite.com", "Set Discovery Service URL")
flag.StringVar(&discoID, "disco-id", "", "Set Discovery ID. If not set, Discovery Service not used")
flag.BoolVar(&expvar, "expvar", true, "Serve expvar data on HTTP server")
flag.BoolVar(&pprofEnabled, "pprof", true, "Serve pprof data on HTTP server")
flag.StringVar(&dsn, "dsn", "", `SQLite DSN parameters. E.g. "cache=shared&mode=memory"`)
flag.BoolVar(&onDisk, "ondisk", false, "Use an on-disk SQLite database")
flag.BoolVar(&onDisk, "on-disk", false, "Use an on-disk SQLite database")
flag.BoolVar(&showVersion, "version", false, "Show version information and exit")
flag.StringVar(&raftHeartbeatTimeout, "rafttimeout", "1s", "Raft heartbeat timeout")
flag.StringVar(&raftApplyTimeout, "raftapplytimeout", "10s", "Raft apply timeout")
flag.StringVar(&raftOpenTimeout, "raftopentimeout", "120s", "Time for initial Raft logs to be applied. Use 0s duration to skip wait")
flag.Uint64Var(&raftSnapThreshold, "raftsnap", 8192, "Number of outstanding log entries that trigger snapshot")
flag.StringVar(&cpuProfile, "cpuprofile", "", "Path to file for CPU profiling information")
flag.StringVar(&memProfile, "memprofile", "", "Path to file for memory profiling information")
flag.StringVar(&raftHeartbeatTimeout, "raft-timeout", "1s", "Raft heartbeat timeout")
flag.StringVar(&raftApplyTimeout, "raft-apply-timeout", "10s", "Raft apply timeout")
flag.StringVar(&raftOpenTimeout, "raft-open-timeout", "120s", "Time for initial Raft logs to be applied. Use 0s duration to skip wait")
flag.Uint64Var(&raftSnapThreshold, "raft-snap", 8192, "Number of outstanding log entries that trigger snapshot")
flag.StringVar(&cpuProfile, "cpu-profile", "", "Path to file for CPU profiling information")
flag.StringVar(&memProfile, "mem-profile", "", "Path to file for memory profiling information")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "\n%s\n\n", desc)
fmt.Fprintf(os.Stderr, "Usage: %s [arguments] <data directory>\n", name)

@ -16,26 +16,26 @@ Let's say you have 3 host machines, _host1_, _host2_, and _host3_, and that each
To create a cluster you must first launch a node that can act as the initial leader. Do this as follows on _host1_:
```bash
host1:$ rqlited -http host1:4001 -raft host1:4002 ~/node
host1:$ rqlited -http-addr host1:4001 -raft-addr host1:4002 ~/node
```
With this command a single node is started, listening for API requests on port 4001 and listening on port 4002 for intra-cluster communication and cluster-join requests from other nodes. This node stores its state at `~/node`.
To join a second node to this leader, execute the following command on _host2_:
```bash
host2:$ rqlited -http host2:4001 -raft host2:4002 -join http://host1:4001 ~/node
host2:$ rqlited -http-addr host2:4001 -raft-addr host2:4002 -join http://host1:4001 ~/node
```
_If a node receives a join request, and that node is not actually the leader of the cluster, the receiving node will automatically redirect the requesting node to the leader node. As a result a node can actually join a cluster by contacting any node in the cluster. You can also specify multiple join addresses, and the node will try each address until joining is successful._
Once executed you now have a cluster of two nodes. Of course, for fault-tolerance you need a 3-node cluster, so launch a third node like so on _host3_:
```bash
host3:$ rqlited -http host3:4001 -raft host3:4002 -join http://host1:4001 ~/node
host3:$ rqlited -http-addr host3:4001 -raft-addr host3:4002 -join http://host1:4001 ~/node
```
_When restarting a node, there is no further need to pass `-join`. It will be ignored if a node is already a member of a cluster._
You've now got a fault-tolerant, distributed, relational database. It can tolerate the failure of any node, even the leader, and remain operational.
## Listening on all interfaces
You can pass `0.0.0.0` to both `-http` and `-raft` if you wish a node to listen on all interfaces. You must still pass an explicit network address to `-join` however.
You can pass `0.0.0.0` to both `-http-addr` and `-raft-addr` if you wish a node to listen on all interfaces. You must still pass an explicit network address to `-join` however.
## Discovery Service
There is also a rqlite _Discovery Service_, allowing nodes to automatically connect and form a cluster. This can be much more convenient, allowing clusters to be dynamically created. Check out [the documentation](https://github.com/rqlite/rqlite/blob/master/doc/DISCOVERY.md) for more details.

@ -29,12 +29,12 @@ In the example above `809d9ba6-f70b-11e6-9a5a-92819c00729a` was returned by the
This ID is then provided to each node on start-up.
```shell
rqlited --discoid 809d9ba6-f70b-11e6-9a5a-92819c00729a
rqlited -disco-id 809d9ba6-f70b-11e6-9a5a-92819c00729a
```
When any node registers using the ID, it is returned the current list of nodes that have registered using that ID. If the nodes is the first node to access the service using the ID, it will receive a list that contains just itself -- and will subsequently elect itself leader. Subsequent nodes will then receive a list with more than 1 entry. These nodes will use one of the join addresses in the list to join the cluster.
### Controlling the registered join address
By default each node registers the address passed in via the `--http` option. However if you instead set `--httpadv` when starting a node, the node will instead register that address.
By default each node registers the address passed in via the `-http-addr` option. However if you instead set `-http-adv-addr` when starting a node, the node will instead register that address.
## Caveats
If a node is already part of a cluster, addresses returned by the Discovery Service are ignored.
@ -52,11 +52,11 @@ $ curl -XPOST -L -w "\n" 'http://discovery.rqlite.com/'
```
To automatically form a 3-node cluster simply pass the ID to 3 nodes, all of which can be started simultaneously via the following commands:
```shell
$ rqlited --discoid b3da7185-725f-461c-b7a4-13f185bd5007 ~/node.1
$ rqlited -http localhost:4003 -raft localhost:4004 --discoid b3da7185-725f-461c-b7a4-13f185bd5007 ~/node.2
$ rqlited -http localhost:4005 -raft localhost:4006 --discoid b3da7185-725f-461c-b7a4-13f185bd5007 ~/node.3
$ rqlited -disco-id b3da7185-725f-461c-b7a4-13f185bd5007 ~/node.1
$ rqlited -http-addr localhost:4003 -raft-addr localhost:4004 -disco-id b3da7185-725f-461c-b7a4-13f185bd5007 ~/node.2
$ rqlited -http-addr localhost:4005 -raft-addr localhost:4006 -disco-id b3da7185-725f-461c-b7a4-13f185bd5007 ~/node.3
```
_This demonstration shows all 3 nodes running on the same host. In reality you probably wouldn't do this, and then you wouldn't need to select different -http and -raft ports for each rqlite node._
_This demonstration shows all 3 nodes running on the same host. In reality you probably wouldn't do this, and then you wouldn't need to select different -http-addr and -raft-addr ports for each rqlite node._
## Removing registered addresses
If you need to remove an address from the list of registered addresses, perhaps because a node has permanently left a cluster, you can do this via the following command:

@ -19,7 +19,7 @@ AWS EC2 [Security Groups](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/usi
rqlite supports HTTPS access, ensuring that all communication between clients and a cluster is encrypted.
## Node-to-node encryption
rqlite supports encryption of all inter-node traffic. To enable this, pass `-encrypt` to `rqlited`. Each node must also be supplied with the relevant SSL certificate and corresponding private key, in X.509 format. Note that every node in a cluster must operate with encryption enabled, or none at all.
rqlite supports encryption of all inter-node traffic. To enable this, pass `-node-encrypt` to `rqlited`. Each node must also be supplied with the relevant SSL certificate and corresponding private key, in X.509 format. Note that every node in a cluster must operate with encryption enabled, or none at all.
One way to generate the necessary (possibly self-signed) resources is via [openssl](https://www.openssl.org/):
```
@ -65,15 +65,15 @@ This configuration also sets permissions for both users. _bob_ has permission to
## Secure cluster example
Starting a node with HTTPS enabled, node-to-node encryption, and with the above configuration file. It is assumed the HTTPS X.509 certificate and key are at the paths `server.crt` and `key.pem` respectively, and the node-to-node certificate and key are at `node.crt` and `node-key.pem`
```bash
rqlited -auth config.json -x509cert server.crt -x509key key.pem \
-encrypt -nodex509cert node.crt -nodex509key node-key.pem -nonodeverify \
rqlited -auth config.json -http-cert server.crt -http-key key.pem \
-node-encrypt -node-cert node.crt -node-key node-key.pem -node-no-verify \
~/node.1
```
Bringing up a second node, joining it to the first node. This allows you to block nodes from joining a cluster, unless those nodes supply a password.
Bringing up a second node on the same host, joining it to the first node. This allows you to block nodes from joining a cluster, unless those nodes supply a password.
```bash
rqlited -auth config.json -http localhost:4003 -x509cert server.crt \
-x509key key.pem -raft :4004 -join https://bob:secret1@localhost:4001 \
-encrypt -nodex509cert node.crt -nodex509key node-key.pem -nonodeverify \
rqlited -auth config.json -http-addr localhost:4003 -http-cert server.crt \
-http-key key.pem -raft-addr :4004 -join https://bob:secret1@localhost:4001 \
-node-encrypt -node-cert node.crt -node-key node-key.pem -no-node-verify \
~/node.2
```
Querying the node, as user _mary_.

@ -5,11 +5,11 @@ TMP_DATA=`mktemp`
rm $GOPATH/bin/*
go install ./...
$GOPATH/bin/rqlited -http localhost:4001 -raft localhost:4002 ${TMP_DATA}_1 &
$GOPATH/bin/rqlited -http-addr localhost:4001 -raft-addr localhost:4002 ${TMP_DATA}_1 &
sleep 5
$GOPATH/bin/rqlited -http localhost:4003 -raft localhost:4004 -join http://localhost:4001 ${TMP_DATA}_2 &
$GOPATH/bin/rqlited -http-addr localhost:4003 -raft-addr localhost:4004 -join http://localhost:4001 ${TMP_DATA}_2 &
sleep 5
$GOPATH/bin/rqlited -http localhost:4005 -raft localhost:4006 -join http://localhost:4001 ${TMP_DATA}_3 &
$GOPATH/bin/rqlited -http-addr localhost:4005 -raft-addr localhost:4006 -join http://localhost:4001 ${TMP_DATA}_3 &
sleep 5
wait

@ -7,11 +7,11 @@ go install ./...
openssl req -x509 -nodes -newkey rsa:4096 -keyout ${TMP_DATA}_key.pem -out ${TMP_DATA}_cert.pem -days 365
$GOPATH/bin/rqlited -http localhost:4001 -raft localhost:4002 -nodex509cert ${TMP_DATA}_cert.pem -nodex509key ${TMP_DATA}_key.pem -nonodeverify -encrypt ${TMP_DATA}_1 &
$GOPATH/bin/rqlited -http-addr localhost:4001 -raft-addr localhost:4002 -node-cert ${TMP_DATA}_cert.pem -node-key ${TMP_DATA}_key.pem -node-no-verify -node-encrypt ${TMP_DATA}_1 &
sleep 5
$GOPATH/bin/rqlited -http localhost:4003 -raft localhost:4004 -join http://localhost:4001 -nodex509cert ${TMP_DATA}_cert.pem -nodex509key ${TMP_DATA}_key.pem -nonodeverify -encrypt ${TMP_DATA}_2 &
$GOPATH/bin/rqlited -http-addr localhost:4003 -raft-addr localhost:4004 -join http://localhost:4001 -node-cert ${TMP_DATA}_cert.pem -node-key ${TMP_DATA}_key.pem -node-no-verify -node-encrypt ${TMP_DATA}_2 &
sleep 5
$GOPATH/bin/rqlited -http localhost:4005 -raft localhost:4006 -join http://localhost:4001 -nodex509cert ${TMP_DATA}_cert.pem -nodex509key ${TMP_DATA}_key.pem -nonodeverify -encrypt ${TMP_DATA}_3 &
$GOPATH/bin/rqlited -http-addr localhost:4005 -raft-addr localhost:4006 -join http://localhost:4001 -node-cert ${TMP_DATA}_cert.pem -node-key ${TMP_DATA}_key.pem -node-no-verify -node-encrypt ${TMP_DATA}_3 &
sleep 5
wait

Loading…
Cancel
Save