make configuration items clearer

v4
suxb201 2 years ago
parent 99a1c80043
commit 0fd2c5d72f
  1. 10
      README.md
  2. 4
      build.sh
  3. 12
      cmd/redis-shake/main.go
  4. 10
      internal/config/config.go
  5. 3
      restore.toml
  6. 5
      sync.toml
  7. 3
      test/assets/empty.toml

@ -6,7 +6,6 @@
redis-shake is a tool for Redis data migration and data filtering.
## Feature
* 🚄 High performance
@ -16,7 +15,8 @@ redis-shake is a tool for Redis data migration and data filtering.
* 💖 Support `restore` mode and `sync` mode
* ☁ Support Aliyun Redis and ElastiCache
For older versions of redis-shake (support codis, twemproxy) please visit [here](https://github.com/alibaba/RedisShake/tree/develop).
For older versions of redis-shake (support codis, twemproxy) please
visit [here](https://github.com/alibaba/RedisShake/tree/develop).
![redis-shake2.PNG](https://s2.loli.net/2022/07/10/OZrSGutknlI8XNp.png)
@ -42,7 +42,7 @@ sh build.sh
## Usage
1. Edit `redis-shake.toml` or `restore.toml` and modify the source and target configuration items in it.
1. Edit `sync.toml` or `restore.toml`.
2. Start redis-shake.
```shell
@ -55,7 +55,7 @@ sh build.sh
## Configure
The redis-shake configuration file refers to `redis-shake.toml` or `restore.toml`.
The redis-shake configuration file refers to `sync.toml` or `restore.toml`.
## Data filtering
@ -63,7 +63,7 @@ redis-shake supports custom filtering rules using lua scripts. redis-shake can b
the following command:
```shell
./bin/redis-shake redis-shake.toml filter/xxx.lua
./bin/redis-shake sync.toml filter/xxx.lua
```
Some following filter templates are provided in `filter` directory:

@ -24,14 +24,14 @@ for g in "linux" "darwin"; do
done
done
cp redis-shake.toml "$BIN_DIR"
cp sync.toml "$BIN_DIR"
cp restore.toml "$BIN_DIR"
if [ "$1" == "dist" ]; then
echo "[ DIST ]"
cd bin
cp -r ../filters ./
tar -czvf ./redis-shake.tar.gz ./redis-shake.toml ./restore.toml ./redis-shake-* ./filters
tar -czvf ./redis-shake.tar.gz ./sync.toml ./restore.toml ./redis-shake-* ./filters
rm -rf ./filters
cd ..
fi

@ -17,11 +17,12 @@ import (
func main() {
if len(os.Args) < 2 || len(os.Args) > 3 {
fmt.Println("Usage: redis-shake <config file> <lua file>")
fmt.Println("Example: redis-shake config.toml lua.lua")
fmt.Println("Usage: redis-shake <config file> <filter file>")
fmt.Println("Example: redis-shake config.toml filter.lua")
os.Exit(1)
}
// load filter file
if len(os.Args) == 3 {
luaFile := os.Args[2]
filter.LoadFromFile(luaFile)
@ -40,6 +41,7 @@ func main() {
log.Infof("No lua file specified, will not filter any cmd.")
}
// start pprof
if config.Config.Advanced.PprofPort != 0 {
go func() {
err := http.ListenAndServe(fmt.Sprintf("localhost:%d", config.Config.Advanced.PprofPort), nil)
@ -64,12 +66,12 @@ func main() {
// create reader
source := &config.Config.Source
var theReader reader.Reader
if source.Type == "sync" {
if config.Config.Type == "sync" {
theReader = reader.NewPSyncReader(source.Address, source.Username, source.Password, source.IsTLS, source.ElastiCachePSync)
} else if source.Type == "restore" {
} else if config.Config.Type == "restore" {
theReader = reader.NewRDBReader(source.RDBFilePath)
} else {
log.Panicf("unknown source type: %s", source.Type)
log.Panicf("unknown source type: %s", config.Config.Type)
}
ch := theReader.StartRead()

@ -10,13 +10,15 @@ import (
)
type tomlSource struct {
Type string `toml:"type"`
// sync mode
Address string `toml:"address"`
Username string `toml:"username"`
Password string `toml:"password"`
IsTLS bool `toml:"tls"`
ElastiCachePSync string `toml:"elasticache_psync"`
RDBFilePath string `toml:"rdb_file_path"`
// restore mode
RDBFilePath string `toml:"rdb_file_path"`
}
type tomlTarget struct {
@ -49,6 +51,7 @@ type tomlAdvanced struct {
}
type tomlShakeConfig struct {
Type string
Source tomlSource
Target tomlTarget
Advanced tomlAdvanced
@ -57,8 +60,9 @@ type tomlShakeConfig struct {
var Config tomlShakeConfig
func init() {
Config.Type = "sync"
// source
Config.Source.Type = "sync"
Config.Source.Address = ""
Config.Source.Username = ""
Config.Source.Password = ""

@ -1,5 +1,6 @@
type = "restore"
[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"

@ -1,5 +1,6 @@
type = "sync"
[source]
type = "sync" # sync or restore
address = "127.0.0.1:6379"
username = "" # keep empty if not using ACL
password = "" # keep empty if no authentication is required
@ -7,7 +8,7 @@ tls = false
elasticache_psync = "" # using when source is ElastiCache. ref: https://github.com/alibaba/RedisShake/issues/373
[target]
type = "standalone" # standalone or cluster
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:6380"

@ -1,5 +1,6 @@
type = "sync"
[source]
type = "sync" # sync or restore
address = "127.0.0.1:6379"
username = "" # keep empty if not using ACL
password = "" # keep empty if no authentication is required

Loading…
Cancel
Save