Dqlite

可嵌入的、可复制的和容错的 SQL 引擎。「Embeddable, replicated and fault tolerant SQL engine.」

Github星跟踪图

dqlite

dqlite 是一个 C 语言库,它实现了一个可嵌入和复制的 SQL 数据库引擎,具有高可用性和自动故障转移。

首字母缩写 "dqlite" 代表 "distributed SQLite(分布式 SQLite)",意味着 dqlite 用网络协议扩展了 SQLite,可以将你的应用程序的各个实例连接在一起,让它们作为一个高可用的集群,而不依赖外部数据库。

设计亮点

  • 使用 libuv 作为事件循环的异步单线程实现。
  • 针对 SQLite 基元和数据类型优化的自定义线程协议。
  • 基于 Raft 算法的数据复制及其高效的 C-raft 实现。

许可证

dqlite 库是在 LGPLv3 的一个稍微修改过的版本下发布的,其中包含一个版权例外,允许用户在他们的项目中静态链接库代码,并在他们自己的条款下发布最终作品。请看完整的 许可证 文本。

试试吧

看到 dqlite 运行的最简单的方法是使用 Go dqlite 绑定的演示程序。请看该项目中的 相关文档

媒体

在 FOSDEM 2020 上有一个关于 dqlite 的演讲,你可以在 这里 观看。

Wire 协议

如果你想写一个客户端,请参考 wire 协议 的文档。

安装

如果你使用的是基于 Debian 的系统,你可以从 dqlite 的稳定 PPA 中获得最新的稳定版本。

sudo add-apt-repository ppa:dqlite/stable
sudo apt-get update
sudo apt-get install libdqlite-dev

构建

要从源代码构建 libdqlite,你需要

  • 一个相当新的 libuv 版本(v1.8.0 或以上)。
  • 一个合理的最新版本的 sqlite3-dev
  • 一个 C-raft Raft 库的构建。

你的发行版应该已经为你提供了一个预建的 libuv 共享库和 libsqlite3-dev。

要建立 raft 库。

git clone https://github.com/canonical/raft.git
cd raft
autoreconf -i
./configure

构建

sudo make install
cd .

安装了所有必需的库之后,为了构建 dqlite 共享库本身,您可以运行:

autoreconf -i
./configure
make
sudo make install


主要指标

概览
名称与所有者canonical/dqlite
主编程语言C
编程语言Emacs Lisp (语言数: 7)
平台Linux
许可证Other
所有者活动
创建于2017-05-24 19:35:52
推送于2025-04-24 15:58:17
最后一次提交2025-03-10 11:27:26
发布数56
最新版本名称v1.17.2 (发布于 )
第一版名称v0.0.1 (发布于 )
用户参与
星数4k
关注者数72
派生数231
提交数1.9k
已启用问题?
问题数209
打开的问题数57
拉请求数465
打开的拉请求数10
关闭的拉请求数45
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

dqlite Build Status codecov

dqlite is a C library that implements an embeddable and replicated SQL database
engine with high-availability and automatic failover.

The acronym "dqlite" stands for "distributed SQLite", meaning that dqlite extends
SQLite with a network protocol that can connect together
various instances of your application and have them act as a highly-available
cluster, with no dependency on external databases.

Design higlights

  • Asynchronous single-threaded implementation using libuv
    as event loop.
  • Custom wire protocol optimized for SQLite primitives and data types.
  • Data replication based on the Raft algorithm and its
    efficient C-raft implementation.

Licence

The dqlite library is released under a slightly modified version of LGPLv3, that
includes a copyright exception letting users to statically link the library code
in their project and release the final work under their own terms. See the full
license text.

Try it

The simplest way to see dqlite in action is to use the demo program that comes
with the Go dqlite bindings. Please see the relevant
documentation
in that project.

Wire protocol

If you wish to write a client, please refer to the wire protocol
documentation.

Install

If you are on a Debian-based system, you can the latest stable release from
dqlite's stable PPA:

sudo add-apt-repository ppa:dqlite/stable
sudo apt-get update
sudo apt-get install libdqlite-dev

Build

To build libdqlite from source you'll need:

Your distribution should already provide you a pre-built libuv shared
library.

To build the other libraries:

git clone --depth 100 https://github.com/canonical/sqlite.git
cd sqlite
./configure --enable-replication
make
sudo make install
cd ..
git clone https://github.com/canonical/libco.git
cd libco
make
sudo make install
cd ..
git clone https://github.com/canonical/raft.git
cd raft
autoreconf -i
./configure
make
sudo make install
cd ..

Once all required libraries are installed, to in order to build the dqlite
shared library itself you can run:

autoreconf -i
./configure
make
sudo make install