Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method to replicate sqlite database across multiple servers

I'm developing an application that works distributed, and I have a SQLite database that must be shared between distributed servers. If I'm in serverA, and change sqlite row, this change must be in the other servers instantly, but if a server were offline and then it came online, it must update all info equal other servers.

I'm trying to develop a HA service with small SQLite databases.

I'm thinking on something like MongoDB or ReThinkDB, due to replication works fine and I have got data independently server online I had.

There are a library or other SQL methodology to share data between servers?

Thanks in advance.

like image 782
ManuParra Avatar asked Apr 16 '13 09:04

ManuParra


People also ask

Does SQLite support replication?

Litestream is a standalone streaming replication tool for SQLite. It runs as a background process and safely replicates changes incrementally to another file or S3. Litestream only communicates with SQLite through the SQLite API so it will not corrupt your database.

Can SQLite be distributed?

Unlike most other SQL databases, SQLite does not have a separate server process. It is lightweight and contained in a single disk file. However, it does not support replication and thus does not provide fault tolerance for the data nodes. We use the idea of leveraging Raft algorithm to build a distributed SQL database.


2 Answers

I used the Raft consensus protocol to replicate my SQLite database. You can find the system here:

https://github.com/rqlite/rqlite

like image 91
Philip O'Toole Avatar answered Sep 18 '22 15:09

Philip O'Toole


Here are some options:

LiteReplica:

It supports master-slave replication for SQLite3 databases using a single master (writable node) and one or many replicas (read-only nodes).

If a device went offline and then it came online, the secondary/slave dbs are updated with the primary/master one incrementally.

LiteSync:

It implements multi-master replication so we can write to the db in any node, even when the device is off-line.

On both we open the database using a modified URI, like this:

   “file:/path/to/app.db?replica=master&bind=tcp://0.0.0.0:4444”

AergoLite:

Blockchain based, it has the highest level of security. Stores immutable relational data, secured by a distributed consensus with low resource usage.

Disclosure: I am the author of these solutions

like image 21
Bernardo Ramos Avatar answered Sep 20 '22 15:09

Bernardo Ramos