使用go-mysql-elasticsearch包实现将mysql数据同步elasticsearch的流程步骤
Go  /  管理员 发布于 1年前   365
go-mysql-elasticsearch是一项将MySQL数据自动同步到 Elasticsearch 的服务。
它首先使用mysqldump获取原始数据,然后使用 binlog 逐步同步数据。
github:
https://github.com/go-mysql-org/go-mysql-elasticsearch
注意事项
1.当前环境需要 mysqldump 工具取导出数据
2.阿里云的数据库需要 skip_master_data = true
3.源代码里 是使用 update 方法取修改文档数据,而不是 index 方法
4.master 节点 binglog 日志设长点 不然的话 等 dump 完 之前的同步位点的 log 日志就会丢失
使用步骤:
配置文件
# MySQL address, user and password
# user must have replication privilege in MySQL.
my_addr = "localhost"
my_user = "root"
my_pass = "root"
my_charset = "utf8mb4"
# Set true when elasticsearch use https
#es_https = false
# Elasticsearch address
es_addr = "elasticsearch.addr"
# Elasticsearch user and password, maybe set by shield, nginx, or x-pack
es_user = ""
es_pass = ""
# Path to store data, like master.info, if not set or empty,
# we must use this to support breakpoint resume syncing.
# TODO: support other storage, like etcd.
data_dir = "./postion"
# Inner Http status address
stat_addr = "127.0.0.1:12800"
stat_path = "/metrics"
# pseudo server id like a slave
server_id = 1
# mysql or mariadb
flavor = "mysql"
# mysqldump execution path
# if not set or empty, ignore mysqldump.
mysqldump = "mysqldump"
# if we have no privilege to use mysqldump with --master-data,
# we must skip it.
skip_master_data = false
# minimal items to be inserted in one bulk
bulk_size = 128
# force flush the pending requests if we don't have enough items >= bulk_size
flush_bulk_time = "200ms"
# Ignore table without primary key
skip_no_pk_table = true
# MySQL data source
[[source]]
schema = "a"
tables = ["b"]
# Below is for special rule mapping
[[rule]]
schema = "a"
table = "b"
index = "es_index_v1"
type = "_doc"
id = ["id"]
filter = ["id","refine_timestamp"]
[rule.field]
# Map column `id` to ES field `es_id`
refine_timestamp = "refineTimestamp"
它主要是用 go 去请求 es 提供的 rest-api实现同步的。
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号