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

How to restore a Redis Bloom Filter key from an RDB file to a remote redis server? #317

Open
Damanchen opened this issue Jun 2, 2021 · 9 comments
Labels

Comments

@Damanchen
Copy link

We can use ‘set’ to restore a string type key from RDB file to remote redis server, or use ‘hset’ to restore hash type key ...

But, how to restore a bloom filter key from RDB file to remote redis server ?

According to https://github.com/sripathikrishnan/redis-rdb-tools and RedisBloom source code, I can get the following information about bloom key in rdb file:

RDB binary file about bloom filter key:
0201 0201 0205 0202 0240 6404 7b14 ae47 e17a 743f 0208 04e9 862f b235 0e26 4002 4480 0200 05c3 3340 9001 0000 e024 0000 01e0 002d 0002 e000 09e0 0700 0004 e000 1000 08e0 0009 0010 e000 0900 20e0 0009 0040 e000 0900 80c0 0901 0000 0201 00

means:
size 0201
nfilters 0201
options 0205
growth 0202
entries(capacity) 0240 64
error(ratio) 04 7b14 ae47 e17a 743f
hashes 0208
bpe 04e9 862f b235 0e26 40
bits 02 4480
n2 0200
Chunk ? 05c3 3340 9001 0000 e024 0000 01e0 002d 0002 e000 09e0 0700 0004 e000 1000 08e0 0009 0010 e000 0900 20e0 0009 0040 e000 0900 80c0 0901 0000
size 0201
end 00

After lzf_decompress of the part of 'Chunk' , we can get following content:
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00

It is as same as the content we get by 'bf.scandump bfkey 1' command,maybe I can restore this part of content to remote redis server by 'bf.loadchunk bfkey xx' ; (Am I right ??)

The question is how to restore other information about bloom filter key in the RDB file, can enyone help me ? thanks a lot ~

@gkorland
Copy link
Contributor

gkorland commented Jun 2, 2021

You can use DUMP/RESTORE.
https://redis.io/commands/dump
https://redis.io/commands/restore

@Damanchen
Copy link
Author

Damanchen commented Jun 2, 2021

Thanks for your promptly reply.

When redis server is running, 'dump' and 'restore' command can do this;

But, if I want to restore data from an RDB file to a remote redis server (Such as a disaster recovery scenario), 'dump' and 'restore' is useless...

@gkorland
Copy link
Contributor

gkorland commented Jun 2, 2021

if you already have an RDB just load the server with this RDB

@Damanchen
Copy link
Author

I want to restore RDB file to a remote Redis server, not local server, so can't just use RDB file to load.

I would like to know if there is a command to set the RDB content about the Bloom filter key to the remote Redis server. For example, we can use 'set' command to set a string key parsed from an RDB file to a remote Redis server, or use 'hset' command to set a hash key .

@Damanchen
Copy link
Author

Do I have to modify the source code to implement this feature? Any better suggestions?

@ashtul
Copy link
Contributor

ashtul commented Jun 6, 2021

@Damanchen RedisBlomm has BF.SCANDUMP and BF.LOADCHUNK which you can find here.
You can then save the filter, transport it and load it into another server.

@Damanchen
Copy link
Author

@ashtul Thanks for your reply.

When the Redis server is running, BF.SCANDUMP and BF.LOADCHUNK can save the filter, transport it and load it into another server.

But, when I only have the rdb file ,how can I load the bloom filter key to a remote Redis server ??

Has anyone encountered similar situations and problems?

@Damanchen Damanchen changed the title How to restore a Redis Bloom Filter key from an RDB file to remote redis server? How to restore a Redis Bloom Filter key from an RDB file to a remote redis server? Jun 17, 2021
@rvencu
Copy link

rvencu commented Dec 9, 2021

I believe the answer would be: make a local instance from rdb file then scandump locally and loadchunk remotely... I played with a python script that can be easily adapted to loadchunk remotely when the dump is saved on some local files
https://github.com/rvencu/crawlingathome-gpu-hcloud/blob/main/helpers/bloomexport.py

@631086083
Copy link

631086083 commented Mar 27, 2023

hello,I don’t know if it’s late. I wrote a program to load BloomFilter from offline rdb to remote Redis. It is currently under development and testing. @Damanchen
https://github.com/KCacheTeam/redis-proxy-resharding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants