简体   繁体   English

k8s集群如何做redis slave repalation?

[英]How to do Redis slave repalication in k8s cluster?

By this famous guestbook example:通过这个著名的留言簿示例:

https://github.com/kubernetes/examples/tree/master/guestbookhttps://github.com/kubernetes/examples/tree/master/guestbook

It will create Redis master/slave deployment and services.它将创建 Redis 主/从部署和服务。 It also has a subfolder named redis-slave which used for create a docker image and run Redis replication command.它还有一个名为redis-slave的子文件夹,用于创建 docker 镜像和运行 Redis 复制命令。

  • Dockerfile文件
  • run.sh运行文件

The question is, if deployed the Redis master and slave to the k8s cluster.问题是,如果将Redis master和slave部署到k8s集群。 Then how to run that command?那么如何运行该命令? Deploy a new container?部署一个新容器? That will not relate to the slave container already deployed.这与已经部署的从属容器无关。

Is there a better way to do Redis repliaciton between master and slave running in k8s cluster?有没有更好的方法来在 k8s 集群中运行的主从之间进行 Redis 复制?

One option you have is using helm to deploy the redis-ha app.您拥有的一种选择是使用helm部署redis-ha应用程序。

Info about helm: https://github.com/kubernetes/helm关于 helm 的信息: https : //github.com/kubernetes/helm

The redis-ha helm app page: https://hub.kubeapps.com/charts/stable/redis-ha redis-ha helm 应用页面: https : //hub.kubeapps.com/charts/stable/redis-ha

Redis Sentinel is often suggested for simple master-slave replication and high availability. Redis Sentinel通常被建议用于简单的主从复制和高可用性。

Unfortunately, Sentinel does not fit Kubernetes world well and it also requires a Sentinel-aware client to talk to Redis.不幸的是,Sentinel 并不适合 Kubernetes 世界,它还需要一个 Sentinel-aware 客户端来与 Redis 对话。

You could try Redis operator which can be considered a Kubernetes-native replacement for Sentinel and allows to create a Redis deployment that would resist without human intervention to most kind of failures.您可以尝试使用Redis 操作符,它可以被认为是 Sentinel 的 Kubernetes 原生替代品,并允许创建一个 Redis 部署,无需人工干预即可抵抗大多数类型的故障。

Here is how you can setup Redis HA Master Slave Cluster in Kubernetes/Openshift OKD以下是如何在 Kubernetes/Openshift OKD 中设置 Redis HA Master Slave Cluster

Basically you have to use configMap, StatefulSet in collaboration with VolumeClaims基本上你必须使用 configMap、StatefulSet 和 VolumeClaims

https://reachmnadeem.wordpress.com/2020/10/01/redis-ha-master-slave-cluster-up-and-running-in-openshift-okd-kubernetes/ https://reachmnadeem.wordpress.com/2020/10/01/redis-ha-master-slave-cluster-up-and-running-in-openshift-okd-kubernetes/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM