mysql-Synch-clickhouse

Synch

GitHub - long2ice/synch: Sync data from the other DB to ClickHouse(cluster)

 环境:

mysql5.7

redis >= 5.0

clickhouse21.2

postgresql

python3

binlog_format=row

XREAD

default

pg_config      

synch

1:安装clickhouse

rpm下载地址:

https://repo.yandex.ru/clickhouse/rpm/stable/x86_6

安装:rpm -ivh ./*.rpm

配置:

/etc/clickhouse-server/config.xml
/etc/clickhouse-server/users.xml

服务:

systemctl start clickhouse-server

 客户端:

clickhouse-client

2:安装Python3

系统默认: Python 2.7.5

安装:pip

yum -y install epel-release

yum install python-pip

pip --version

下载安装

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz

cd Python-3.7.0
./configure --prefix=/usr/local/python3 --enable-shared --enable-optimizations
make

make install

环境变量

/etc/profile

export PYTHON_HOME=/usr/local/python3

export PATH=$PYTHON_HOME/bin:$PATH

异常及处理:
/usr/local/python3/bin/python3.7: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

将python库的路径写到/etc/ld.so.conf配置中

vim /etc/ld.so.conf.d/python3.conf
/usr/local/python3/lib
ldconfig

升级pip

3:安装synch

pip3 install synch

安装异常:

需要安装:PostgreSQL,

yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

yum install -y postgresql13-server

yum install postgresql-devel

psql --version

配置环境变量:

/usr/pgsql-13/bin/pg_config

export PATH=$PATH:/usr/pgsql-13/bin

安装成功:

查看synch

配置synch.yaml
core:debug: true # when set True, will display sql information.insert_num: 1 # how many num to submit,recommend set 20000 when productioninsert_interval: 1 # how many seconds to submit,recommend set 60 when production# enable this will auto create database `synch` in ClickHouse and insert monitor datamonitoring: truesentry:environment: developmentdsn:redis:host: 127.0.0.1port: 6379db: 0password:prefix: synchqueue_max_len: 200000 # stream max len, will delete redundant ones with FIFOsource_dbs:- db_type: mysqlalias: mysql_db # must be uniquebroker_type: redis # current support redis and kafkaserver_id: 3host: 127.0.0.1port: 3306user: rootpassword: "123456"# optional, auto get from `show master status` when emptyinit_binlog_file:# optional, auto get from `show master status` when emptyinit_binlog_pos:skip_dmls: alert # dmls to skipskip_delete_tables: # tables skip delete, format with schema.tableskip_update_tables: # tables skip update, format with schema.tabledatabases:- database: crm# optional, default true, auto create database when database in clickhouse not existsauto_create: truetables:- table: user_log# optional, default false, if your table has decimal column with nullable, there is a bug with full data etl will, see https://github.com/ClickHouse/ClickHouse/issues/7690.skip_decimal: false # set it true will replace decimal with string type.# optional, default trueauto_full_etl: true # auto do full etl at first when table not exists# optional, default ReplacingMergeTreeclickhouse_engine: ReplacingMergeTree # current support MergeTree, CollapsingMergeTree, VersionedCollapsingMergeTree, ReplacingMergeTree# optionalpartition_by: # Table create partitioning by, like toYYYYMM(created_at).# optionalsettings: # Table create settings, like index_granularity=8192# optionalsign_column: sign # need when clickhouse_engine=CollapsingMergeTree and VersionedCollapsingMergeTree, no need real in source db, will auto generate in clickhouse# optionalversion_column: # need when clickhouse_engine=VersionedCollapsingMergeTree and ReplacingMergeTree(optional), need real in source db, usually is `updated_at` with auto update.- table: deptinfo- table: userclickhouse:hosts:- 127.0.0.1:9000user: defaultpassword: ''cluster_name: #perftest_3shards_1replicasdistributed_suffix: ###_all # distributed tables suffix, available in cluster#kafka:
#  servers:
#    - kafka:9092
#  topic_prefix: synch# enable this to send error report, comment or delete these if not.
mail:mailhost: smtp.gmail.comfromaddr: long2ice@gmail.comtoaddrs:- long2ice@gmail.comuser: long2ice@gmail.compassword: "123456"subject: "[synch] Error logging report"

4:测试

1:create 。。 if not exists

synch -c /etc/synch.yaml --alias mysql_db etl --schema crm --table user

2:生产

监听源库并将变动数据写入消息队列。

synch --alias mysql_db produce

3:消费

从消息队列中消费数据并插入 ClickHouse,使用 --skip-error跳过错误消息。 配置 auto_full_etl = True 的时候会首先尝试做一次全量复制。

消费数据库 crm 并插入到ClickHouse

synch --alias mysql_db consume --schema crm

5:安装supervisord守护进程

yum install supervisor

配置
[program:mysql-to-ck-produce]
process_name=%(program_name)s
command=/usr/local/python3/bin/synch -c /etc/synch.yaml --alias mysql_db produce
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stdout_logfile_maxbytes=2048MB
stdout_logfile_backups=20
stopwaitsecs=3600[program:mysql-to-ck-consume-crm]
process_name=%(program_name)s
command=/usr/local/python3/bin/synch -c /etc/synch.yaml --alias mysql_db consume --schema crm
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stdout_logfile_maxbytes=2048MB
stdout_logfile_backups=20
stopwaitsecs=3600
服务:

systemctl restart supervisord

日志:

/var/log/supervisor

mysql-to-ck-consume-crm.log mysql-to-ck-produce.log supervisord.log

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/2821944.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

今日arXiv最热大模型论文:点击即可播放!港中文发布大模型写歌神器!

一首歌,包含作词作曲两个部分。擅长作词or作曲就已经很牛了。比如方文山是周杰伦的御用作词人,而周杰伦写过很多耳熟能详的曲子。而兼具作词作曲才华的全能创作人却是难得一见。 最近港中文发布了一款歌曲创作大模型SongComposer,作词作曲都…

DiskMirror-spring-boot-starter 技术|

DiskMirror-spring-boot-starter 技术 diskMirror 实现了 SpringBoot 的 starter 能够集成到 SpringBoot 中。 DiskMirror 的 starter,通过引入此类,可以直接实现 diskMirror 在 SpringBoot 中的自动配置,接下来我们将使用案例逐步的演示 d…

飞腾平台编译安装openGauss数据库

1. 环境检查 1.1 检查OS版本 openGauss支持的操作系统: CentOS 7.6(x86_64 架构)openEuler-20.03-LTS(aarch64 架构)openEuler-20.03-LTS(x86_64架构)Kylin-V10(aarch64 架构&…

作业1-224——P1015 [NOIP1999 普及组] 回文数

题目描述 思路 首先此题为一道高精度题,然后本题按照题目意思模拟即可。我们可以开两个数组来记录高精度数字,这样方便我们处理。判断“该数组是否回文”、“c翻转存入d再做cd”可以写成两个单独的函数。然后主程序组织一下他们即可。注意好退出循环的…

String类的使用

String常用的构造方法 String的源码 内部是一个数组和hash值,涉及到常量池后续补充(常量池:存储相同的字符时只会存储一租) String的比较 equals()与:String里面为我们提供了许多方法,可直接调用&#xf…

electron 项目环境变量使用注意 public

问题 最近项目中,electron需要调用唤醒本地的另一个客户端程序,但是这个客户端程序报错了。sqlite3 报out of memory. apiSHGetFolderPathW 获取CSIDL_COMMON_DOCUMENTS报 1008,试图引用不存在的令牌。 排查 一看到这个,首先想…

苍穹外卖Day03——解决总结3中存在的问题

解决Day03中存在的问题 1. ResponseBody 与 RequestBody2. RequestParam 与 PathVariable3. 字段填充技术(注解、AOP、反射)3.1. AOP3.2. 注解3.3. 反射3.5 字段填充在项目应用 4. 阿里云云存储OOS 1. ResponseBody 与 RequestBody ResponseBody&…

varFormatter 数据格式化库 以性能优先的 快速的 内存对象格式转换

varFormatter 数据格式化 技术 开源技术栏 对象/变量格式化工具库,其支持将一个对象进行按照 JSON XML HTML 等格式进行转换,并获取到结果字符串! 目录 文章目录 varFormatter 数据格式化 技术目录介绍获取方式 使用实例格式化组件的基本使…

WIN10 无密码自动登录

1、家里重装了一下WIN10系统,第一次登陆居然用了微软网站账号,结果密码忘记了,后面只能用PIN码登陆系统。 2、需要登录微软的网站修改密码: Microsoft account | Sign In or Create Your Account Today – Microsoft 3、在运行…

【C语言】动态内存管理常用函数

前言 我们在之前学习的数组开辟的空间是固定不变的,有时候我们需要的空间⼤⼩在程序运⾏的时候才能知道~ c语言中的动态内存开辟,让程序员⾃⼰可以根据实际需求申请和释放相应空间,这使得空间的开辟变得灵活了许多。 欢迎关注个人主页&#x…

数据库原理及应用 第三章:关系数据模型

文章目录 三、关系数据模型3.1.1关系模型概述3.1.2候选键和外键3.2关系模型的完整性 三、关系数据模型 3.1.1关系模型概述 3.1.2候选键和外键 3.2关系模型的完整性

写作软件,批量写作文章的软件

在信息爆炸的时代,写作软件成为许多人提高效率、优化内容的利器。本文将介绍6款不同的写作软件,以及知名的147GPT生成工具和文心一言AI生成软件,它们不仅可以帮助用户快速生成原创文章,还支持全自动SEO优化,提升文章在…

wy的leetcode刷题记录_Day79

wy的leetcode刷题记录_Day79 声明 本文章的所有题目信息都来源于leetcode 如有侵权请联系我删掉! 时间:2024-3-1 前言 目录 wy的leetcode刷题记录_Day79声明前言2369. 检查数组是否存在有效划分题目介绍思路代码收获 61. 旋转链表题目介绍思路代码收获 82. 删除排…

【Vue】npm run build 打包报错:请在[.env.local]中填入key后方可使用...

报错如下 根目录添加 .env.local 文件 .env.local :本地运行下的配置文件 配置:VUE_GITHUB_USER_NAME 及 VUE_APP_SECRET_KEY 原因

【研发日记】Matlab/Simulink技能解锁(二)——在Function编辑窗口Debug

目录 前言 行断点 条件断点 前言 见《【研发日记】Matlab/Simulink技能解锁(一)——在Simulink编辑窗口Debug》 行断点 当Matlab Function出现异常时,如果能确定大致的代码段,就可以在相应的行上设置一个断点(Breakpoint)&…

Oracle 11g升级19c 后部分查询功能很慢

*Oracle 11g升级19c 后部分查询功能很慢 今天生产突然有个查询非常慢,日志显示执行了50秒左右,但是从日志中拿出SQL在PLSQL执行,发现用时不到1秒,查看SQL,怀疑是下面几种原因导致 1、使用函数不当 UNIT.UNIT_CODE LIKE CONCAT(‘…

b站小土堆pytorch学习记录——P7-P8 Tensorboard的使用

文章目录 一、前置知识1.Tensorboard是什么2.SummaryWriter3.add_scalar()4.add_image() 二、代码1.一次函数2.蚂蚁和蜜蜂图片 一、前置知识 1.Tensorboard是什么 TensorBoard 是 TensorFlow 的可视化工具,它允许开发者可视化模型的图(graph&#xff0…

栈(顺序栈)实现Language C

###王道考研的学习领悟,个人喜好讲解清晰 何为栈? 定义:栈(stack)是只允许在一端进行插入或删除的线性表。 其重要术语:栈顶,栈底,空栈。 我们只需要把这个图看明白了,理解起来就…

electron+vue3全家桶+vite项目搭建【28】封装窗口工具类【2】窗口组,维护窗口关系

文章目录 引入实现效果思路主进程模块渲染进程模块测试效果 引入 demo项目地址 窗口工具类系列文章: 封装窗口工具类【1】雏形 我们思考一下窗口间的关系,窗口创建和销毁的一些动作,例如父子窗口,窗口组合等等,还有…

Prometheus(二):NodeExporter和Grafana的安装和使用

目录 1 Node Exporter安装1.1 简介1.2 安装1.3 Prometheus收集node_exporter数据 2 安装Grafana2.1 安装2.2 使用1、创建数据源2、选择模板3、模板导入 2.3 grafana创建用户1、创建用户2、验证 总结 1 Node Exporter安装 1.1 简介 node exporter是Prometheus的收集数据的组件…