1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Philip O'Toole 7eed859051 Update CHANGELOG 8 years ago
auth Update credential_store.go 8 years ago
cluster Merge pull request #286 from rqlite/fix_http_help 8 years ago
cmd Tweak join-related logging 8 years ago
db Unit test query of SQLite master table 8 years ago
disco Explicitly don't follow redirects 8 years ago
doc Update DISCOVERY.md 8 years ago
http Not all queries begin with SELECT so pull check 8 years ago
store Copy JSON peers decode functionality from Raft 8 years ago
system_test Tweak end-to-end quick script 8 years ago
tcp Simplify TCP mux testing 8 years ago
testdata/chinook Move chinook package to idiomatic testdata dir 8 years ago
.gitignore Correct .gitignore for new CLI 9 years ago
CHANGELOG.md Update CHANGELOG 8 years ago
CONTRIBUTING.md Update CONTRIBUTING.md 8 years ago
LICENSE Update license years 8 years ago
README.md Update README.md 8 years ago
Vagrantfile Move Vagrant box to ubuntu/xenial64 8 years ago
appveyor.yml Update appveyor.yml 8 years ago
circle.yml Actually install Go 1.7.1 8 years ago
doc.go Update doc.go 8 years ago
gofmt.sh Add script to check 'go fmt' status 9 years ago
package.sh Script easier to use when accepting token last 8 years ago
vagrant_setup.sh Vagrant now uses Go 1.7.1 8 years ago

README.md

Circle CI appveyor GoDoc Go Report Card Release

====== rqlite is a distributed relational database, which uses SQLite as its storage engine. rqlite uses Raft to achieve consensus across all the instances of the SQLite databases, ensuring that every change made to the system is made to a quorum of SQLite databases, or none at all. It also gracefully handles leader elections, and tolerates failures of machines, including the leader. rqlite is available for Linux, OSX, and Microsoft Windows.

Why?

rqlite gives you the functionality of a rock solid, fault-tolerant, replicated relational database, but with very easy installation, deployment, and operation. With it you've got a lightweight and reliable distributed relational data store. Think etcd or Consul, but with relational data modelling also available.

You could use rqlite as part of a larger system, as a central store for some critical relational data, without having to run a heavier solution like MySQL.

Key features

  • Very easy deployment, with no need to separately install SQLite.
  • Fully replicated production-grade SQL database.
  • [Production-grade] (https://github.com/hashicorp/raft) distributed consensus system.
  • An easy-to-use HTTP(S) API, including leader-redirection and bulk-update support. A CLI is also available.
  • Discovery Service support, allowing clusters to be dynamically created.
  • Basic auth security and user-level permissions.
  • Read consistency levels.
  • Transaction support.
  • Hot backups.

Quick Start

Full documentation available here.

The quickest way to get running on OSX and Linux is to download a pre-built release binary. You can find these binaries on the Github releases page. Once installed, you can start a single rqlite node like so:

rqlited ~/node.1

This single node automatically becomes the leader. You can pass -h to rqlited to list all configuration options.

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:

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

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.

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.

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 for more details.

Inserting records

Let's insert some records via the rqlite CLI, using standard SQLite commands. Once inserted, these records will be replicated across the cluster, in a durable and fault-tolerant manner. Your 3-node cluster can suffer the failure of a single node without any loss of functionality.

$ rqlite
127.0.0.1:4001> CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)
0 row affected (0.000668 sec)
127.0.0.1:4001> .schema
+-----------------------------------------------------------------------------+
| sql                                                                         |
+-----------------------------------------------------------------------------+
| CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)               |
+-----------------------------------------------------------------------------+
127.0.0.1:4001> INSERT INTO foo(name) VALUES("fiona")
1 row affected (0.000080 sec)
127.0.0.1:4001> SELECT * FROM foo
+----+-------+
| id | name  |
+----+-------+
| 1  | fiona |
+----+-------+

Data API

rqlite has a rich HTTP API, allowing full control over writing to, and querying from, rqlite. Check out the documentation for full details. There are also client libraries available.

Performance

rqlite replicates SQLite for fault-tolerance. It does not replicate it for performance. In fact performance is reduced somewhat due to the network round-trips.

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 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.

Does using an in-memory database put my data at risk?

No.

Since the Raft log is the authoritative store for all data, and it is written to disk, an in-memory database can be fully recreated on start-up. Using an in-memory database does not put your data at risk.

Limitations

  • Only SQL statements that are deterministic are safe to use with rqlite, because statements are committed to the Raft log before they are sent to each node. In other words, rqlite performs statement-based replication. For example, the following statement could result in different a SQLite database under each node:
INSERT INTO foo (n) VALUES(random());
  • Technically this is not supported, but you can directly read the SQLite under any node at anytime, assuming you run in "on-disk" mode. However there is no guarantee that the SQLite file reflects all the changes that have taken place on the cluster unless you are sure the host node itself has received and applied all changes.
  • In case it isn't obvious, rqlite does not replicate any changes made directly to any underlying SQLite files, when run in "on disk" mode. If you do change these files directly, you will cause rqlite to fail. Only modify the database via the HTTP API.
  • SQLite dot-commands such as .schema or .tables are not directly supported by the API, but the rqlite CLI supports some very similar functionality. This is because those commands are features of the sqlite3 command, not SQLite itself.

Status API

You can learn how check status and diagnostics here.

Backup and restore

Learn how to hot backup your rqlite cluster here. You can also load data directly from a SQLite dump file.

Security

You can learn about securing access, and restricting users' access, to rqlite here.

Projects using rqlite

If you are using rqlite in a project, please generate a pull request to add it to this list.

  • OpenMarket - A free, decentralized bitcoin-based marketplace.

Pronunciation?

How do I pronounce rqlite? For what it's worth I try to pronounce it "ree-qwell-lite". But it seems most people, including me, often pronouce it "R Q lite".