gpt4 book ai didi

mysql - Kubernetes POD 创建问题 mysql PV、PVC 问题、centos 7.3.1611

转载 作者:行者123 更新时间:2023-11-29 18:54:53 26 4
gpt4 key购买 nike

希望你做得很好。我在同一个虚拟机中有 Kubernetes Master 和 Slave 模拟 ==>centos 7.3.1611,2GB 内存,2 个虚拟核心。

Mysql容器服务。

登录用户:root

Kubernetes 版本:1.5

        Temp directory
--------------
mkdir -p /tmp/work/data /tmp/work/init

db.sql

create table `item`(`id` bigint not null auto_increment primary key, `description` varchar(100), `done` bit);
insert into `item`(`id`,`description`, `done`) valumes(1, 'Today is Friday', 0);
insert into `item`(`id`,`description`, `done`) valumes(2, 'Today is Saturday', 1);

cp db.sql /tmp/work/init


pv001.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
name: pv001
labels:
type: local
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
#persistentVolumeReclaimPolicy: Recycle
hostPath:
path: "/tmp/work/data"

pv002.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
name: pv002
labels:
type: local
spec:
capacity:
storage: 1Mi
accessModes:
- ReadWriteOnce
#persistentVolumeReclaimPolicy: Recycle
hostPath:
path: "/tmp/work/init"


dbclaim.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dbclaim
labels:
name: map_data_volume
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

dbinit.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dbinit
labels:
name: map_init_volume
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Mi


mkdir -p /var/lib/mysql/data /var/lib/mysql/init

mysql-pvc-pod.yaml

apiVersion: v1
kind: Pod
metadata:
name: mysql-pvc-pod
labels:
name: mysql-pvc-pod
spec:
containers:
- resources:
limits :
cpu: 1
image: mysql
name: mysql-pvc-pod
env:
- name: MYSQL_ROOT_PASSWORD
# change this
value: welcome1
- name: MYSQL_USER
value: testuser
- name: MYSQL_PASSWORD
value: mypass123
ports:
- containerPort: 3310
name: mysql-pvc-pod
volumeMounts:
- mountPath: /var/lib/mysql/data
name: db-volume
- mountPath: /var/lib/mysql/init
name: db-init
volumes:
- name: db-volume
persistentVolumeClaim:
claimName: dbclaim
- name: db-init
persistentVolumeClaim:
claimName: dbinit

mysql-pvc-pod-service.yaml

apiVersion: v1
kind: Service
metadata:
labels:
name: mysql-pvc-service
name: mysql-pvc-service
spec:
externalIPs:
- 10.0.2.15
ports:
# the port that this service should serve on
- port: 3310
# label keys and values that must match in order to receive traffic for this service
selector:
name: mysql-pvc-service

错误

我的 POD 崩溃了:CrashLoopBackOff

[root@centos7 ~]# kubectl 获取 Pod

名称就绪状态重新开始

mysql-pvc-pod 0/1 CrashLoopBackOff 8 18m

最佳答案

尝试通过设置粘性位来授予世界写入权限。然后重新创建 Pod

chmod 1777 /tmp/work/data /tmp/work/init

谢谢-SR

关于mysql - Kubernetes POD 创建问题 mysql PV、PVC 问题、centos 7.3.1611,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44200079/

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