安装go
官网下载并解压
wget https://dl.google.com/go/go1.12.13.linux-amd64.tar.gz
tar -xvf go1.12.13.linux-amd64.tar.gz -C /opt
配置环境变量
sudo vi ~/.bashrc
输入
export GOROOT=/opt/go
export GOPATH=/home/ubuntu/go-workplace
export PATH=$PATH:$GOROOT/bin:/$GOPATH/bin
使生效
source /etc/profile
查看版本
go version
安装go-mysql-elasticsearch
go get github.com/siddontang/go-mysql-elasticsearch
cd $GOPATH/src/github.com/siddontang/go-mysql-elasticsearch&&make
编写同步规则
# MySQL address, user and password
# user must have replication privilege in MySQL.
my_addr = "127.0.0.1:3306"
my_user = "root"
my_pass = "147258369"
my_charset = "utf8"
# Set true when elasticsearch use https
#es_https = false
# Elasticsearch address
es_addr = "127.0.0.1:9200"
# 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 = "./var"
# Inner Http status address
stat_