当我使用dockerfile构建Rabbitmq映像时,它在docker和kubernetes上运行良好。但是当我在上面添加pvc时,容器显示“崩溃回退”。 错误是:
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@rongqiyun-dev-base-qqqqqqqq-0...
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
set 3 plugins.
Offline change; changes will take effect at broker restart.
mkdir: cannot create directory '/var/lib/rabbitmq/mnesia': Permission denied
Failed to create directory: /var/lib/rabbitmq/mnesia
这是我的dockerfile
FROM hub.gcloud.lab/library/centos:7.4.1708
WORKDIR /root
RUN groupadd rabbitmq
RUN useradd -g rabbitmq rabbitmq
RUN mkdir -p /var/lib/rabbitmq/mnesia && \
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq && \
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/mnesia
RUN yum install -y epel-release
RUN yum install -y deltarpm gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget xz lsof dos2unix unixODBC unixODBC-devel wxBase wxGTK SDL wxGTK-gl socat git
RUN yum clean all
RUN wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
RUN rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
RUN yum install -y erlang
RUN yum install -y initscripts logrotate
RUN wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.8/rabbitmq-server-3.7.8-1.el6.noarch.rpm
RUN rpm -ivh rabbitmq-server-3.7.8-1.el6.noarch.rpm
ENTRYPOINT rabbitmq-plugins enable rabbitmq_management && rabbitmq-server
EXPOSE 5672
EXPOSE 15672
CMD ["rabbitmq-server"]
这是我的状态集。 在添加Rabbitmq-persistent-storage之前,它可以正常启动。 但是,当我添加它时,容器无法启动
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: rongqiyun-dev-base-qqqqqqqq
namespace: rongqiyun-dev
spec:
podManagementPolicy: OrderedReady
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: rongqiyun-dev
ns-baseServiceName: rongqiyun-dev-base-qqqqqqqq
serviceName: qqqqqqqq
template:
metadata:
labels:
app: rongqiyun-dev
ns-baseServiceName: rongqiyun-dev-base-qqqqqqqq
spec:
containers:
- env:
- name: RABBITMQ_DEFAULT_PASS
value: "12345"
image: hub.gcloud.lab/library/rabbitmq:3.7
imagePullPolicy: Always
name: qqqqqqqq
ports:
- containerPort: 15672
protocol: TCP
- containerPort: 5672
protocol: TCP
resources:
limits:
cpu: "1"
memory: 800Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/rabbitmq
name: rabbitmq-persistent-storage
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
fsGroup: 0
terminationGracePeriodSeconds: 30
updateStrategy:
rollingUpdate:
partition: 0
type: RollingUpdate
volumeClaimTemplates:
- metadata:
name: rabbitmq-persistent-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: rook-ceph-block
答案 0 :(得分:0)
尝试:
chmod 777 /var/lib/rabbitmq/mnesia