码迷,mamicode.com
首页 > 数据库 > 详细

k8s存储卷mysql故障转移

时间:2019-09-04 19:04:42      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:ssm   cto   erp   utils   共享   mysql   mode   mes   bin   

yum install -y rpcbind nfs-utils
创建共享目录
mkdir /home/sharedir
修改目录权限
chmod 0755 -R sharedir
修改NFS配置文件
vi /etc/exports
/home/sharedir 192.168.2.0(rw,no_root_squash,no_all_squash,sync)
----------------------------
yum install -y nfs-utils
showmount -e 192.168.2.120
mkdir /mnt/sharedir
mount -t nfs 192.168.2.120:/home/sharedir /mnt/sharedir

----------------------------------------
pv创建配置
mysql-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
nfs:
path: /home/sharedir/mysqldata
server: 192.168.2.120
----------------------------------------
pvc创建
mysql-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
----------------------------------------
部署mysql
mysql.yaml
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- port: 3306
selector:
app: mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:5.6
env:
- name: MYSQL_ROOT_PASSWORD
value: password
ports:
- name: mysql
containerPort: 3306
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pvc
----------------------------------------
进入mysql容器:
kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword

k8s存储卷mysql故障转移

标签:ssm   cto   erp   utils   共享   mysql   mode   mes   bin   

原文地址:https://www.cnblogs.com/fourw/p/11460911.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!