参考官网:https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/

20-nproc.conf

*          soft    nproc     unlimited
root soft nproc unlimited

limits.conf

# End of file
* soft core
* hard core
* soft nofile
* hard nofile

senyint.conf

[root@harbor mysql5.7.20]# cat  senyint.cnf
[mysqld]
server-id =
port =
user = mysql
autocommit =
character_set_server=utf8mb4
skip_name_resolve =
max_connections =
max_connect_errors =
transaction_isolation = READ-COMMITTED
join_buffer_size = 128M
tmp_table_size = 64M
tmpdir = /tmp
max_allowed_packet = 64M
interactive_timeout =
wait_timeout =
read_buffer_size = 16M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
explicit_defaults_for_timestamp=true

Dockerfile

[root@harbor mysql5.7.20]# cat Dockerfile
FROM docker.io/mysql:5.7. MAINTAINER fengjian <fengjian@senyint.com>
ENV TZ "Asia/Shanghai"
ENV TERM xterm
ENV MALLOC_ARENA_MAX= ADD localtime /etc/
ADD -nproc.conf /etc/security/limits.d/
ADD limits.conf /etc/security/
ADD senyint.cnf /etc/mysql/mysql.conf.d/
ADD senyint.cnf /etc/mysql/conf.d/
#RUN rm /var/lib/mysql/lost+found -rf

docker build -t 192.168.200.10/source/mysql:5.7.20 .
 docker push 192.168.200.10/source/mysql:5.7.20

部署到k8s中

[root@master1 mysql]# cat mysql-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: mysql-secrets
namespace: prodpay
#type: Opaque
data:
root-password: QWJjZCwxMj222M0
[root@master1 mysql]# cat mysql_pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
namespace: prodpay
name: mysql-pvc
spec:
storageClassName: ceph-rbd-dalianpay
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
[root@master1 mysql]# cat mysql.yaml
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mysql
namespace: prodpay
spec:
selector:
matchLabels:
app: mysql
replicas:
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: 192.168.200.10/source/mysql:5.7.
imagePullPolicy: Always
name: mysql
#command: ["rm","-rf","/var/lib/mysql/lost+found"]
ports:
- containerPort:
resources:
requests:
cpu:
memory: 4Gi
limits:
cpu:
memory: 8Gi
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secrets
key: root-password
volumeMounts:
- mountPath: /var/lib/mysql
subPath: mysql #如果不加subpath,那么就会报[ERROR] --initialize specified but the data directory has files in it. Aborting.目录不为空,使用subpath基础表信息会记录在/var/lib/mysql/mysql下
name: data
volumes:
- name: data
persistentVolumeClaim:
claimName: mysql-pvc ---
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: prodpay
spec:
ports:
- name: mqsql
port:
targetPort:
selector:
app: mysq

最新文章

  1. js实现下滑加载更多的效果
  2. 重构Mybatis与Spring集成的SqlSessionFactoryBean(1)
  3. SURF算子(1)
  4. python suds 一坑
  5. C++哈弗曼编码
  6. python实现简单爬虫抓取图片
  7. BZOJ1695 : [Usaco2007 Demo]Walk the Talk
  8. C# @Page指令中的AutoEventWireup,CodeBehind,Inherits
  9. 设置UIButton文字大小颜色不同
  10. 关于datatable转换datatime类型的问题
  11. Oracle----dual
  12. R cannot be resolved to a variable
  13. S5PV210开发板刷机(SD卡uboot、串口+USB-OTG刷机方法)
  14. Android集成科大讯飞SDK语音听写及语音合成功能实现
  15. 开源个.NetCore写的 - 并发请求工具PressureTool
  16. Leetcode_48_Rotate Image
  17. 好的LCT板子和一句话
  18. mpvue支持小程序的分包加载
  19. js 前端有消息了 声音提示给用户
  20. Ubuntu下ClickHouse安装

热门文章

  1. 操作Linux系统环境变量的几种方法
  2. 弱引用(WeakReference)
  3. Spring Boot 初始化运行特定方法
  4. 服务器CPU居高不下--解决问题历程
  5. 现如今的CDN网站加速技术,细说CDN
  6. Hash table: why size should be prime?
  7. 解决Linux服务器tomact-8.0启动慢的问题
  8. spark_wordcount
  9. sigar获取Windows系统的硬件信息进行JAVA后台系统资源监控
  10. [工作总结]jQuery在工作开发中常用代码片段集锦(1-10)