距离上一次更新该文章已经过了 652 天,文章所描述的內容可能已经发生变化,请留意。
此处以mergetree引擎举例,如果是用于高可用开发,还是需要换成replicatemergetree系列引擎
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
drop table if exists <database>.<tablename_local> on cluster <clustername>; drop table if exists <database>.<tablename_local> on cluster <clustername>;
CREATE TABLE <database>.<tablename_local> ENGINE = MergeTree order by cm_id AS SELECT * FROM mysql( '远程mysql_ip:远程mysql_port', '远程mysql_database', '远程mysql_tablename', '远程mysql_user', '远程mysql_password' ) limit 0;
show create table <database>.<tablename_local>; CREATE TABLE default.t_customer on cluster <clustername> ( xxx String, xxx UInt64 ... ) ENGINE = MergeTree ORDER BY <id> SETTINGS index_granularity = 8192;
create table <database>.<tablename> on cluster <clustername> AS <database>.<tablename> engine = Distributed('<clustername>', '<database>', '<tablename_local>', rand());
insert into <database>.<tablename> SELECT * FROM mysql( '远程mysql_ip:远程mysql_port', '远程mysql_database', '远程mysql_tablename', '远程mysql_user', '远程mysql_password' );
|