mysql 同步数据到 elasticsearch

需要用到 https://github.com/siddontang/go-mysql-elasticsearch

第一步是安装 go 环境,版本要 1.9+

下载go
 

cd /home
mkdir app
cd app
wget wget https://storage.googleapis.com/golang/go1.9.4.linux-amd64.tar.gz
tar zxvf go1.9.4.linux-amd64.tar.gz
新建GOPATH目录
mkdir /home/work
vi /etc/profile

 

export GOROOT=/home/app/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=/home/work
执行 source /etc/profile 生效
查看是否配置成功,执行 go version ,如果返回版本号就正常了。

修改数据库配置文件,默认文件位置为:/etc/my.cnf , 确保有以下配置内容

  1. 开启bin-log
  2. binglog_foramt格式必须为row ;  binlog_format=ROW
  3. binlog-row-image 必须为FULL

修改 river.toml 配置文件 /home/work/src/github.com/siddontang/go-mysql-elasticsearch/etc/river.toml

  • 如果可能,创建关联的Elasticsearch索引,文档类型和映射,否则,Elasticsearch将自动创建这些索引。
  • 执行./bin/go-mysql-elasticsearch -config=./etc/river.toml 开始同步数据,以后新增数据都会自动同步到ES中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值