Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify build by converting to go mod #105

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ result.db.*
dump.data
runtime.trace

bin/redis-full-check
bin/

.DS_Store

Expand Down
47 changes: 33 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
Redis-full-check is used to compare whether two redis have the same data. We also offer a data synchronization tool called [redis-shake](https://github.com/aliyun/redis-shake) to syncing data from one redis to another redis.<br>
Thanks to the Douyu's WSD team for the support. <br>
Redis-full-check is used to compare whether two redis have the same data. We
also offer a data synchronization tool called
[redis-shake](https://github.com/aliyun/redis-shake) to syncing data from one
redis to another redis.<br> Thanks to the Douyu's WSD team for the support.
<br>

* [中文文档](https://yq.aliyun.com/articles/690463)
* [下载地址 redis-full-check.tar.gz](https://github.com/alibaba/RedisFullCheck/releases)
* [第一次使用,如何进行配置](https://github.com/alibaba/RedisFullCheck/wiki/%E7%AC%AC%E4%B8%80%E6%AC%A1%E4%BD%BF%E7%94%A8%EF%BC%8C%E5%A6%82%E4%BD%95%E8%BF%9B%E8%A1%8C%E9%85%8D%E7%BD%AE%EF%BC%9F)

# redis-full-check
---
Redis-full-check is developed and maintained by NoSQL Team in Alibaba-Cloud Database department.<br>
Redis-full-check performs full data verification by comparing the data of the source database and the destination database. The entire check process consists of multiple comparisons, in every comparison, redis-full-check fetches data from two dabatases and then compared, the inconsistent data is put into sqlite3 db for the next comparison. By this iteratively comparing method, the difference continues to converge. The following figure shows the dataflow. In every comparison which is the yellow box, redis-full-check fetches all keys firstly. After that, it runs comparison and stores the difference result(key and field) into the sqlite3 db which is the position that keys and fields can be fetched in next round instead of the source database.<br>
--- Redis-full-check is developed and maintained by NoSQL Team in Alibaba-Cloud
Database department.<br> Redis-full-check performs full data verification by
comparing the data of the source database and the destination database. The
entire check process consists of multiple comparisons, in every comparison,
redis-full-check fetches data from two dabatases and then compared, the
inconsistent data is put into sqlite3 db for the next comparison. By this
iteratively comparing method, the difference continues to converge. The
following figure shows the dataflow. In every comparison which is the yellow
box, redis-full-check fetches all keys firstly. After that, it runs comparison
and stores the difference result(key and field) into the sqlite3 db which is
the position that keys and fields can be fetched in next round instead of the
source database.<br>
![dataflow.png](https://github.com/aliyun/redis-full-check/blob/master/resources/dataflow.png)<br>
Redis-full-check fetches keys from source and then checks these keys exist on the target. So if one key exists on the target but lack on the source, redis-full-check can't find it. If you want to know whether the data in the source and destination databases are exactly the same, you need to set up a bidirectional link: <br>
Redis-full-check fetches keys from source and then checks these keys exist on
the target. So if one key exists on the target but lack on the source,
redis-full-check can't find it. If you want to know whether the data in the
source and destination databases are exactly the same, you need to set up a
bidirectional link: <br>

* source->RedisFullCheck->target
* target->RedisFullCheck->source
Expand Down Expand Up @@ -75,13 +91,16 @@ Help Options:

# Usage
---
Run `./bin/redis-full-check.darwin64` or `redis-full-check.linux64` which is built in OSX and Linux respectively, however, the binaries aren't always the newest version.<br>
Or you can build redis-full-check yourself according to the following steps:<br>
* git clone https://github.com/alibaba/RedisFullCheck.git
* cd RedisFullCheck/src/vendor
* GOPATH=\`pwd\`/../..; govendor sync #please note: must install govendor first and then pull all dependencies
* cd ../../ && ./build.sh
* ./redis-full-check -s $(source_redis_ip_port) -p $(source_password) -t $(target_redis_ip_port) -a $(target_password) # these parameters should be given by users
Run `./bin/redis-full-check.darwin64` or `redis-full-check.linux64` which is
built in OSX and Linux respectively, however, the binaries aren't always the
newest version.
If you wish to build redis-full-check on your own, you may follow the instructions
as follows:

- git clone https://github.com/alibaba/RedisFullCheck.git
- cd RedisFullCheck/
- ./build.sh
- ./bin/redis-full-check -s $(source_redis_ip_port) -p $(source_password) -t $(target_redis_ip_port) -a $(target_password) # these parameters should be given by users

Here comes the sqlite3 example to display the conflict result:<br>
```
Expand Down Expand Up @@ -113,5 +132,5 @@ We also provide some tools for synchronization in Shake series.<br>
* [RedisShake](https://github.com/aliyun/RedisShake): redis data synchronization tool.
* [RedisFullCheck](https://github.com/aliyun/RedisFullCheck): redis data synchronization verification tool.

Plus, we have a DingDing(钉钉) group so that users can join and discuss, please scan the code.
Plus, we have a DingDing(钉钉) group so that users can join and discuss, please scan the code.
![DingDing](resources/dingding_group.png)<br>
25 changes: 12 additions & 13 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

set -o errexit

export GOARCH=amd64
export CGO_ENABLED=1
# older version Git don't support --short !
if [ -d ".git" ];then
#branch=`git symbolic-ref --short -q HEAD`
Expand All @@ -17,9 +18,6 @@ branch=$branch","$cid
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

GOPATH=$(pwd)
export GOPATH

info="main.VERSION=$branch"
# golang version
goversion=$(go version | awk -F' ' '{print $3;}')
Expand All @@ -40,15 +38,16 @@ rm -rf ${output}
echo "[ BUILD RELEASE ]"
run_builder='go build -v'
#goos=(windows darwin linux)
#for g in "${goos[@]}"; do
# export GOOS=$g
# echo "try build goos=$g"
# $run_builder -ldflags "-X $info" -o "$output/redis-full-check.$g" "./src/full_check/"
# echo "build successfully!"
#done
goos=(darwin linux)
for g in "${goos[@]}"; do
export GOOS=$g
echo "try build goos=$g"
$run_builder -ldflags "-X $info" -o "$output/redis-full-check.$g" "main.go"
echo "build successfully!"
done

#echo "all build successfully!"
echo "all build successfully!"


$run_builder -ldflags "-X $info" -o "$output/redis-full-check" "./src/full_check/"
echo "build successfully!"
#$run_builder -ldflags "-X $info" -o "$output/redis-full-check" "main.go"
#echo "build successfully!"
6 changes: 3 additions & 3 deletions src/full_check/checker/base.go → full_check/checker/base.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package checker

import (
"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/common"
"sync"
"full_check/metric"
"full_check/client"
"github.com/alibaba/RedisFullCheck/full_check/metric"
"github.com/alibaba/RedisFullCheck/full_check/client"
)

type FullCheckParameter struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package checker

import (
"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/common"
"bytes"
"full_check/metric"
"full_check/client"
"github.com/alibaba/RedisFullCheck/full_check/metric"
"github.com/alibaba/RedisFullCheck/full_check/client"
"strconv"
"reflect"
"math"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package checker

import (
"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/common"
"sync"
"full_check/metric"
"full_check/client"
"github.com/alibaba/RedisFullCheck/full_check/metric"
"github.com/alibaba/RedisFullCheck/full_check/client"
)

type KeyOutlineVerifier struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package checker

import (
"full_check/metric"
"full_check/common"
"full_check/client"
"github.com/alibaba/RedisFullCheck/full_check/metric"
"github.com/alibaba/RedisFullCheck/full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/client"
)

func NewValueOutlineVerifier(stat *metric.Stat, param *FullCheckParameter) *ValueOutlineVerifier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"fmt"

"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/common"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"
"errors"

"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/common"

"github.com/garyburd/redigo/redis"
redigoCluster "github.com/vinllen/redis-go-cluster"
Expand Down
2 changes: 1 addition & 1 deletion src/full_check/client/db.go → full_check/client/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strconv"
"fmt"

"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/common"

"github.com/garyburd/redigo/redis"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"sync"
"time"

"full_check/common"
"full_check/metric"
"full_check/checker"
"full_check/configure"
"full_check/client"
"github.com/alibaba/RedisFullCheck/full_check/checker"
"github.com/alibaba/RedisFullCheck/full_check/client"
"github.com/alibaba/RedisFullCheck/full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/configure"
"github.com/alibaba/RedisFullCheck/full_check/metric"

_ "github.com/mattn/go-sqlite3"
)
Expand Down Expand Up @@ -232,12 +232,12 @@ func (p *FullCheck) Start() {
panic(common.Logger.Critical(err))
}

common.Logger.Infof("sourceDbType=%v, p.sourcePhysicalDBList=%v", p.FullCheckParameter.SourceHost.DBType,
common.Logger.Infof("sourceDbType=%v, p.sourcePhysicalDBList=%v", p.SourceHost.DBType,
p.sourcePhysicalDBList)

sourceClient.Close()
for db, keyNum := range p.sourceLogicalDBMap {
if p.SourceHost.IsCluster() == true {
if p.SourceHost.IsCluster() {
common.Logger.Infof("db=%d:keys=%d(inaccurate for type cluster)", db, keyNum)
} else {
common.Logger.Infof("db=%d:keys=%d", db, keyNum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"strconv"
"fmt"

"full_check/common"
"full_check/client"
"github.com/alibaba/RedisFullCheck/full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/client"

"github.com/jinzhu/copier"
"sync"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package metric
import (
"fmt"
"sync/atomic"
"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/common"
)

type CounterStat struct {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package metric

import (
"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/common"
)

type Stat struct {
Expand Down
21 changes: 21 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module github.com/alibaba/RedisFullCheck

go 1.17

require (
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575
github.com/garyburd/redigo v1.6.3
github.com/gugemichael/nimo4go v0.0.0-20210413043712-ccb2ff0d7b40
github.com/jessevdk/go-flags v1.5.0
github.com/jinzhu/copier v0.3.5
github.com/mattn/go-sqlite3 v1.14.10
github.com/stretchr/testify v1.7.0
github.com/vinllen/redis-go-cluster v1.0.1-0.20200120220710-4e63c4a1b59e
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
27 changes: 27 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 h1:kHaBemcxl8o/pQ5VM1c8PVE1PubbNx3mjUr09OqWGCs=
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575/go.mod h1:9d6lWj8KzO/fd/NrVaLscBKmPigpZpn5YawRPw+e3Yo=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/garyburd/redigo v1.6.3 h1:HCeeRluvAgMusMomi1+6Y5dmFOdYV/JzoRrrbFlkGIc=
github.com/garyburd/redigo v1.6.3/go.mod h1:rTb6epsqigu3kYKBnaF028A7Tf/Aw5s0cqA47doKKqw=
github.com/gugemichael/nimo4go v0.0.0-20210413043712-ccb2ff0d7b40 h1:6TWAiHVyKs75ZHEn7XtVv7SO7M4rHwvY/5Tf7xdJBkc=
github.com/gugemichael/nimo4go v0.0.0-20210413043712-ccb2ff0d7b40/go.mod h1:ibO7uKpO8fOH/bKD4trmwm5tHhHKiAjC0u288Rd+GnI=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/vinllen/redis-go-cluster v1.0.1-0.20200120220710-4e63c4a1b59e h1:Pdu80G0wLCY9Tx5hpBubuhhcCUCvbzuGMsk65lLliBQ=
github.com/vinllen/redis-go-cluster v1.0.1-0.20200120220710-4e63c4a1b59e/go.mod h1:xig5hQAOZX1K+KNUVDqAbhTRzMTPcb257nJl7OCHrI4=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10 changes: 5 additions & 5 deletions src/full_check/main.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"strconv"
"strings"

"full_check/configure"
"full_check/full_check"
"full_check/checker"
"full_check/client"
"full_check/common"
"github.com/alibaba/RedisFullCheck/full_check/configure"
"github.com/alibaba/RedisFullCheck/full_check/full_check"
"github.com/alibaba/RedisFullCheck/full_check/checker"
"github.com/alibaba/RedisFullCheck/full_check/client"
"github.com/alibaba/RedisFullCheck/full_check/common"

"github.com/jessevdk/go-flags"
"github.com/gugemichael/nimo4go"
Expand Down
Loading