Skills2026年4月16日·1 分钟阅读

rqlite — Distributed Database Built on SQLite & Raft

Lightweight distributed relational database that replicates SQLite across nodes using the Raft consensus protocol.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
rqlite Raft SQLite
先审查命令
npx -y tokrepo@latest install 44ddef49-3931-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

TL;DR
rqlite replicates SQLite across nodes with Raft consensus for fault-tolerant distributed SQL.
§01

What it is

rqlite turns the battle-tested SQLite engine into a fault-tolerant distributed database. Each node wraps SQLite with the Raft consensus protocol, replicating writes to a cluster of 3, 5, or 7 nodes. It serves SQL over a simple HTTP/JSON API plus a native command-line shell.

rqlite is ideal when you want relational guarantees and easy operations without the complexity of running PostgreSQL or MySQL clusters. It ships as a tiny single-binary with no external dependencies.

§02

How it saves time or tokens

rqlite provides distributed SQL without the operational complexity of traditional database clusters. Starting a cluster takes three commands. Adding nodes requires a single join command. There is no external dependency (no ZooKeeper, no etcd). The HTTP/JSON API works with any language that can make HTTP requests, eliminating the need for database-specific drivers. Read consistency levels (none, weak, strong, linearizable) let you trade consistency for performance per request.

§03

How to use

  1. Start a 3-node cluster:
rqlited -node-id 1 -http-addr localhost:4001 \
  -raft-addr localhost:4002 ~/node1 &
rqlited -node-id 2 -http-addr localhost:4003 \
  -raft-addr localhost:4004 -join http://localhost:4001 ~/node2 &
rqlited -node-id 3 -http-addr localhost:4005 \
  -raft-addr localhost:4006 -join http://localhost:4001 ~/node3 &
  1. Write and read over HTTP:
curl -XPOST localhost:4001/db/execute \
  -d '[["CREATE TABLE foo (id INTEGER PRIMARY KEY, name TEXT)"]]'
curl -XPOST localhost:4001/db/execute \
  -d '[["INSERT INTO foo(name) VALUES(?)", "bar"]]'
curl -G localhost:4001/db/query \
  --data-urlencode 'q=SELECT * FROM foo'
  1. Check cluster status:
curl localhost:4001/status?pretty
§04

Example

Using rqlite with different read consistency levels:

# No consistency check (fastest, may read stale data)
curl -G localhost:4001/db/query \
  --data-urlencode 'q=SELECT * FROM foo' \
  --data-urlencode 'level=none'

# Weak consistency (confirms leader, no log check)
curl -G localhost:4001/db/query \
  --data-urlencode 'q=SELECT * FROM foo' \
  --data-urlencode 'level=weak'

# Strong consistency (verifies with Raft quorum)
curl -G localhost:4001/db/query \
  --data-urlencode 'q=SELECT * FROM foo' \
  --data-urlencode 'level=strong'
§05

Related on TokRepo

§06

Common pitfalls

  • Running a single-node rqlite cluster in production provides no fault tolerance. Deploy at least 3 nodes for automatic leader election and failover.
  • rqlite is not designed for high-throughput write workloads. Raft consensus adds latency to every write. Use it for configuration stores, metadata, and low-to-moderate write volumes.
  • SQLite limitations apply: no concurrent writers per node, limited data types, no stored procedures. rqlite inherits all SQLite constraints.

常见问题

What is Raft consensus?+

Raft is a consensus algorithm that ensures all nodes in a cluster agree on the same data. One node is elected leader, and writes are replicated to a majority of nodes before being committed. If the leader fails, a new leader is elected automatically.

How does rqlite differ from SQLite?+

SQLite is a single-file embedded database. rqlite wraps SQLite with Raft consensus to replicate data across multiple nodes, providing fault tolerance and a network-accessible HTTP API. rqlite adds distribution; SQLite provides the storage engine.

Can I use SQL drivers with rqlite?+

rqlite uses an HTTP/JSON API rather than the MySQL or PostgreSQL wire protocols. There are client libraries for Go, Python, and JavaScript that wrap the HTTP API. Standard SQL drivers for other databases will not work.

What consistency levels does rqlite support?+

rqlite offers four read consistency levels: none (fastest, may be stale), weak (confirms current leader), strong (Raft quorum verification), and linearizable (strongest, single-value semantics). Choose per query based on your requirements.

How many nodes should I run?+

Run an odd number of nodes (3, 5, or 7). A 3-node cluster tolerates 1 failure. A 5-node cluster tolerates 2. More nodes increase read capacity but add write latency due to Raft replication.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产