将Redis DB导入Kubernetes上的其他Redis群集

发布于 2025-01-31 20:58:33 字数 86 浏览 3 评论 0原文

我在Kubernetes中有状态填充群。
我想导入将othet redis带到此redis群集的dump.rdb文件。导入此转储文件的最佳方法是什么?

I have statefulset redis cluster in kubernetes.
I want to import dump.rdb file which is taken othet redis to this redis cluster . what is the best way to import this dump file ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

め可乐爱微笑 2025-02-07 20:58:33

它可能很丑陋,但可以工作

1-用您的转储文件创建一个配置毫米(不知道dump.rdb是否是二进制文件,我认为这不是二进制文件,但是如果这是二进制文件,请遵循以下操作: 我如何将二进制文件存储在kubernetes中configmap?),您可以以命令的方式进行此操作:

kubectl create configmap dump --from-file dump.rdb

2-在您的状态填充中像这样:

...
        volumeMounts:
        - name: "dump"
          mountPath: "/DUMP_LOCATION/dump.rdb"
          subPath: "dump.rdb"
      volumes:
        - name: "dump"
          configMap:
            name: "dump"
...

3-创建,以相同的方式来安装redis配置文件(如果还没有完成,如果您应该做的话)。

4-在您的配置文件中,更改为以下参数,告诉redis使用dump.rdb文件的新位置。您刚刚安装的RDB文件:

# path to the dump file
dbfilename dump.rdb

# The working directory (not a file) where DB will be written inside, with the filename specified
# above (dbfilename) configuration directive.
# 
dir /data/mydirectory/

在使用新配置重新启动您的状态填充之后,应该是这样,请告诉我是否有效

It may be ugly but can work

1- Create a configmap with your dump file in it ( don't know if the dump.rdb is a binary file or not, I assume this is not but if this is a binary file follow this: How can I store a binary file in a Kubernetes ConfigMap?), you can do this in an imperative manner for example with:

kubectl create configmap dump --from-file dump.rdb

2- Mount it like this in your statefulset:

...
        volumeMounts:
        - name: "dump"
          mountPath: "/DUMP_LOCATION/dump.rdb"
          subPath: "dump.rdb"
      volumes:
        - name: "dump"
          configMap:
            name: "dump"
...

3- Create, in the same way a configmap to mount the redis configuration file ( if not already done, if not you should).

4- In you configuration file, change to following parameters to tell redis to use the new location of the dump.rdb file you just mounted:

# path to the dump file
dbfilename dump.rdb

# The working directory (not a file) where DB will be written inside, with the filename specified
# above (dbfilename) configuration directive.
# 
dir /data/mydirectory/

After this restart your statefulset with the new configuration and it should be it, tell me if this worked

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文