当前位置:网站首页>Clickhouse synchronization MySQL (based on materialization engine)
Clickhouse synchronization MySQL (based on materialization engine)
2022-07-05 03:45:00 【Younger Cheng】
One 、Mysql engine ( Not recommended )
Synchronization considerations :1、 The library name specification cannot have “-”, The table name specification cannot have “-”
CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster]
ENGINE = MySQL('host:port', ['database' | database], 'user', 'password')Parameter description :
host:port— MySQL Service addressdatabase— MySQL Database nameuser— MySQL user namepassword— MySQL User password
MySQL The engine will be remote MySQL Tables in the server / Library mapping to ClickHouse in ,MySQL The database engine will convert the query to MySQL Syntax and send to MySQL Server ( Equivalent to direct use of mysql)
Database synchronization :
CREATE DATABASE IF NOT EXISTS mysql_db ENGINE = MySQL ('localhost:3306', 'mysql', 'root', '123456');
Table synchronization :
CREATE TABLE IF NOT EXISTS tmp ENGINE = MergeTree ORDER BY id AS SELECT * FROM mysql('localhost:3306','test','user','root','123456')Two 、MaterializedMySQL( To use , But the official is still in the experimental stage )
CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster]
ENGINE = MaterializedMySQL('host:port', ['database' | database], 'user', 'password') [SETTINGS ...]
[TABLE OVERRIDE table1 (...), TABLE OVERRIDE table2 (...)]establish ClickHouse database , contain MySQL All the tables in , And all the data in these tables .
ClickHouse Server as MySQL Copy work . It reads binlog And implement DDL and DML Inquire about
1、mysql Turn on binlog and GTID
vim /etc/mysql/my.cnf
[mysqld]
# Appoint binlog Log storage location
#log-bin=/data/logs/mysql/mysql-bin.log
log-bin=/var/lib/mysql/mysql-bin
# Turn on GTID Pattern
gtid-mode=ON
# Set master-slave strong consistency
enforce-gtid-consistency=1
# Log
log-slave-updates=1
binlog_format=ROW2、 Create a replication pipeline
# Start the materialization engine
SET allow_experimental_database_materialized_mysql=1;
CREATE DATABASE yfc
ENGINE = MaterializeMySQL('localhost:3306', 'yfc', 'root', '123456') advantage : By monitoring mysql Of binlog file , Achieve incremental updates , Increased efficiency
Data restrictions :
1、 Sync mysql Before the data ,mysql Every watch of should have primary key( If there is no primary key , Error will be reported during synchronization )
2、MaterializedMySQL It is a library level engine , During synchronization, the table data in the whole database will be synchronized
3、mysql Data synchronization to clickhouse Index conversion will occur after : stay ClickHouse In the table ,MySQL Of PRIMARY KEY and INDEX Clause is converted to ORDER BY Tuples
4、mysql In the transformation of clickhouse Table time , Each table will add two fields :_sign(1: write in 、-1: Delete ),_version
5、 stay clickhouse When adding synchronization in , There is no physical deletion , Only pass _sign Flag field to realize data filtering
6、 stay mysql conversion clickhouse when , Default ReplacingMergeTree engine , Ensure that no duplicate data appears
example :
#1、 Query the synchronized database
show databses;
use yfc;
show tables;
#2、 View the table creation statement
show create table sku_info;
#3、 Query synchronized data
select *,_sign,_version from sku_info;

#4、 The new data ( Go to mysql Of sku_info Insert data into the table )
INSERT INTO `yfc`.`sku_info`(`id`, `sku_code`) VALUES (3, '10003');
#5、 Modifying data
UPDATE `yfc`.`ts_store_info` set cust_name = ' Continuous commissioning test ' where id= 111; 
#6、 Delete data
DELETE FROM `yfc`.`sku_info` where id= 3; 
3、 ... and 、mysql Table function
Four 、datax
边栏推荐
- ICSI213/IECE213 Data Structures
- Share the newly released web application development framework based on blazor Technology
- Three line by line explanations of the source code of anchor free series network yolox (a total of ten articles, which are guaranteed to be explained line by line. After reading it, you can change the
- Excuse me, my request is a condition update, but it is blocked in the buffer. In this case, can I only flush the cache every time?
- Talk about the SQL server version of DTM sub transaction barrier function
- [move pictures up, down, left and right through the keyboard in JS]
- Redis6-01nosql database
- 线程基础知识
- LeetCode 234. Palindrome linked list
- MySQL winter vacation self-study 2022 11 (9)
猜你喜欢

Share the newly released web application development framework based on blazor Technology

Learning notes of raspberry pie 4B - IO communication (I2C)
![[vérification sur le Web - divulgation du code source] obtenir la méthode du code source et utiliser des outils](/img/ea/84e67a1fca0e12cc4452c744c242b4.png)
[vérification sur le Web - divulgation du code source] obtenir la méthode du code source et utiliser des outils
![[system security] ten thousand words summary system virtualization container bottom layer principle experiment](/img/c6/1bdb29a0acb0739f67b882fa6b3b47.jpg)
[system security] ten thousand words summary system virtualization container bottom layer principle experiment

New interesting test applet source code_ Test available

51 independent key basic experiment
![[groovy] loop control (number injection function implements loop | times function | upto function | downto function | step function | closure can be written outside as the final parameter)](/img/45/6cb796364efe16d54819ac10fb7d05.jpg)
[groovy] loop control (number injection function implements loop | times function | upto function | downto function | step function | closure can be written outside as the final parameter)

花了2晚,拿到了吴恩达@斯坦福大学的机器学习课程证书

How to define a unified response object gracefully

DMX parameter exploration of grandma2 onpc 3.1.2.5
随机推荐
DMX parameter exploration of grandma2 onpc 3.1.2.5
C # use awaiter
Pdf things
Excuse me, my request is a condition update, but it is blocked in the buffer. In this case, can I only flush the cache every time?
[安洵杯 2019]不是文件上传
040. (2.9) relieved
Talk about the SQL server version of DTM sub transaction barrier function
Une question est de savoir si Flink SQL CDC peut définir le parallélisme. Si le parallélisme est supérieur à 1, il y aura un problème d'ordre?
[learning notes] month end operation -gr/ir reorganization
DECLARE_ WAIT_ QUEUE_ HEAD、wake_ up_ Interruptible macro analysis
There is a question about whether the parallelism can be set for Flink SQL CDC. If the parallelism is greater than 1, will there be a sequence problem?
speed or tempo in classical music
Yuancosmic ecological panorama [2022 latest]
Cette ADB MySQL prend - elle en charge SQL Server?
Machine learning experiment report 1 - linear model, decision tree, neural network part
Timing manager based on C #
[system security] ten thousand words summary system virtualization container bottom layer principle experiment
001 chip test
SQL injection exercise -- sqli Labs
IPv6 experiment