Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package reader | ||
|
||
import ( | ||
"github.com/alibaba/RedisShake/internal/entry" | ||
"github.com/alibaba/RedisShake/internal/log" | ||
"github.com/alibaba/RedisShake/internal/rdb" | ||
"path/filepath" | ||
) | ||
|
||
type rdbReader struct { | ||
path string | ||
ch chan *entry.Entry | ||
} | ||
|
||
func NewRDBReader(path string) Reader { | ||
log.Infof("NewRDBReader: path=[%s]", path) | ||
absolutePath, err := filepath.Abs(path) | ||
if err != nil { | ||
log.Panicf("NewRDBReader: filepath.Abs error: %s", err.Error()) | ||
} | ||
log.Infof("NewRDBReader: absolute path=[%s]", absolutePath) | ||
r := new(rdbReader) | ||
r.path = absolutePath | ||
return r | ||
} | ||
|
||
func (r *rdbReader) StartRead() chan *entry.Entry { | ||
r.ch = make(chan *entry.Entry, 1024) | ||
|
||
go func() { | ||
// start parse rdb | ||
log.Infof("start send RDB. path=[%s]", r.path) | ||
rdbLoader := rdb.NewLoader(r.path, r.ch) | ||
_ = rdbLoader.ParseRDB() | ||
log.Infof("send RDB finished. path=[%s]", r.path) | ||
close(r.ch) | ||
}() | ||
|
||
return r.ch | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[source] | ||
type = "restore" # sync, restore | ||
# Path to the dump.rdb file. Absolute path or relative path. Note | ||
# that relative paths are relative to the dir directory. | ||
rdb_file_path = "dump.rdb" | ||
|
||
[target] | ||
type = "standalone" # standalone or cluster | ||
# When the target is a cluster, write the address of one of the nodes. | ||
# redis-shake will obtain other nodes through the `cluster nodes` command. | ||
address = "127.0.0.1:6379" | ||
username = "" # keep empty if not using ACL | ||
password = "" # keep empty if no authentication is required | ||
tls = false | ||
|
||
[advanced] | ||
dir = "data" | ||
|
||
# runtime.GOMAXPROCS, 0 means use runtime.NumCPU() cpu cores | ||
ncpu = 3 | ||
|
||
# pprof port, 0 means disable | ||
pprof_port = 0 | ||
|
||
# log | ||
log_file = "redis-shake.log" | ||
log_level = "info" # debug, info or warn | ||
log_interval = 5 # in seconds | ||
|
||
# redis-shake gets key and value from rdb file, and uses RESTORE command to | ||
# create the key in target redis. Redis RESTORE will return a "Target key name | ||
# is busy" error when key already exists. You can use this configuration item | ||
# to change the default behavior of restore: | ||
# panic: redis-shake will stop when meet "Target key name is busy" error. | ||
# rewrite: redis-shake will replace the key with new value. | ||
# ignore: redis-shake will skip restore the key when meet "Target key name is busy" error. | ||
rdb_restore_command_behavior = "rewrite" # panic, rewrite or skip | ||
|
||
# pipeline | ||
pipeline_count_limit = 1024 | ||
|
||
# Client query buffers accumulate new commands. They are limited to a fixed | ||
# amount by default. This amount is normally 1gb. | ||
target_redis_client_max_querybuf_len = 1024_000_000 | ||
|
||
# In the Redis protocol, bulk requests, that are, elements representing single | ||
# strings, are normally limited to 512 mb. | ||
target_redis_proto_max_bulk_len = 512_000_000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters