使用go-mysql-elasticsearch包实现将mysql数据同步elasticsearch的流程步骤
Go  /  管理员 发布于 3星期前   67
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实现同步的。
博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..路人 在
php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..博主 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 @ mashrdn 多切换几个节点测试,免费ssr是没那么稳..mashrdn 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 V2rayn免费节点添加上去了,youtobe无法打开网页,是怎么回事..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号