gpt4 book ai didi

mysql - 无法在 Redhat Openshift 上部署 MySQL

转载 作者:行者123 更新时间:2023-11-29 15:41:56 25 4
gpt4 key购买 nike

我无法在 Redhat openshift 上部署 MySQL。我的 pod 不断进入 CrashLoopBackOff。从错误中,我不明白问题是什么,因为它指出服务器正在作为进程进行初始化,之后,它直接进入关闭状态。需要了解实际发生的情况。

部署.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-wordpress-deployment
namespace: wordpress-website
labels:
app: mysql-wordpress
spec:
selector:
matchLabels:
app: mysql-wordpress
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql-wordpress
spec:
volumes:
- name: mysql-local-pv
persistentVolumeClaim:
claimName: local-mysql-pvc
containers:
- name: mysql-container
image: mysql
imagePullPolicy: IfNotPresent
port:
- containerPorts: 3306
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: pass
volumeMounts:
- name: mysql-local-pv
mountPath: /var/lib/mysql

持久卷.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
name: local-mysql-pv
spec:
storageClassName: ibmc-block-bronze
accessModes:
- ReadWriteOnce
capacity:
storage: "20Gi"
hostPath:
path: /tmp/data/
persistentVolumeReclaimPolicy: Recycle

持久卷声明.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi

错误日志

Initializing database
mysqld: Can't create directory '/var/lib/mysql/' (OS errno 17 - File exists)
2019-08-18T10:16:22.005955Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2019-08-18T10:16:22.006063Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.17) initializing of server in progress as process 17
2019-08-18T10:16:22.008464Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2019-08-18T10:16:22.008504Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-08-18T10:16:22.008970Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL.

最佳答案

hostPath 需要 privileged scc 才能通过 pod 向主机写入内容。因此,您可以按照以下步骤配置特权权限。

# oc adm policy add-scc-to-user privileged -z default
# oc edit deployment mysql-wordpress-deployment
spec:
...
template:
...
spec:
...
containers:
- name: mysql-container
securityContext:
privileged: true

基本上,出于安全考虑,不建议使用特权模式,因为特权允许不受任何限制地直接访问主机资源。

希望对你有帮助。

关于mysql - 无法在 Redhat Openshift 上部署 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57543677/

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