docker mysql 性能_docker 中的mysql 经常重启优化

查看 自己的centos 内存占用 :

[xx xxxxcentos ~]# free -m

total used free shared buff/cache available

Mem: 1838 1069 103 0 664 618

Swap: 0 0

还有600m 的可用呢 ,不是没有内存不可用啊。

网上查找问题是 mysql 的所占资源过多了 查看一下 docker 下的mysql 日志

dmesg | grep mysql

[10360983.950070] [12015] 999 12015 317044 81903 245 0 0 mysqld

[10360983.950114] Out of memory: Kill process 12015 (mysqld) score 174 or sacrifice child

[10360983.953032] Killed process 12015 (mysqld), UID 999, total-vm:1268176kB, anon-rss:327612kB, file-rss:0kB, shmem-rss:0kB

确实也是 Out of memory: Kill process 12015(mysqld) 也有解决办法 就是修改mysql 的使用内存

参考 解决办法

https://www.cnblogs.com/WNpursue/p/10617217.html

查看你 现在的 mysql 服务内存占用 MEM 占用为百分之 20 自己的两个java 服务各占 百分之 7.5 之前我会开两个 mysql 还有自己配置的1个nginx 那么 内存确实会占用很多。

ps -aux |grep mysqld

polkitd 25395 0.5 19.9 1292132 374736 ? Ssl 09:16 0:39 mysqld

进入docker 容器

docker exec -it dockermysql bash

切换到容器下的

cd /etc/mysql/conf.d

修改配置 : 在docker 中 mysql 目录下的 docker.cnf 自己猜测是 docker 对 mysql 的配置

vim docker.cnf

添加这几行 其中是把 performance_schema 关掉了

performance_schema_max_table_instances=400

table_definition_cache=400

table_open_cache=256

performance_schema = off

docker restart dockermysql

查看现在的mysqld 服务内存占用情况

[xxxxx centos ~]# ps -aux | grep mysqld

polkitd 17423 0.7 6.6 1055400 125636 ? Ssl 11:29 0:03 mysqld

root 18835 0.0 0.0 112812 972 pts/0 R+ 11:36 0:00 grep --color=auto mysqld

确实内存会下降很多。

同时也修改了另一个 mysql 实例,

[xxxx centos ~]# ps -aux | grep mysqld

polkitd 17423 0.6 6.6 1055976 125636 ? Ssl 11:29 0:04 mysqld

polkitd 19649 4.6 6.1 1052988 115068 ? Ssl 11:39 0:01 mysqld

现在两个总共也就占用 13 的mem 估计这次是不会mysql 服务不会重启了。

关于这问题的其他参考 有关于 performance_schema的介绍 简单就是performance_schema 是一个会监控mysql 运行状态的一个线程,off 后性能肯定会提高, 其他几个是配置一些缓存 实例的减少。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值