Powered by an embedded NATS JetStream server.
- 🔌 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/
Download and install the latest release
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
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.
PGPASSWORD=ha psql -h localhost -U haCreate and populate a table:
CREATE TABLE users(ID INTEGER PRIMARY KEY, name TEXT);
INSERT INTO users(name) VALUES('HA user');PGPASSWORD=ha psql -h localhost -U ha -p 5433SELECT * 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)This project is open-source. Contributions, issues, and feature requests are welcome via GitHub.
