housepower / ckman

This is a tool which used to manage and monitor ClickHouse database
Apache License 2.0
433 stars 108 forks source link

ckman2.3.6版本[均衡集群]为什么目标表和视图必须是同一个库,否则平衡报错 #273

Closed mengxiangchang closed 1 year ago

mengxiangchang commented 1 year ago

在target库中建立集群表newst_dw_all_details_day_tar【存储数据】,在newst库中建立视图newst_dw_all_details_day【对应集群表target.newst_dw_all_details_day_tar】 点击页面的【均衡集群】 后台ckman.log日志如下 2023-06-15T17:06:44.584+0800 INFO clickhouse/clickhouse_service.go:1407 table newst.newst_dw_all_details_day_tar rebalance by partition 2023-06-15T17:06:44.584+0800 INFO clickhouse/ck_rebalance.go:63 initialized clickhouse connection to 172.25.2.137 2023-06-15T17:06:44.584+0800 INFO clickhouse/ck_rebalance.go:63 initialized clickhouse connection to 172.25.2.139 2023-06-15T17:06:44.584+0800 INFO clickhouse/ck_rebalance.go:63 initialized clickhouse connection to 172.25.2.141 2023-06-15T17:06:44.584+0800 INFO clickhouse/ck_rebalance.go:105 host: 172.25.2.137, command: ssh -o StrictHostKeyChecking=false 172.25.2.139 sudo ls /data01/clickhouse/data/newst 2023-06-15T17:06:44.850+0800 INFO clickhouse/ck_rebalance.go:105 host: 172.25.2.137, command: ssh -o StrictHostKeyChecking=false 172.25.2.141 sudo ls /data01/clickhouse/data/newst 2023-06-15T17:06:45.121+0800 INFO clickhouse/ck_rebalance.go:105 host: 172.25.2.139, command: ssh -o StrictHostKeyChecking=false 172.25.2.137 sudo ls /data01/clickhouse/data/newst 2023-06-15T17:06:45.382+0800 INFO clickhouse/ck_rebalance.go:105 host: 172.25.2.139, command: ssh -o StrictHostKeyChecking=false 172.25.2.141 sudo ls /data01/clickhouse/data/newst 2023-06-15T17:06:45.641+0800 INFO clickhouse/ck_rebalance.go:105 host: 172.25.2.141, command: ssh -o StrictHostKeyChecking=false 172.25.2.137 sudo ls /data01/clickhouse/data/newst 2023-06-15T17:06:45.907+0800 INFO clickhouse/ck_rebalance.go:105 host: 172.25.2.141, command: ssh -o StrictHostKeyChecking=false 172.25.2.139 sudo ls /data01/clickhouse/data/newst 2023-06-15T17:06:46.166+0800 INFO clickhouse/ck_rebalance.go:135 host 172.25.2.137: query: WITH (SELECT argMax(partition, modification_time) FROM system.parts WHERE database='newst' AND table='newst_dw_all_details_day_tar') AS latest_partition SELECT partition, sum(data_compressed_bytes) AS compressed FROM system.parts WHERE database='newst' AND table='newst_dw_all_details_day_tar' AND active=1 AND partition!=latest_partition GROUP BY partition ORDER BY partition; 2023-06-15T17:06:46.171+0800 INFO clickhouse/ck_rebalance.go:135 host 172.25.2.139: query: WITH (SELECT argMax(partition, modification_time) FROM system.parts WHERE database='newst' AND table='newst_dw_all_details_day_tar') AS latest_partition SELECT partition, sum(data_compressed_bytes) AS compressed FROM system.parts WHERE database='newst' AND table='newst_dw_all_details_day_tar' AND active=1 AND partition!=latest_partition GROUP BY partition ORDER BY partition; 2023-06-15T17:06:46.176+0800 INFO clickhouse/ck_rebalance.go:135 host 172.25.2.141: query: WITH (SELECT argMax(partition, modification_time) FROM system.parts WHERE database='newst' AND table='newst_dw_all_details_day_tar') AS latest_partition SELECT partition, sum(data_compressed_bytes) AS compressed FROM system.parts WHERE database='newst' AND table='newst_dw_all_details_day_tar' AND active=1 AND partition!=latest_partition GROUP BY partition ORDER BY partition; 2023-06-15T17:06:46.181+0800 INFO clickhouse/ck_rebalance.go:161 table newst_dw_all_details_day_tar state []*clickhouse.TblPartitions{ &clickhouse.TblPartitions{ Table: "newst.newst_dw_all_details_day_tar", Host: "172.25.2.137", ZooPath: "", Partitions: map[string]int64{}, TotalSize: 0, ToMoveOut: map[string]string{}, ToMoveIn: false, }, &clickhouse.TblPartitions{ Table: "newst.newst_dw_all_details_day_tar", Host: "172.25.2.139", ZooPath: "", Partitions: map[string]int64{}, TotalSize: 0, ToMoveOut: map[string]string{}, ToMoveIn: false, }, &clickhouse.TblPartitions{ Table: "newst.newst_dw_all_details_day_tar", Host: "172.25.2.141", ZooPath: "", Partitions: map[string]int64{}, TotalSize: 0, ToMoveOut: map[string]string{}, ToMoveIn: false, }, } 2023-06-15T17:06:46.181+0800 INFO clickhouse/ck_rebalance.go:334 table newst.newst_dw_all_details_day_tar host 172.25.2.141 rebalance done 2023-06-15T17:06:46.181+0800 INFO clickhouse/ck_rebalance.go:334 table newst.newst_dw_all_details_day_tar host 172.25.2.139 rebalance done 2023-06-15T17:06:46.181+0800 INFO clickhouse/ck_rebalance.go:334 table newst.newst_dw_all_details_day_tar host 172.25.2.137 rebalance done 2023-06-15T17:06:46.181+0800 INFO clickhouse/ck_rebalance.go:342 table newst.newst_dw_all_details_day_tar rebalance done 2023-06-15T17:06:46.181+0800 INFO clickhouse/clickhouse_service.go:1583 rebalance done

后台日志sql: WITH (SELECT argMax(partition, modification_time) FROM system.parts WHERE database='newst' AND table='ttl_move_test_tar') AS latest_partition SELECT partition, sum(data_compressed_bytes) AS compressed FROM system.parts WHERE database='newst' AND table='ttl_move_test_tar' AND active=1 AND partition!=latest_partition GROUP BY partition ORDER BY partition; 上述的database='newst'应该为database='target',否则上述sql执行结果为空

YenchangChan commented 1 year ago

暂时未考虑支持物化视图和实体表不在一个数据库的场景