Skip to content

Commit 7d02fde

Browse files
walterwanderleyCopilot
andcommitted
docs review
Co-authored-by: Copilot <copilot@github.com>
1 parent 6d3f109 commit 7d02fde

17 files changed

Lines changed: 6889 additions & 169 deletions

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ HA is a highly available SQLite cluster powered by an embedded NATS JetStream se
2828
- 📝 **Read/Write Replicas**: Create live local read/write replicas with [go-ha database/sql driver](https://github.com/litesql/go-ha)
2929
- 📚 **Read Replicas**: Create live local read replicas with [ha-sync SQLite extension](https://github.com/litesql/ha-sync)
3030
- 🔄 **Change Data Capture (CDC)**: Supports CDC for real-time data streaming
31+
- 🔌 **Proxy**: Proxy and replicate PostgreSQL or MySQL databases to the edge
3132
- ⚙️ **Cluster Modes**: Configure leader-based or leaderless clusters with custom conflict resolution strategies
3233
- 📚 **Cross-Shard Queries**: Execute queries across shards using SQL hints like `/*+ db=DSN */`
3334
- 🔄 **Transaction Undo**: Supports undo operations on committed transactions, allowing rollback to previous states
@@ -182,6 +183,20 @@ PGPASSWORD=ha psql -h localhost -U ha -p 5432
182183
mysql -h localhost --port 3306 -u ha
183184
```
184185

186+
## Proxy and Replicate Other Databases
187+
188+
HA can proxy connections to PostgreSQL and MySQL databases, replicating their data to achieve high availability and enable faster queries.
189+
190+
![HA Proxy Architecture](ha_proxy.png)
191+
192+
### Proxy and Replicate PostgreSQL
193+
194+
[PostgreSQL Example](https://github.com/litesql/ha/tree/main/examples/proxy-postgresql)
195+
196+
### Proxy and Replicate MySQL
197+
198+
[MySQL Example](https://github.com/litesql/ha/tree/main/examples/proxy-mysql)
199+
185200
## API Documentation
186201

187202
- **HTTP API**: [https://litesql.github.io/ha/#5](https://litesql.github.io/ha/#5)

docker-compose-leaderless.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.

docker-compose.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

docs/index.markdown

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ ghcr.io/litesql/ha:latest
7373
```
7474
#### Cluster example
7575

76-
- [Docker compose cluster](https://github.com/litesql/ha/blob/main/docker-compose.yml) example
76+
- [Docker compose cluster](https://github.com/litesql/ha/blob/main/examples/leader-based/docker-compose.yml) example
7777

7878
```sh
79+
cd examples/leader-based
7980
docker compose up
8081
```
8182

@@ -506,7 +507,14 @@ DDL commands (such as CREATE, ALTER, and DROP) are not affected by undo operatio
506507
| --leader-static | HA_LEADER_STATIC | | Address of a static leader. This will disable the leader election |
507508
| --mysql-port| HA_MYSQL_PORT| | Port to MySQL Wire Protocol Server |
508509
| --mysql-user| HA_MYSQL_USER| ha | MySQL Auth user |
509-
| --mysql-pass| HA_MYSQL_PASS| | MySQL Auth password |
510+
| --mysql-pass| HA_MYSQL_PASS| | MySQL Auth password |
511+
| --mysql-proxied | HA_MYSQL_PROXIED | | DSN of a source MySQL database to replicate into the local HA instance |
512+
| --mysql-include | HA_MYSQL_INCLUDE | `^db.*` | Regexp to include tables from the proxied MySQL database replication; empty means include all |
513+
| --mysql-exclude | HA_MYSQL_EXCLUDE | | Regexp to exclude tables from the proxied MySQL database replication |
514+
| --mysql-dump-bin| HA_MYSQL_DUMP_BIN | | Filesystem path to the mysqldump executable used for proxied MySQL import. Example: /usr/bin/mysqldump |
515+
| --mysql-dump-db | HA_MYSQL_DUMP_DB | | Database name used for mysqldump when importing from the proxied MySQL source |
516+
| --mysql-dump-include | HA_MYSQL_DUMP_INCLUDE | |Table filter to pass to mysqldump during proxied MySQL import |
517+
| --mysql-proxy-id | HA_MYSQL_PROXY_ID | sqlite-ha | Identifier for this proxied MySQL connection, used in replication metadata |
510518
| --nats-logs | HA_NATS_LOGS | false | Enable embedded NATS Server logging |
511519
| --nats-port | HA_NATS_PORT | 4222 | Embedded NATS server port (0 to disable) |
512520
| --nats-store-dir | HA_NATS_STORE_DIR | /tmp/nats | Embedded NATS server store directory |
@@ -518,6 +526,12 @@ DDL commands (such as CREATE, ALTER, and DROP) are not affected by undo operatio
518526
| --pg-pass | HA_PG_PASS | ha | PostgreSQL Auth password |
519527
| --pg-cert | HA_PG_CERT | | Path to PostgreSQL TLS certificate file |
520528
| --pg-key | HA_PG_KEY | | Path to PostgreSQL TLS key file |
529+
| --pg-proxied | HA_PG_PROXIED | |DSN of the source PostgreSQL database to replicate from and proxy to |
530+
| --pg-publication | HA_PG_PUBLICATION | ha_publication | Name of the publication in the source PostgreSQL database for logical replication (used only when --pg-proxied is specified) |
531+
| --pg-slot | HA_PG_SLOT | ha_slot | Name of the replication slot to create in the source PostgreSQL database (used only when --pg-proxied is specified) |
532+
| --proxy-local | HA_PROXY_LOCAL | ha.db | Path to the local SQLite database file that proxies the source database (used only when --pg-proxied or --mysql-proxied is set) |
533+
| --proxy-use-schema | HA_PROXY_USE_SCHEMA | false | Create local tables using the schema from the source database (used only when --pg-proxied or --mysql-proxied is set) |
534+
| --proxy-disable-redirect | HA_PROXY_DISABLE_REDIRECT | false | Disable redirecting queries to the source database; all queries will run on the local HA SQLite database (used only when --pg-proxied or --mysql-proxied is set) |
521535
| --concurrent-queries | HA_CONCURRENT_QUERIES | 50 | Number of concurrent queries (DB pool max) |
522536
| --extensions | HA_EXTENSIONS | | Comma-separated list of SQLite extensions path to load |
523537
| --async-replication | HA_ASYNC_REPLICATION | false | Enables asynchronous replication message publishing |

examples/leader-based/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
node1:
33
image: ghcr.io/litesql/ha:latest
44
volumes:
5-
- ./testdata:/etc/nats
5+
- ./conf:/etc/nats
66
- node1_data:/data
77
ports:
88
- "3306:3306"
@@ -25,7 +25,7 @@ services:
2525
node2:
2626
image: ghcr.io/litesql/ha:latest
2727
volumes:
28-
- ./testdata:/etc/nats
28+
- ./conf:/etc/nats
2929
- node2_data:/data
3030
ports:
3131
- "3307:3306"
@@ -47,7 +47,7 @@ services:
4747
node3:
4848
image: ghcr.io/litesql/ha:latest
4949
volumes:
50-
- ./testdata:/etc/nats
50+
- ./conf:/etc/nats
5151
- node3_data:/data
5252
ports:
5353
- "3308:3306"

examples/leaderless/conf/node1.cfg

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server_name=node1
2+
listen=4222
3+
4+
accounts: {
5+
$SYS: {
6+
users: [{user: sys, password: sys}]
7+
}
8+
}
9+
10+
jetstream {
11+
store_dir=/data/nats/n1
12+
}
13+
14+
cluster {
15+
name: HA
16+
listen: 0.0.0.0:6222
17+
routes: [
18+
nats-route://node2:6222
19+
nats-route://node3:6222
20+
]
21+
}

examples/leaderless/conf/node2.cfg

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server_name=node2
2+
listen=4222
3+
4+
accounts: {
5+
$SYS: {
6+
users: [{user: sys, password: sys}]
7+
}
8+
}
9+
10+
jetstream {
11+
store_dir=/data/nats/n2
12+
}
13+
14+
cluster {
15+
name: HA
16+
listen: 0.0.0.0:6222
17+
routes: [
18+
nats-route://node1:6222
19+
nats-route://node3:6222
20+
]
21+
}

0 commit comments

Comments
 (0)