Skip to content

Commit 2e16b69

Browse files
committed
Update README and wiki
1 parent 5bc0c2f commit 2e16b69

4 files changed

Lines changed: 514 additions & 204 deletions

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
AliSQL is Alibaba's MySQL branch, forked from official MySQL and used extensively in Alibaba Group's production environment. It includes various performance optimizations, stability improvements, and features tailored for large-scale applications.
44

55
- [AliSQL](#alisql)
6+
- [🚀 Quick Start (DuckDB)](#-quick-start-duckdb)
67
- [Version Information](#version-information)
78
- [Features](#features)
89
- [Roadmap](#roadmap)
@@ -12,6 +13,10 @@ AliSQL is Alibaba's MySQL branch, forked from official MySQL and used extensivel
1213
- [License](#license)
1314
- [See Also](#see-also)
1415

16+
## 🚀 Quick Start (DuckDB)
17+
18+
> **Quickly build your DuckDB node:** **[How to set up a DuckDB node](./wiki/duckdb/how-to-setup-duckdb-node-en.md)**
19+
1520
## Version Information
1621

1722
- **AliSQL Version**: 8.0.44 (LTS)
@@ -21,7 +26,7 @@ AliSQL is Alibaba's MySQL branch, forked from official MySQL and used extensivel
2126

2227
- **[DuckDB Storage Engine](./wiki/duckdb/duckdb.md)**:AliSQL integrates DuckDB as a native storage engine, allowing users to operate DuckDB with the same experience as MySQL. By leveraging AliSQL for rapid deployment of DuckDB service nodes, users can easily achieve lightweight analytical capabilities.
2328

24-
- **[Vector Storage](https://www.alibabacloud.com/help/en/rds/apsaradb-rds-for-mysql/vector-storage-1?spm=a2c63.p38356.help-menu-26090.d_3_3_0.6bb8d111D06xOW)**:AliSQL natively supports enterprise-grade vector processing for up to 16,383 dimensions. By integrating a highly optimized HNSW algorithm for high-performance Approximate Nearest Neighbor (ANN) search, AliSQL empowers users to build AI-driven applications—such as semantic search and recommendation systems—seamlessly using standard SQL interfaces.
29+
- **[Vector Storage](./wiki/vidx/vidx_readme.md)**:AliSQL natively supports enterprise-grade vector processing for up to 16,383 dimensions. By integrating a highly optimized HNSW algorithm for high-performance Approximate Nearest Neighbor (ANN) search, AliSQL empowers users to build AI-driven applications—such as semantic search and recommendation systems—seamlessly using standard SQL interfaces.
2530

2631
## Roadmap
2732

wiki/duckdb/duckdb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ AliSQL allows DuckDB nodes to serve as replicas via Binlog synchronization. By r
9494
**Test Environment**:
9595
- ECS Instance: 32 CPU, 128GB Memory, ESSD PL1 Cloud Disk 500GB
9696
- Benchmark: TPC-H SF100
97-
-
98-
| Query ID | DuckDB | InnoDB | InnoDB |
97+
98+
| Query ID | DuckDB | InnoDB | ClickHouse |
9999
| --- | --- | --- | --- |
100100
|q1|0.92|1134.25|3.47|
101101
|q2|0.15|1800|1.52|
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
# How to setup DuckDB node in AliSQL
2+
3+
[ [快速部署 AliSQL DuckDB 节点](./how-to-setup-duckdb-node-zh.md) | [How to setup DuckDB node in AliSQL](./how-to-setup-duckdb-node-en.md) ]
4+
5+
## Overview
6+
7+
AliSQL integrates DuckDB as an analytical storage engine.
8+
9+
- **User data** is stored in **DuckDB**
10+
- **System tables and metadata** remain in **InnoDB** (e.g., `mysql.*`, data dictionary)
11+
12+
You can:
13+
1) bootstrap a **brand-new instance** where new tables default to DuckDB
14+
2) **convert an existing InnoDB instance** to DuckDB at startup
15+
3) build a **DuckDB replica (HTAP)** to replay binlogs from an OLTP primary
16+
17+
---
18+
19+
## 1. Bootstrap a Brand-New DuckDB Instance
20+
21+
Use this when you are creating a fresh instance and want newly created tables to land in DuckDB by default.
22+
23+
### 1.1 Install AliSQL 8.0.44
24+
25+
#### Option A: Build from source
26+
```bash
27+
git clone https://github.com/alibaba/AliSQL.git
28+
cd AliSQL
29+
30+
sh build.sh -t release -d /opt/alisql
31+
make install
32+
```
33+
34+
#### Option B: Install from RPM
35+
```bash
36+
# For example, use x86 el6 rpm for installation
37+
wget https://github.com/alibaba/AliSQL/releases/download/AliSQL-8.0.44-1/alisql-8.0.44-1.el8.x86_64.rpm
38+
rpm -ivh alisql-8.0.44-1.el8.x86_64.rpm
39+
```
40+
41+
---
42+
43+
### 1.2 Directory bootstrap + config generator script
44+
45+
```bash
46+
cat > init_alisql_dir.sh <<'EOF'
47+
#!/usr/bin/env bash
48+
set -euo pipefail
49+
50+
# Usage:
51+
# ./init_alisql_dir.sh <absolute_path>
52+
53+
if [[ $# -ne 1 ]]; then
54+
echo "Usage: $0 <absolute_path>"
55+
exit 1
56+
fi
57+
58+
DIR="$1"
59+
if [[ "$DIR" != /* ]]; then
60+
echo "Error: Argument must be an ABSOLUTE PATH (starting with /)."
61+
exit 1
62+
fi
63+
64+
DIR="${DIR%/}"
65+
66+
mkdir -p \
67+
"$DIR/data/dbs" \
68+
"$DIR/data/mysql" \
69+
"$DIR/run" \
70+
"$DIR/log/mysql" \
71+
"$DIR/tmp"
72+
73+
cat > "$DIR/alisql.cnf" <<EOF2
74+
[mysqld]
75+
# --- Paths ---
76+
basedir =
77+
datadir = ${DIR}/data/dbs
78+
socket = ${DIR}/run/mysql.sock
79+
pid-file = ${DIR}/run/mysqld.pid
80+
tmpdir = ${DIR}/tmp
81+
82+
# --- Basic ---
83+
character_set_server = utf8mb4
84+
skip_ssl
85+
lower_case_table_names = 1
86+
core-file
87+
88+
# --- Logs ---
89+
log-error = ${DIR}/log/mysql/error.log
90+
91+
# Binary logging (optional)
92+
log-bin = ${DIR}/log/mysql/mysql-bin
93+
binlog_format = ROW
94+
95+
# --- InnoDB (system tables / metadata) ---
96+
innodb_data_home_dir = ${DIR}/data/mysql
97+
innodb_log_group_home_dir = ${DIR}/data/mysql
98+
99+
# --- DuckDB Storage Engine ---
100+
duckdb_mode=ON
101+
force_innodb_to_duckdb=ON
102+
103+
# DuckDB resources (0 = auto)
104+
duckdb_memory_limit=0
105+
duckdb_threads=0
106+
duckdb_temp_directory=${DIR}/tmp
107+
EOF2
108+
109+
echo "OK: created $DIR and $DIR/alisql.cnf"
110+
EOF
111+
112+
chmod +x init_alisql_dir.sh
113+
```
114+
115+
References:
116+
- MySQL 8.0 manual: https://dev.mysql.com/doc/refman/8.0/en/
117+
- DuckDB variables: [AliSQL DuckDB variables](./duckdb/duckdb_variables-zh.md)
118+
119+
---
120+
121+
### 1.3 Initialize and start
122+
123+
```bash
124+
# Example: store all data under $HOME/alisql_8044
125+
./init_alisql_dir.sh $HOME/alisql_8044
126+
127+
# Initialize
128+
/opt/alisql/bin/mysqld --defaults-file=$HOME/alisql_8044/alisql.cnf --initialize-insecure
129+
130+
# Start, the port is 3306 by default
131+
/opt/alisql/bin/mysqld_safe --defaults-file=$HOME/alisql_8044/alisql.cnf &
132+
```
133+
134+
---
135+
136+
### 1.4 Validate and use
137+
138+
```sql
139+
CREATE DATABASE test;
140+
USE test;
141+
142+
-- Create DuckDB table
143+
CREATE TABLE t (
144+
id INT PRIMARY KEY,
145+
name VARCHAR(255)
146+
) ENGINE = DuckDB;
147+
148+
-- Convert
149+
ALTER TABLE t ENGINE = InnoDB;
150+
ALTER TABLE t ENGINE = DuckDB;
151+
152+
-- DML
153+
INSERT INTO t VALUES (1, 'John');
154+
SELECT * FROM t;
155+
UPDATE t SET name = 'Jane' WHERE id = 1;
156+
DELETE FROM t WHERE id = 1;
157+
158+
-- DDL
159+
ALTER TABLE t ADD COLUMN age INT;
160+
ALTER TABLE t RENAME TO t_new;
161+
```
162+
163+
---
164+
165+
## 2. One-Click Conversion from an Existing InnoDB Instance
166+
167+
Use this when you want to migrate existing InnoDB tables to DuckDB to boost analytical performance.
168+
169+
### Steps
170+
171+
1) **Stop the existing instance** (clean shutdown)
172+
173+
2) **Update `my.cnf`**
174+
```ini
175+
[mysqld]
176+
duckdb_mode=ON
177+
force_innodb_to_duckdb=ON
178+
179+
duckdb_memory_limit=0
180+
duckdb_threads=0
181+
duckdb_temp_directory=/path/to/duckdb_temp_dir
182+
183+
duckdb_convert_all_at_startup=ON
184+
duckdb_convert_all_at_startup_threads=32
185+
duckdb_convert_all_at_startup_ignore_error=ON
186+
```
187+
188+
3) **Start the instance**
189+
190+
4) **Verify**
191+
```sql
192+
-- Check the conversion stage
193+
SHOW GLOBAL STATUS LIKE 'DuckDB_convert_stage_at_startup';
194+
195+
-- Check the converted tables
196+
SELECT table_schema, table_name, engine
197+
FROM information_schema.tables
198+
WHERE engine = 'DuckDB';
199+
```
200+
201+
### Notes
202+
203+
- Startup conversion is resource-intensive (CPU/IO). Monitor the error log for progress and failures.
204+
- Ensure enough free disk space (recommended: ≥ original data size).
205+
- Backup before conversion (backup set + cnf).
206+
- Upgrade MySQL 5.7 or below to 8.0 first.
207+
- If your source instance is not 8.0.44, an upgrade may be triggered on startup; ensure a clean shutdown beforehand.
208+
209+
---
210+
211+
## 3. DuckDB Replica (HTAP)
212+
213+
A common pattern is OLTP on the primary and OLAP on a DuckDB replica, fed by row-based binlogs.
214+
215+
### Steps
216+
217+
1) **Prepare the primary**
218+
- enable binlog
219+
- `binlog_format=ROW`
220+
- enable GTID
221+
222+
1) **Configure the replica `my.cnf`**
223+
```ini
224+
[mysqld]
225+
duckdb_mode=ON
226+
duckdb_require_primary_key=ON
227+
force_innodb_to_duckdb=ON
228+
229+
dml_in_batch=ON
230+
update_modified_column_only=ON
231+
duckdb_multi_trx_in_batch=ON
232+
duckdb_multi_trx_timeout=5000
233+
duckdb_multi_trx_max_batch_length=268435456
234+
```
235+
236+
3) **Initialize the replica**
237+
Follow section 1 (new instance) or section 2 (optional startup conversion), depending on your scenario.
238+
239+
4) **Set up replication**
240+
```sql
241+
CHANGE MASTER TO
242+
MASTER_HOST='your-master-ip',
243+
MASTER_USER='repl',
244+
MASTER_PASSWORD='your-password',
245+
MASTER_AUTO_POSITION=1;
246+
247+
START SLAVE;
248+
```
249+
250+
5) **Done**
251+
Route analytics/reporting queries to the DuckDB replica.

0 commit comments

Comments
 (0)