最近项目里用了 es 代替对数据库的查询
q:(但看了下 基本都是对表字段精确查询 如 activityid= and pid= 这种精确查询用 es 是不是不是很必要?)
看了下 代码里可以用 ElasticsearchRepository 这种简单的 crud 同步数据库操作 logstash 也可以实现,但试了下 table_01 的 id 与 es 中的 index/type 的 id 要有对应关系,
q:(且如果是删除库里的一条操作,使用 logstash 来让 es 同步的话 ,那库里的删除操作要设为逻辑操作才行吗?)
q:(如果 mysql 中的表与 es 没有主键的对应关系,logstash 能同步吗)
大家实际在项目中使用 es 是怎么处理同步数据库操作的
![]() | 1 nyjy997 2019-11-25 17:11:42 +08:00 logstash 数据同步还不错. |
![]() | 2 gz911122 2019-11-25 17:16:40 +08:00 我们直接读的 mysql binlog 来同步的 |
![]() | 3 tsl0922 2019-11-25 17:36:26 +08:00 binlog 方式同步的可以用: https://github.com/siddontang/go-mysql-elasticsearch |
![]() | 4 cocacola99 2019-11-25 17:48:34 +08:00 业务逻辑 -> 消息队列 -> 脚本处理 |
![]() | 5 ziiber 2019-11-25 18:31:18 +08:00 自建 Mysql 的话一般是用 binlog 监听,如果是阿里云 RDS 的话推荐使用阿里云的 DTS 数据订阅服务。 Binlog 方案: 监听 binlog 日志 > 消息队列 > 消费客户端 ## PHP https://github.com/krowinski/php-mysql-replication https://github.com/telanflow/laravel-binlog ## Go https://github.com/siddontang/go-mysql-elasticsearch ## Java https://github.com/shyiko/mysql-binlog-connector-java |
![]() | 6 vikeria 2019-11-26 08:52:55 +08:00 canal ? |
![]() | 7 cion 2019-11-26 09:08:49 +08:00 如果要自己做的话就用 Canal 吧,想做什么处理都容易 |
8 kiddingU 2019-11-26 09:26:06 +08:00 1、logstash jdbc plugin 2、唐刘写的 go-mysql-elasticsearch,不过这玩意不稳定,自己生产环境使用时,发生过意外 3、基于 canal 自己开发 |
9 capljf 2019-11-26 13:44:34 +08:00 同上,logstash jdbc plugin |