Skip to content

Commit 1e690a2

Browse files
authored
More tests and README update
- Tests for removal - Tests for update - README.md updated (added MySQL config and ClickHouse config settings)
1 parent f414940 commit 1e690a2

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,31 @@ You may need to also compile C++ components if they're not pre-built for your pl
4242
For realtime data sync from MySQL to ClickHouse:
4343

4444
1. Prepare config file. Use `example_config.yaml` as an example.
45-
2. Start the replication:
45+
2. Configure MySQL and ClickHouse servers:
46+
- MySQL server configuration file `my.cnf` should include following settings (required to write binary log in raw format, and enable password authentication):
47+
```ini
48+
[mysqld]
49+
# ... other settings ...
50+
gtid_mode = on
51+
enforce_gtid_consistency = 1
52+
default_authentication_plugin = mysql_native_password
53+
54+
```
55+
56+
- ClickHouse server config `override.xml` should include following settings (it makes clickhouse apply final keyword automatically to handle updates correctly):
57+
```xml
58+
<clickhouse>
59+
<!-- ... other settings ... -->
60+
<profiles>
61+
<default>
62+
<!-- ... other settings ... -->
63+
<final>1</final>
64+
</default>
65+
</profiles>
66+
</clickhouse>
67+
```
68+
69+
3. Start the replication:
4670

4771
```bash
4872
mysql_ch_replicator --config config.yaml run_all

docker-compose-tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ services:
1212
- CLICKHOUSE_ADMIN_USER=default
1313
- CLICKHOUSE_HTTP_PORT=9123
1414
network_mode: host
15+
volumes:
16+
- ./tests_override.xml:/bitnami/clickhouse/etc/conf.d/override.xml:ro
1517

1618
mysql_db:
1719
image: mysql/mysql-server:8.0.32

test_mysql_ch_replicator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ def test_runner():
312312
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME)) == 4)
313313
assert_wait(lambda: ch.select(TEST_TABLE_NAME, where="name='John'")[0]['rate'] == 12.5)
314314

315+
mysql.execute(f"DELETE FROM {TEST_TABLE_NAME} WHERE name='John';", commit=True)
316+
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME)) == 3)
317+
318+
mysql.execute(f"UPDATE {TEST_TABLE_NAME} SET age=66 WHERE name='Ivan'", commit=True)
319+
time.sleep(4)
320+
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME)) == 3)
321+
315322
run_all_runner.stop()
316323

317324

tests_override.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<clickhouse>
2+
<profiles>
3+
<default>
4+
<final>1</final>
5+
</default>
6+
</profiles>
7+
</clickhouse>

0 commit comments

Comments
 (0)