Skip to content

几个使用中疑问 #949

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

Open
gitjacky opened this issue Apr 16, 2025 · 6 comments
Open

几个使用中疑问 #949

gitjacky opened this issue Apr 16, 2025 · 6 comments
Labels
type: question Further information is requested

Comments

@gitjacky
Copy link

gitjacky commented Apr 16, 2025

问题描述(Issue Description)

由自建redis集群A同步到另一个自建redis集群B。

使用sync_reader与redis_writer方式进行数据同步

配置文件:
[sync_reader]
cluster = true
version = 4.0
address = "192.168.12.8:6379"
username = ""
password = ""
sync_rdb = true
sync_aof = true

[redis_writer]
cluster = true
address = "192.168.12.19:6379"
username = ""
password = ""

环境信息(Environment)

  • RedisShake 版本(RedisShake Version):4.4
  • Redis 源端版本(Redis Source Version):4.0
  • Redis 目的端版本(Redis Destination Version):4.0
  • Redis 部署方式(standalone/cluster/sentinel):cluster
  • 是否在云服务商实例上部署(Deployed on Cloud Provider):否

日志信息(Logs)

在运行工具进行数据同步时
./redis-shake shake.toml

看到有以下提示信息

2025-04-13 15:01:30 INF [reader_192.168.12.8_6379] source db is not doing bgsave! continue.
2025-04-13 15:01:30 INF [reader_192.168.12.9_6379] source db is not doing bgsave! continue.
2025-04-13 15:01:30 INF [reader_192.168.12.15_6379] source db is not doing bgsave! continue.

有几个问题想确认下:
1、运行工具之前是否需要手工先在每个主节点执行bgsave生成rdb文件?还是说4.4会自动执行bgsave。
2、是否要redis集群中每个主节点都创建一个单独目录,启动一个单独的redis-shake进程,一个集群几百个节点怎么搞?还是说一个集群只启动一个进程就可以。
3、建议集群同步时配置文件中使用slave节点,还是master节点?各有什么风险?

其他信息(Additional Information)

@gitjacky gitjacky added the type: question Further information is requested label Apr 16, 2025
@suxb201
Copy link
Member

suxb201 commented Apr 23, 2025

请阅读文档

@GHrjf
Copy link

GHrjf commented Apr 23, 2025

您的问题解决了么,我这里也遇到了,手动执行了bgsave ,也没同步。还是有这个日志 [reader_172.31.88.110_6379] source db is not doing bgsave! continue

Image

@gitjacky
Copy link
Author

gitjacky commented Apr 23, 2025

`[sync_reader] cluster = false # set to true if source is a redis cluster address = "172.31.88.110:6379" # when cluster is true, set address to one of the cluster node password = "Sjpt@2025#@!" # keep empty if no authentication is required tls = false sync_rdb = true # set to false if you don't want to sync rdb sync_aof = false # set to false if you don't want to sync aof

[redis_writer] cluster = false # set to true if target is a redis cluster address = "172.25.214.49:6379" # when cluster is true, set address to one of the cluster node password = "Sjpt@2025#@!" # keep empty if no authentication is required tls = false

[advanced] log_file = "shake.log" # 日志文件路径 log_level = "info" # 日志级别:info pipeline_count_limit = 1024 # 默认管道大小

rdb_restore_command_behavior = "rewrite" # 遇到重复键时覆盖 ` 我现在的做法是将sync_aof 改成 false,然后数据同步过去了

看文档是这样说

原理:RedisShake 模拟 Slave 连接到 Master 节点,Master 会向 RedisShake 发送数据,数据包含全量与增量两部分。全量是一个 RDB 文件,增量是 AOF 数据流,RedisShake 会接受全量与增量将其暂存到硬盘上。全量同步阶段:RedisShake 首先会将 RDB 文件解析为一条条的 Redis 命令,然后将这些命令发送至目的端。增量同步阶段:RedisShake 会持续将 AOF 数据流同步至目的端。

说是rdb文件暂存在本地,实际看只有aof文件在,没有 看到rdb文件。文档对这一点写的有点简略。

@suxb201
Copy link
Member

suxb201 commented Apr 24, 2025

@GHrjf @gitjacky

  1. “source db is not doing bgsave! continue.” 这条日志代表正常状态。表述确实有歧义,欢迎 PR 修改下。

@gitjacky 本地 aof 和 rdb 都会有的,你要不 tree 看看目录结构?

@gitjacky
Copy link
Author

gitjacky commented Apr 24, 2025

@GHrjf @gitjacky

  1. “source db is not doing bgsave! continue.” 这条日志代表正常状态。表述确实有歧义,欢迎 PR 修改下。

@gitjacky 本地 aof 和 rdb 都会有的,你要不 tree 看看目录结构?

//定义结构体方法checkBgsaveInProgress,用于检查BGSAVE是否正在进行
// When BGSAVE is triggered by the source Redis itself, synchronization is blocked, so need to check it
func (r *syncStandaloneReader) checkBgsaveInProgress() {
	for {
		select {
		case <-r.ctx.Done():
			close(r.ch)
			runtime.Goexit() // stop goroutine
		default:
			argv := []interface{}{"INFO", "persistence"}
			r.client.Send(argv...)
			receiveString := r.client.ReceiveString()
			if strings.Contains(receiveString, "rdb_bgsave_in_progress:1") || strings.Contains(receiveString, "aof_rewrite_in_progress:1") {
				log.Warnf("[%s] source db is doing bgsave, waiting for a while.", r.stat.Name)
			} else {
				log.Infof("[%s] source db is not doing bgsave! continue.", r.stat.Name)
				return
			}
			time.Sleep(1 * time.Second)
		}
	}
}
// 定义结构体方法sendPSync
func (r *syncStandaloneReader) sendPSync() {
	if r.opts.TryDiskless {
		argv := []interface{}{"REPLCONF", "CAPA", "EOF"}
		reply := r.client.DoWithStringReply(argv...)
		if reply != "OK" {
			log.Warnf("[%s] send replconf capa eof to redis server failed. reply=[%v]", r.stat.Name, reply)
		} else {
			r.isDiskless = true
		}
	}
	r.checkBgsaveInProgress() // 检查BGSAVE是否正在进行
	// send PSync

看代码这里是检查源端主节点是不是正在做bgsave操作,如果正在做就等待,如果没在做就继续往下执行。

@suxb201
Copy link
Member

suxb201 commented Apr 24, 2025

对,修改下这个 info 中的描述就好,看起来别像报错:
log.Infof("[%s] source db is not doing bgsave! continue.", r.stat.Name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants