拉取映象
docker pull gozer/go-mysql-elasticsearch
建立配置檔案
vim /docker/go-mysql-es/go_mysql_river.toml
配置檔案如下
my_addr = "192.168.126.105:3306"
my_user = "root"
my_pass = "root"
my_charset = "utf8"
enable-relay = true
es_addr = "192.168.126.105:9200"
es_user = ""
es_pass = ""
data_dir = "/docker/data"
stat_addr = "127.0.0.1:12800"
stat_path = "/metrics"
server_id = 1001
flavor = "mysql"
mysqldump = ""
#skip_master_data = false
bulk_size = 128
flush_bulk_time = "200ms"
skip_no_pk_table = false
[[source]]
schema = "lmrs_2008_shops"
tables = ["lmrs_products"]
[[rule]]
schema = "lmrs_2008_shops"
table = "lmrs_products"
index = "products"
type = "_doc"
# Only sync following columns
filter = ["id", "name","long_name","brand_id","shop_id","price","sold_count","review_count","status","create_time","last_time","three_category_id"]
[rule.filed]
mysql = "three_category_id"
elastic = "category_id"
run
docker run -p 12345:12345 -d --name go-mysql-es --net lmrs --ip 172.18.12.8 -v /docker/go-mysql-es/go_mysql_river.toml:/config/river.toml:ro --privileged=true gozer/go-mysql-elasticsearch
備註:mysql8 mysqldump有問題未解決
本作品採用《CC 協議》,轉載必須註明作者和本文連結