redis-migrate(迁移)
redis数据如何同步到其他redis…
env
- redis-4.x
- container
- single->single
redis-shake(alibaba)
#docs
基本上疑难杂症都可以得到解决的或者issue
1.pull images && run single redis
//pull
podman pull redis:4.0-alpine
//run
podman run --rm -d -p 6310:6379 --name redis1 redis:4.0-alpine
podman run --rm -d -p 6320:6379 --name redis2 redis:4.0-alpine
//ps
podman rm -f $(podman ps -qa)
2.add key to redis1
podman exec -it redis1 sh
vi add.sh
#add.sh
|
|
3.download redisShake && run
#sync
bang@gaga-90:~/tmp> egrep -v '^#|^$' sync.toml
...
type = "sync"
[source]
version = 4.0 # redis version, such as 2.8, 4.0, 5.0, 6.0, 6.2, 7.0, ...
address = "127.0.0.1:6310"
[target]
type = "standalone" # "standalone" or "cluster"
version = 4.0 # redis version, such as 2.8, 4.0, 5.0, 6.0, 6.2, 7.0, ...
address = "127.0.0.1:6320"
...
注意redis的src/target version
#log
bang@gaga-90:~/tmp> ./redis-shake sync.toml
2022-12-02 22:55:58 INF GOOS: linux, GOARCH: amd64
2022-12-02 22:55:58 INF Ncpu: 4, GOMAXPROCS: 4
2022-12-02 22:55:58 INF pid: 2741
2022-12-02 22:55:58 INF pprof_port: 0
2022-12-02 22:55:58 INF No lua file specified, will not filter any cmd.
2022-12-02 22:55:58 INF no password. address=[127.0.0.1:6320]
2022-12-02 22:55:58 INF redisWriter connected to redis successful. address=[127.0.0.1:6320]
2022-12-02 22:55:58 INF no password. address=[127.0.0.1:6310]
2022-12-02 22:55:58 INF psyncReader connected to redis successful. address=[127.0.0.1:6310]
2022-12-02 22:55:58 INF start save RDB. address=[127.0.0.1:6310]
2022-12-02 22:55:58 INF send [replconf listening-port 10007]
2022-12-02 22:55:58 INF send [PSYNC ? -1]
2022-12-02 22:55:58 INF receive [FULLRESYNC 0454d6d4f93e7a5de4c8cd99b8e376a4838e2ebf 0]
2022-12-02 22:55:58 INF source db is doing bgsave. address=[127.0.0.1:6310]
2022-12-02 22:55:58 INF source db bgsave finished. timeUsed=[0.04]s, address=[127.0.0.1:6310]
2022-12-02 22:55:58 INF received rdb length. length=[19282]
2022-12-02 22:55:58 INF create dump.rdb file. filename_path=[dump.rdb]
2022-12-02 22:55:58 INF save RDB finished. address=[127.0.0.1:6310], total_bytes=[19282]
2022-12-02 22:55:58 INF start send RDB. address=[127.0.0.1:6310]
2022-12-02 22:55:58 INF RDB version: 8
2022-12-02 22:55:58 INF RDB AUX fields. key=[redis-ver], value=[4.0.14]
2022-12-02 22:55:58 INF RDB AUX fields. key=[redis-bits], value=[64]
2022-12-02 22:55:58 INF RDB AUX fields. key=[ctime], value=[1669992958]
2022-12-02 22:55:58 INF RDB AUX fields. key=[used-mem], value=[1956944]
2022-12-02 22:55:58 INF RDB repl-stream-db: 0
2022-12-02 22:55:58 INF RDB AUX fields. key=[repl-id], value=[0454d6d4f93e7a5de4c8cd99b8e376a4838e2ebf]
2022-12-02 22:55:58 INF RDB AUX fields. key=[repl-offset], value=[0]
2022-12-02 22:55:58 INF RDB AUX fields. key=[aof-preamble], value=[0]
2022-12-02 22:55:58 INF start save AOF. address=[127.0.0.1:6310]
2022-12-02 22:55:58 INF AOFWriter open file. filename=[0.aof]
2022-12-02 22:55:58 INF RDB resize db. db_size=[300], expire_size=[0]
2022-12-02 22:55:58 INF send RDB finished. address=[127.0.0.1:6310], repl-stream-db=[0]
2022-12-02 22:55:59 INF AOFReader open file. aof_filename=[0.aof]
2022-12-02 22:56:03 INF syncing aof. allowOps=[60.20], disallowOps=[0.00], entryId=[300], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[0], aofReceivedOffset=[14], aofAppliedOffset=[14]
2022-12-02 22:56:08 INF syncing aof. allowOps=[0.00], disallowOps=[0.00], entryId=[300], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[0], aofReceivedOffset=[14], aofAppliedOffset=[14]
2022-12-02 22:56:13 INF syncing aof. allowOps=[0.20], disallowOps=[0.00], entryId=[301], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[0], aofReceivedOffset=[28], aofAppliedOffset=[28]
2022-12-02 22:56:18 INF syncing aof. allowOps=[0.00], disallowOps=[0.00], entryId=[301], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[0], aofReceivedOffset=[28], aofAppliedOffset=[28]
2022-12-02 22:56:23 INF syncing aof. allowOps=[0.00], disallowOps=[0.00], entryId=[301], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[14], aofReceivedOffset=[42], aofAppliedOffset=[28]
2022-12-02 22:56:28 INF syncing aof. allowOps=[0.20], disallowOps=[0.00], entryId=[302], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[0], aofReceivedOffset=[42], aofAppliedOffset=[42]
2022-12-02 22:56:33 INF syncing aof. allowOps=[0.00], disallowOps=[0.00], entryId=[302], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[0], aofReceivedOffset=[42], aofAppliedOffset=[42]
2022-12-02 22:56:38 INF syncing aof. allowOps=[0.20], disallowOps=[0.00], entryId=[303], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[0], aofReceivedOffset=[56], aofAppliedOffset=[56]
2022-12-02 22:56:43 INF syncing aof. allowOps=[0.00], disallowOps=[0.00], entryId=[303], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, diff=[0], aofReceivedOffset=[56], aofAppliedOffset=[56]
//日志
allowOps=[0.00] 后者 0.x标识已经同步完毕
4.check
podman exec -it redis2 redis-cli dbsize