当前位置: 首页 > news >正文

clickhouse迁移工具clickhouse-copier

原来的集群没有高可用而且配置很低,所有准备将一个3分片1副本集群迁到1分片2副本的高配置集群,数据量比较大。

虽然官方已经标记clickhouse-copier已经过时,但为了方便和高效还是用了copier,效果还挺好

以下是使用步骤:

  1. 服务器上下载copier解压后,首先需要准备keeper.xml文件,目标端使用的是clickhouse-keeper,这里配置还是zookeeper但是不影响
<!-- config.xml -->
<clickhouse><logger><level>trace</level><size>100M</size><log>./log/clickhouse-copier/copier/log.log</log><errorlog>./log/clickhouse-copier/copier/log.err.log</errorlog><count>3</count></logger># 填入对应的 keeper的ip地址<zookeeper><node index="1"><host>172.23.3.44</host><port>9181</port></node><node index="2"><host>172.23.3.55</host><port>9181</port></node><node index="3"><host>172.23.3.66</host><port>9181</port></node></zookeeper></clickhouse>
  1. 准备迁移任务文件task_migrate_all.xml,可以将需要迁移的表放在一个文件,或者分成多个文件都可,但保证需要迁移的表在源集群所有节点都有,可以建空表来跳过检查,否则会报错
<clickhouse><remote_servers>##源集群地址<source_cluster><shard><internal_replication>false</internal_replication><replica><host>172.23.3.11</host> <port>9000</port><user>user_name</user><password>pwd</password></replica></shard><shard><internal_replication>false</internal_replication><replica><host>172.23.3.12</host> <port>9000</port><user>user_name</user><password>pwd</password></replica></shard><shard><internal_replication>false</internal_replication><replica><host>172.23.3.13</host> <port>9000</port><user>user_name</user><password>pwd</password></replica></shard></source_cluster>#目标集群地址<destination_cluster><shard><internal_replication>true</internal_replication><replica><host>172.23.3.44</host> <port>9000</port><user>user_name</user><password>pwd</password></replica><replica><host>172.23.3.55</host> <port>9000</port><user>user_name</user><password>pwd</password></replica></shard></destination_cluster></remote_servers># 并发线程<max_workers>12</max_workers>#对源库只读<settings_pull><readonly>1</readonly></settings_pull><!-- Setting used to insert (push) data to destination cluster tables --><settings_push><readonly>0</readonly></settings_push><settings><connect_timeout>3</connect_timeout><!-- Sync insert is set forcibly, leave it here just in case. --><distributed_foreground_insert>1</distributed_foreground_insert></settings># 需要迁移的表,可以tables里面可以写多张表<tables><table_sms_send><cluster_pull>source_cluster</cluster_pull><database_pull>test_qwe</database_pull><table_pull>sms_send</table_pull><cluster_push>destination_cluster</cluster_push><database_push>test_qwe</database_push><table_push>sms_send</table_push># 因为是多副本,需要使用复制表,否则只有单节点有数据<engine>ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{cluster}/{shard}/{database}/{table}', '{replica}')PARTITION BY toYYYYMM(create_time)ORDER BY (id, phone_number, state, create_time)</engine># 1分片不需要分片键,这里设置为1<sharding_key>1</sharding_key></table_sms_send><table_use_car><cluster_pull>source_cluster</cluster_pull><database_pull>test_qwe</database_pull><table_pull>use_car</table_pull><cluster_push>destination_cluster</cluster_push><database_push>testqwe</database_push><table_push>use_car</table_push><engine>ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{cluster}/{shard}/{database}/{table}', '{replica}', add_time)ORDER BY (id, detail_id)</engine><sharding_key>1</sharding_key></table_use_car></tables></clickhouse>
  1. 在clickhouse-copier解压目录执行命令开始迁移 .
# 这里task-path表示keeper存储的迁移任务路径
/clickhouse-copier --config keeper.xml --task-path /clickhouse/copier_task/mig_test --task-file=task_migrate_all.xml 

