当前位置:网站首页>TKE(K8S)部署mysql使用CFS存储
TKE(K8S)部署mysql使用CFS存储
2022-07-17 19:04:00 【陈敬伟】
**前置条件
1,创建CFS实例
2,权限组 来访地址: * 用户权限是:no_root_squash 读写权限:读写
/var/lib/mysql 目录下的文件属性 都是mysql
[email protected]:/var/lib/mysql# pwd
/var/lib/mysql
[email protected]:/var/lib/mysql# ls -lrt
total 198064
-rw-r----- 1 mysql mysql 50331648 Jul 17 08:22 ib_logfile1
-rw-r----- 1 mysql mysql 8585216 Jul 17 08:22 '#ib_16384_1.dblwr'
drwxr-x--- 2 mysql mysql 4096 Jul 17 08:23 performance_schema
[email protected]:/var/lib/mysql# id mysql
uid=999(mysql) gid=999(mysql) groups=999(mysql)
需要将文件系统的权限组修改成 no_all_squash 访问用户会先与本机用户匹配,匹配失败后再映射为匿名用户或用户组;
yaml文件:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: mysql-cfs-data
qcloud-app: mysql-cfs-data
name: mysql-cfs-data
namespace: storage
spec:
replicas: 1
selector:
matchLabels:
k8s-app: mysql-cfs-data
qcloud-app: mysql-cfs-data
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
k8s-app: mysql-cfs-data
qcloud-app: mysql-cfs-data
spec:
containers:
- env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
image: mysql:5.7.16
imagePullPolicy: IfNotPresent
name: mysql
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 100m
memory: 64Mi
securityContext:
privileged: false
volumeMounts:
- mountPath: /var/lib/mysql
name: mysql-vol
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: qcloudregistrykey
restartPolicy: Always
volumes:
- name: mysql-vol
persistentVolumeClaim:
claimName: cfs-pvc-root
---
##内网型CLB
apiVersion: v1
kind: Service
metadata:
annotations:
service.kubernetes.io/qcloud-loadbalancer-internal-subnetid: subnet-ge8hhr3e
name: mysql-cfs-data
namespace: storage
spec:
externalTrafficPolicy: Cluster
ports:
- name: 3306-3306-tcp
nodePort: 31761
port: 3306
protocol: TCP
targetPort: 3306
selector:
k8s-app: mysql-cfs-data
qcloud-app: mysql-cfs-data
sessionAffinity: None
type: LoadBalancer
查看部署结果
[email protected]:/var/lib/mysql# df -h | grep /var
192.168.1.6:/111 10G 241M 9.8G 3% /var/lib/mysql
[email protected]:/var/lib/mysql# ls -lt
total 188452
drwxr-x--- 2 mysql mysql 19 Jul 17 09:28 chen
-rw-r----- 1 mysql mysql 12582912 Jul 17 09:26 ibtmp1
-rw-r----- 1 mysql mysql 50331648 Jul 17 09:25 ib_logfile0
-rw-r----- 1 mysql mysql 79691776 Jul 17 09:25 ibdata1
-rw-r----- 1 mysql mysql 1325 Jul 17 09:25 ib_buffer_pool
drwxr-x--- 2 mysql mysql 8192 Jul 17 09:25 sys
drwxr-x--- 2 mysql mysql 4096 Jul 17 09:25 mysql
drwxr-x--- 2 mysql mysql 8192 Jul 17 09:25 performance_schema
-rw-r----- 1 mysql mysql 56 Jul 17 09:25 auto.cnf
-rw-r----- 1 mysql mysql 50331648 Jul 17 09:25 ib_logfile1
StatefulSet方式部署:
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
k8s-app: mysql
qcloud-app: mysql
name: mysql
namespace: cjweichen
spec:
replicas: 1
selector:
matchLabels:
k8s-app: mysql
qcloud-app: mysql
serviceName: ""
template:
metadata:
labels:
k8s-app: mysql
qcloud-app: mysql
spec:
containers:
- env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
image: mysql:5.7
imagePullPolicy: IfNotPresent
name: mysql
resources: {}
volumeMounts:
- mountPath: /var/lib/mysql
name: nfs
subPath: mysql_docker/data
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: qcloudregistrykey
volumes:
- name: nfs
nfs:
path: /
server: 172.16.3.7
边栏推荐
- 统计直播间的榜一信息,从这里起步
- 卤味店,如何在低线城市挣钱
- NO.4位、字节、信息存储
- Start from here by counting the information of the broadcast room
- 【码蹄集新手村 600 题】如何使整数逆序
- 「津津乐道播客」#392 原汤话原食:仲夏夜,马砂、肉串儿、趿拉板儿
- 【考研词汇训练营】Day 7 —— second,attract,current,collect,simple,communicate,vocation
- 语音通信网络的原理
- ModuleNotFoundError: No module named ‘_distutils_hack‘
- Responsive dream weaving template wine cellar website
猜你喜欢
565.数组嵌套
asterisk: rejected because extension not found in context ‘from-ipphone‘
[postgraduate entrance examination vocabulary training camp] day 5 - alarm, cooperate, point, benefit, industrial, revolution, mechanism
【考研词汇训练营】Day 5 —— alarmist,cooperate,point,benefit,industrial,revolution,mechanize
[code hoof set novice village question 600] operator / type conversion in different operation sequences
No.3汇编进阶
Onvif protocol related: 4.1.3 WS username token method to obtain screenshot URL
基于MOS管的防反接电路设计仿真
Onvif protocol related: 2.1.1 get token in none mode
Forget about postman. Apifox is better
随机推荐
Codeforce:a. difference operations [mathematical thinking]
[7.13] code source - [hungry meals] [path count 2] [function sum]
Onvif protocol related: 4.1.3 WS username token method to obtain screenshot URL
基于MOS管的防反接电路设计仿真
ssh无密钥登录
Codeforce:a. doremy's IQ [reverse greed]
S32K148_CAN驱动(裸机开发)
Simulation of overvoltage protection (OVP) circuit based on PMOS
「技术播客月」Day 10: Meta Podcast: 聊聊播客这件事
关于数据字典的一些解惑
STL string查找子串
基于PMOS的过压保护(OVP)电路仿真
Principle of voice communication network
onvif协议相关:3.1.2 Digest方式获取token列表
Health prevention guide 3: health care
Codeforces Round #808 (Div. 2)ABCD
onvif协议相关:常用类说明
Perl command batch replaces some contents in the file
[code hoof set novice village 600 questions] the implementation of scientific counting method, output index form
[code hoof set novice village question 600] align left and right when outputting