ha

command module
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

README ΒΆ

ha

License LiberaPay receives patrons

Highly available SQLite cluster

Powered by an embedded NATS JetStream server.

Features

  • πŸ”Œ Connect using HTTP API, gRPC API, database/sql go driver, JDBC driver, MySQL or PostgreSQL Wire Protocol
  • πŸ” Replicate data using embedded or external NATS server
  • πŸ“ Create live local read/write replicas with go-ha database/sql driver
  • πŸ“š Create live local read replicas with ha-sync SQLite extension
  • πŸ”„ Supports Change Data Capture (CDC)
  • βš™οΈ Configure a leader-based or leaderless cluster (with custom strategies for resolving replication data conflicts)
  • πŸ“š Execute cross-shard queries sing SQL hint /*+ db=DSN */ using regexp
  • πŸ“– Full documentation: https://litesql.github.io/ha/

πŸš€ Getting Started

Download and install the latest release

1. Start the first ha instance
mkdir db1
ha -n node1 "file:db1/mydatabase.db"

This command launches:

  • An embedded NATS server on port 4222
  • A MySQL Wire Protocol compatible server on port 3306
  • A PostgreSQL Wire Protocol compatible server on port 5432
  • A gRPC server on port 5001
  • An HTTP API server on port 8080
2. Start a second ha instance
mkdir db2
ha -n node2 -p 8081 --nats-port 0 --grpc-port 0 --pg-port 5433 --mysql-port 3307 --replication-url nats://localhost:4222 "file:db2/mydatabase.db"

This command starts:

  • A PostgreSQL Wire Protocol server on port 5433
  • A MySQL Wire Protocol server on port 3307
  • An HTTP API server on port 8081.

It connects to the previously launched embedded NATS server for replication.

3. Connect using a PostgreSQL client
PGPASSWORD=ha psql -h localhost -U ha

Create and populate a table:

CREATE TABLE users(ID INTEGER PRIMARY KEY, name TEXT);
INSERT INTO users(name) VALUES('HA user');
4. Verify replication on the second instance
PGPASSWORD=ha psql -h localhost -U ha -p 5433
SELECT * FROM users;
 ID |  name   
----+---------
 1  | HA user

Using a mysql client:

mysql -h localhost --port 3307 -u ha

MySQL [(none)]> show databases;
+-----------------------+
| Database              |
+-----------------------+
|ha.db                  |
+-----------------------+
1 row in set (0,000 sec)

MySQL [(none)]> use ha.db

MySQL [ha.db]> select * from users;
+----+---------+
| ID | name    |
+----+---------+
|  1 | HA user |
+----+---------+
1 row in set (0,000 sec)
5. Please refer to the complete documentation for the HTTP API

HTTP API

πŸ› οΈ License & Contributions

This project is open-source. Contributions, issues, and feature requests are welcome via GitHub.

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL