gongstring技术博客
最新文章
源码解读
软件安装
常见问题
大数据
常用工具
鸡汤文
备案号:鄂ICP备15015839号-1
鄂公网安备 42010202001692号
Clickhouse使用MaterializedMySQL引擎自动同步Mysql数据
2021-12-03 09:45:45
作者: gongstring
软件安装
/
Clickhouse使用MaterializedMySQL引擎自动同步Mysql数据
## 使用MaterializedMySQL引擎自动同步Mysql数据 ### 1、配置Mysql 修改Mysql配置,开通同步能力 vim /etc/my.cnf ``` [mysqld] # binlog 配置 log-bin=/usr/local/mysql/logs/mysql-bin.log binlog_format=ROW server-id=1 explicit_defaults_for_timestamp=true gtid-mode=on enforce-gtid-consistency=on log-slave-updates=1 default_authentication_plugin=mysql_native_password ``` 一定要注意`default_authentication_plugin=mysql_native_password`必须有,否则无法创建; 重启mysql ``` systemctl restart mysql ``` ### 2、创建clickhouse复制库 登录clickhouse,执行命令:  完整命令如下: clickhouse-client ``` SET allow_experimental_database_materialized_mysql =1 CREATE DATABASE mysql_drippro_pay ENGINE = MaterializeMySQL('IP:3306', 'gongstring_sample', 'gongstring', '密码') SETTINGS allows_query_when_mysql_lost=true,max_wait_time_when_mysql_unavailable=10000 ``` ### 3、注意事项 1)、所有的表都要有主键; 2)、要使用常用字段类型,字段类型清单:`https://clickhouse.com/docs/zh/engines/database-engines/materialize-mysql/#data_types-support` 参考文档: https://raw.githubusercontent.com/ClickHouse/clickhouse-presentations/master/meetup47/materialize_mysql.pdf