Code Monkey home page Code Monkey logo

go-dbsync's Introduction

go-dbsync

synchronize the database tables

V1

编译:

  1. 获取MySQL驱动 go get github.com/go-sql-driver/mysql
  2. 本地编译 go build src/user-sync.go
  3. 本地编译Linux版本(bash) GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -o user-sync.linux src/user-sync.go

只能同步tr_f_user表的数据。 同步原理:比较两边数据,没有的补充上,有的但是不一样的,控制台打印。 用法:

./user-sync "root:my-secret-pw@tcp(192.168.99.100:13306)/dba" "root:my-secret-pw@tcp(192.168.99.100:13306)/dbb"

V2

  1. 获取MySQL驱动 go get github.com/go-sql-driver/mysql
  2. 获取nodb go get github.com/lunny/nodb
  3. 获取toml go get github.com/BurntSushi/toml
  4. 本地编译 go build src/dbsync.go
  5. 本地编译Linux版本(bash) GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -o dbsync.linux src/dbsync.go

可以同步指定表的数据,例如:

~/g/go-dbsync > ./dbsync config/dbsync.toml
<<<map[openid:NULL merchant_id:0 create_time:2016-05-16 10:34:22 effective:1 user_id:a045719884460976128 mobile:18231869455]
>>>map[create_time:2016-05-16 10:34:22 effective:1 user_id:a045719884460976128 mobile:18231869455 openid: merchant_id:0]
<<<map[create_time:2016-08-04 14:36:36 effective:1 user_id:b217018113249683456 mobile:18231684453 openid: merchant_id:18D72F678EFA]
>>>map[user_id:b217018113249683456 mobile:18231684453 openid:NULL merchant_id:18D72F678EFA create_time:2016-08-04 14:36:36 effective:1]
Start to merge left tr_f_user, merged 30 rows
Start to merge right tr_f_user, merged 15 rows

配置文件格式

# 同步的两个库配置
Db1 = "root:my-secret-pw@tcp(192.168.99.100:13306)/dba"
Db2 = "root:my-secret-pw@tcp(192.168.99.100:13306)/dbb"
# 需要同步的表,可以指定多个
SyncTables = [ "tr_f_user" ]

go-blackcat-web

提供了一个blackcat的消息跟踪展示原始的web
编译: env GOOS=linux GOARCH=amd64 go build -o go-blackcat-web-linux.bin src/go-blackcat-web.go
配置文件go-blackcat-web.toml:

CassandraHosts = ["127.0.0.1"]
CassandraPort = 9042
ListenPort = 8181

启动: ./nohup ./go-blackcat-web-linux ./go-blackcat-web.toml 2>&1 > go-blackcat-web.log &

go-tail-web

build:

env GOOS=linux GOARCH=amd64 go build -o go-tail-web.linux.bin src/tailweb/go-tail-web.go

run:

nohup ./go-tail-web.linux.bin -log=/Users/bingoo/gitlab/et-server/et.log -port=8497 > go-tail-web.out 2>&1 &

or multiple logs:

nohup ./go-tail-web.linux.bin -log=/Users/bingoo/gitlab/et-server/et.log,/Users/bingoo/gitlab/ab.log -port=8497 > go-tail-web.out 2>&1 &

or multiple logs with log naming:

nohup ./go-tail-web.linux.bin -log=et:/Users/bingoo/gitlab/et-server/et.log,ab:/Users/bingoo/gitlab/ab.log -port=8497 > go-tail-web.out 2>&1 &

go log collector

go-log-client

build:

env GOOS=linux GOARCH=amd64 go build -o go-log-client.linux.bin src/logclient/go-log-client.go

run:

nohup ./go-log-client.linux.bin -server=127.0.0.1 -port=10811 -log=et:/Users/bingoo/gitlab/et-server/et.log,ab:/Users/bingoo/gitlab/ab.log > go-log-client.out 2>&1 &

go-log-server

build:

env GOOS=linux GOARCH=amd64 go build -o go-log-server.linux.bin src/logserver/go-log-server.go

run:

nohup ./go-log-server.linux.bin -port=10811 > go-log-server.out 2>&1 &

All the logs collected from go-log-client will append to related log files with specified naming, like et.log, ab.log and etc.

image

go-dbsync's People

Contributors

bingoohuang avatar zhangcunxin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.