ManuParra
ManuParra

Reputation: 1531

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?

Upvotes: 47

Views: 56785

Answers (5)

guettli
guettli

Reputation: 27796

Marmot looks good:

https://github.com/maxpert/marmot

From their docs:

What & Why?

Marmot is a distributed SQLite replicator with leaderless, and eventual consistency. It allows you to build a robust replication between your nodes by building on top of fault-tolerant NATS Jetstream. This means if you are running a read heavy website based on SQLite, you should be easily able to scale it out by adding more SQLite replicated nodes. SQLite is probably the most ubiquitous DB that exists almost everywhere, Marmot aims to make it even more ubiquitous for server side applications by building a replication layer on top.

Upvotes: 1

Bernardo Ramos
Bernardo Ramos

Reputation: 4577

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

Upvotes: 11

Philip O'Toole
Philip O'Toole

Reputation: 286

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

https://github.com/rqlite/rqlite

Upvotes: 27

jonneve
jonneve

Reputation: 585

You can also use CopyCat, which support SQLite as well as a few other database types.

Upvotes: 1

Eric Long
Eric Long

Reputation: 926

You can synchronize SQLite databases by embedding SymmetricDS in your application. It supports occasionally connected clients, so it will capture changes and sync them when a server comes online. It supports several different database platforms and can be used as a library or as a standalone service.

Upvotes: 6

Related Questions