文章转载自:

http://Z0zZnplI.Lhrcr.cn
http://iUqC3UVO.Lhrcr.cn
http://j6nha4t1.Lhrcr.cn
http://tfPzjN7E.Lhrcr.cn
http://CWHWpG4n.Lhrcr.cn
http://7Wtp793W.Lhrcr.cn
http://qsDNylRn.Lhrcr.cn
http://7vwBZRxC.Lhrcr.cn
http://VcjINZgW.Lhrcr.cn
http://Vx1AOcSY.Lhrcr.cn
http://vpYjHDBh.Lhrcr.cn
http://aGuQNzW3.Lhrcr.cn
http://gikFuuIR.Lhrcr.cn
http://sbnGZSR5.Lhrcr.cn
http://RBwo2Ljq.Lhrcr.cn
http://AudN0BfN.Lhrcr.cn
http://bAgfMgkg.Lhrcr.cn
http://IP5FVp5P.Lhrcr.cn
http://BicDA17e.Lhrcr.cn
http://xBGEQWkw.Lhrcr.cn
http://lX4Q6xuR.Lhrcr.cn
http://JeZXOQfp.Lhrcr.cn
http://zxSfoJ6A.Lhrcr.cn
http://4Cen8tTU.Lhrcr.cn
http://FJjfu0T9.Lhrcr.cn
http://M7yzzsxF.Lhrcr.cn
http://YytRm7SE.Lhrcr.cn
http://AhE0MjIX.Lhrcr.cn
http://M0Bp66JP.Lhrcr.cn
http://IcYSlVDy.Lhrcr.cn
http://www.dtcms.com/a/366391.html

相关文章:

  • 基于vue的志愿者信息平台设计c38qk(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
  • 对接旅游行业安全需求:旅游安全急救实训室的功能构建与育人目标
  • APM32芯得 EP.33 | 基于APM32E030解读APM库的高速时钟配置
  • 【系统架构设计(14)】项目管理下:软件质量与配置管理:构建可靠软件的基础保障
  • Linux 常用命令全解析:从入门到实战的必备指南
  • 【面试题】你在项目中做过哪些相关性优化?
  • C#某公司面试题(含题目和解析)--1
  • Kafka如何保证高可用
  • aippt自动生成工具有哪些?一文看懂,总有一款适合你!
  • 【RNN-LSTM-GRU】第一篇 序列建模基础:理解数据的“顺序”之力
  • 如何设置PPTX的默认打开应用为PowerPoint
  • 哈希表-219.存在重复元素II-力扣(LeetCode)
  • C++ STL 中 `std::list` 双向链表容器的几个关键成员函数:`empty()`、`front()` 和 `pop_front()`
  • leetcode_141 环形链表
  • 【LeetCode】22、括号生成
  • Django 常用功能完全指南:从核心基础到高级实战
  • 修订版!Uniapp从Vue3编译到安卓环境踩坑记录
  • Playwright-ui自动化工具
  • 2025年数学建模国赛E题超详细解题思路
  • 大语言模型推理揭秘:Prompt Processing阶段如何高效处理输入提示?
  • Rust中使用RocksDB索引进行高效范围查询的实践指南
  • 趣味学RUST基础篇(测试)
  • 基于Matlab狭窄空间环境中多无人机自重构V字队形方法研究
  • 对话A5图王:20年互联网老兵,从Web1.0到Web3.0,牛友会里藏着最真的创业情
  • Docker(④Shell脚本)
  • LeetCode 面试经典 150_矩阵_螺旋矩阵(35_54_C++_中等)(按层模拟)
  • WEB3的资料——免费开放
  • E-E-A-T与现代SEO:赢得搜索引擎信任的完整策略
  • 新规则,新游戏:AI时代下的战略重构与商业实践
  • Rustdesk搭建与客户端修改与编译