查看“K8s mysql NFS 持久化”的源代码
←
K8s mysql NFS 持久化
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
[[category:k8s]] =k8s mysql5.7 NFS 持久化= ==NFS== <pre> root@debian11:~# mkdir -p /data/k8s/mysql57 root@debian11:~# chmod -R 0777 /data/k8s/mysql57 root@debian11:~# ls /data/k8s/mysql57 </pre> == k8s yaml== <pre> root@k8s-master:~/mysql5.7# ls pvc.yaml pv.yaml svc.yaml cat pv.yaml apiVersion: v1 kind: PersistentVolume metadata: name: mysql57-pv-evan spec: accessModes: - ReadWriteOnce #指定访问模式 capacity: storage: 1Gi #存储容量 1G persistentVolumeReclaimPolicy: Retain #回收策略 Retain 管理员手工回收 Recycle #清除 PV 的数据 Delete 删除Storage Provider上的对应存储资源 storageClassName: nfs #指定PV 的class为nfs nfs: path: /data/k8s/mysql57 #PV在 NFS服务器上对应的目录 server: 192.168.88.122 cat pvc.yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mysql57-pvc-evan spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi storageClassName: nfs cat svc.yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mysql-pvc-evan spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi storageClassName: nfs apiVersion: v1 kind: Service metadata: name: mysql spec: type: NodePort ports: - protocol: TCP nodePort: 30306 port: 3306 targetPort: 3306 selector: app: mysql --- apiVersion: apps/v1 kind: Deployment metadata: name: mysql spec: selector: matchLabels: app: mysql template: metadata: labels: app: mysql spec: containers: - image: mysql:5.7 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: mysql57-pvc-evan 依次执行 kubectl apply -f pv.yaml kubectl get pv kubectl apply -f pvc.yaml kubectl get pv,pvc kubectl apply -f svc.yaml kubectl get pod kubectl exec -it mysql-58ddb8d7f6-bhps5 bash root@k8s-master:~/mysql5.7# kubectl get pv,pvc NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE persistentvolume/mysql-nfs-pv 2Gi RWO Retain Terminating default/mysql-nfs-pvc nfs 2d1h persistentvolume/mysql-nfs-pv1 3Gi RWO Retain Bound default/mysql-nfs-pvc1 nfs 33h persistentvolume/mysql-pv 4Gi RWX Retain Bound default/mysql-claim nfs 36h persistentvolume/mysql57-pv-evan 1Gi RWO Retain Bound default/mysql57-pvc-evan nfs 18s persistentvolume/web-pv 2Gi RWX Retain Bound default/web-claim nfs 35h NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE persistentvolumeclaim/mysql-claim Bound mysql-pv 4Gi RWX nfs 36h persistentvolumeclaim/mysql-nfs-pvc Terminating mysql-nfs-pv 2Gi RWO nfs 2d1h persistentvolumeclaim/mysql-nfs-pvc1 Bound mysql-nfs-pv1 3Gi RWO nfs 33h persistentvolumeclaim/mysql57-pvc-evan Bound mysql57-pv-evan 1Gi RWO nfs 6s persistentvolumeclaim/web-claim Bound web-pv 2Gi RWX nfs 35h root@k8s-master:~/mysql5.7# node1ip 192.168.88.51 root@k8s-master:~/mysql5.7# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE mysql NodePort 10.96.61.100 <none> 3306:30306/TCP 2d1h mysql -uroot -h192.168.88.51 -P30306 -p 或者 kubectl exec -it mysql-58ddb8d7f6-bhps5 bash mysql -uroot -ppassword create database evanmysq57; 回来 nfs 看一下 root@debian11:~# ls /data/k8s/mysql57/evanmysq57/ db.opt </pre> =5.6= 和上次一样改了下 pv pvc image 名就行了 =see also= [https://blog.csdn.net/weixin_43925277/article/details/104313863 MySQL的持久化部署(k8s与NFS)]
返回至
K8s mysql NFS 持久化
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
我的导航
关于我
shell
python
ops
linuxchina.net
blog.linuxchina
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息