我尝试使用mount-volume的mysql来获取/var/lib/mysql
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
kubelogs如下
sh-3.2# kubectl logs acds-catchup-db-6f7d4b6c5b-2jwds
Initializing database
2018-04-16T09:23:18.020740Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-16T09:23:18.022014Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-04-16T09:23:18.022037Z 0 [ERROR] Aborting
在调查时,我在MountVolume中找到了一个名为Lost+Found
的目录。
可以帮我解决这个问题
答案 0 :(得分:1)
该目录始终存在于卷的根路径中,因此您无法将其删除。
您有两种选择如何解决它:
--ignore-db-dir=lost+found
选项添加到MySQL配置中。我认为这是更好的方式。--datadir=
选项指定数据库目录。以下是args设置的示例:
spec:
containers:
- name: mysql
image: mysql:5.6
args: ["--ignore-db-dir=lost+found"]