gpt4 book ai didi

kubernetes - minikube 上的 RabbitMQ Cluster Kubernetes Operator

转载 作者:行者123 更新时间:2023-12-05 02:48:56 27 4
gpt4 key购买 nike

我正在尝试使用 RabbitMQ Cluster Operator 在 Minikube 上设置 RabbitMQ :

当我尝试附加持久卷时,出现以下错误:

$ kubectl logs -f rabbitmq-rabbitmq-server-0

Configuring logger redirection
20:04:40.081 [warning] Failed to write PID file "/var/lib/rabbitmq/mnesia/rabbit@rabbitmq-rabbitmq-server-0.rabbitmq-rabbitmq-headless.default.pid": permission denied
20:04:40.264 [error] Failed to create Ra data directory at '/var/lib/rabbitmq/mnesia/rabbit@rabbitmq-rabbitmq-server-0.rabbitmq-rabbitmq-headless.default/quorum/rabbit@rabbitmq-rabbitmq-server-0.rabbitmq-rabbitmq-headless.default', file system operation error: enoent
20:04:40.265 [error] Supervisor ra_sup had child ra_system_sup started with ra_system_sup:start_link() at undefined exit with reason {error,"Ra could not create its data directory. See the log for details."} in context start_error
20:04:40.266 [error] CRASH REPORT Process <0.247.0> with 0 neighbours exited with reason: {error,"Ra could not create its data directory. See the log for details."} in ra_system_sup:init/1 line 43
20:04:40.267 [error] CRASH REPORT Process <0.241.0> with 0 neighbours exited with reason: {{shutdown,{failed_to_start_child,ra_system_sup,{error,"Ra could not create its data directory. See the log for details."}}},{ra_app,start,[normal,[]]}} in application_master:init/4 line 138
{"Kernel pid terminated",application_controller,"{application_start_failure,ra,{{shutdown,{failed_to_start_child,ra_system_sup,{error,\"Ra could not create its data directory. See the log for details.\"}}},{ra_app,start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,ra,{{shutdown,{failed_to_start_child,ra_system_sup,{error,"Ra could not create its data directory. See the log for details."}

Crash dump is being written to: erl_crash.dump...

问题是由于缺少权限,RabbitMQ 无法在数据目录 /var/lib/rabbitmq/mnesia 中设置其数据文件。

我最初的猜测是我需要将数据目录指定为 volumeMount,但根据 documentation 这似乎不可配置.

RabbitMQ 的 troubleshooting关于持久性的文档导致 404 .

我试图在网上找到其他有同样问题的资源,但没有一个使用 RabbitMQ Cluster Operator。如果我找不到解决方案,我打算遵循这条路线,但我真的很想以某种方式解决这个问题。

有没有人有什么想法?

我的设置如下:

apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: rabbitmq
spec:
replicas: 1
service:
type: NodePort
persistence:
storageClassName: local-storage
storage: 20Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rabbitmq-pvc
spec:
storageClassName: local-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi

---
apiVersion: v1
kind: PersistentVolume
metadata:
name: rabbitmq-pv
spec:
storageClassName: local-storage
accessModes:
- ReadWriteOnce
capacity:
storage: 20Gi
hostPath:
path: /mnt/app/rabbitmq
type: DirectoryOrCreate

要在 minikube 上重现此问题:

  1. 安装rabbitmq operator:
kubectl apply -f "https://github.com/rabbitmq/cluster-operator/releases/latest/download/cluster-operator.yml"
  1. 应用上面的 list 文件
kubectl apply -f rabbitmq.yml
  1. 运行 kubectl get po 显示名为 rabbitmq-rabbitmq-server-0 的 pod。

  2. 运行kubectl logs -f rabbitmq-rabbitmq-server-0查看日志显示上述错误。

最佳答案

正如我已经在评论中建议的那样,您可以通过运行解决它:

minikube ssh -- sudo chmod g+w /mnt/app/rabbitmq/ 

回答你的问题:

Is there a way I can add that to my manifest file rather than having to do it manually?

您可以覆盖 rabbitmq statefulset list 字段以将 initContainer 命令脚本中的最后一行从 chgrp 999/var/lib/rabbitmq/mnesia/ 更改为:chown 999:999/var/lib/rabbitmq/mnesia/.

完整的 RabbitmqCluster yaml list 如下所示:

apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: rabbitmq
spec:
replicas: 1
service:
type: NodePort
persistence:
storageClassName: local-storage
storage: 20Gi
override:
statefulSet:
spec:
template:
spec:
containers: []
initContainers:
- name: setup-container
command:
- sh
- -c
- cp /tmp/rabbitmq/rabbitmq.conf /etc/rabbitmq/rabbitmq.conf && chown 999:999
/etc/rabbitmq/rabbitmq.conf && echo '' >> /etc/rabbitmq/rabbitmq.conf ; cp /tmp/rabbitmq/advanced.config
/etc/rabbitmq/advanced.config && chown 999:999 /etc/rabbitmq/advanced.config
; cp /tmp/rabbitmq/rabbitmq-env.conf /etc/rabbitmq/rabbitmq-env.conf && chown
999:999 /etc/rabbitmq/rabbitmq-env.conf ; cp /tmp/erlang-cookie-secret/.erlang.cookie
/var/lib/rabbitmq/.erlang.cookie && chown 999:999 /var/lib/rabbitmq/.erlang.cookie
&& chmod 600 /var/lib/rabbitmq/.erlang.cookie ; cp /tmp/rabbitmq-plugins/enabled_plugins
/etc/rabbitmq/enabled_plugins && chown 999:999 /etc/rabbitmq/enabled_plugins
; chown 999:999 /var/lib/rabbitmq/mnesia/ # <- CHANGED THIS LINE

关于kubernetes - minikube 上的 RabbitMQ Cluster Kubernetes Operator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64238522/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com