当前位置:网站首页>docker部署mysql并修改其占用内存大小
docker部署mysql并修改其占用内存大小
2022-08-01 14:05:00 【独酌先生QAQ】
一.安装mysql
1.下载好镜像
docker pull mysql:8.0.18
2.创建MySQL
容器
docker run -id --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.18
3.查看安装情况
[[email protected] ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a28d702be74a mysql:8.0.18 "docker-entrypoint.s…" 20 minutes ago Up 6 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
二.修改mysql占用内存大小
因为自己部署服务内存比较小,而mysql在docker初始化就占500M,所以可优化其占用内存大小
1.查看运行内存
[[email protected] ~]# docker stats
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
a28d702be74a mysql 0.34% 400.49MiB / 1.694GiB 24.33% 0B / 0B 19.3MB / 14.1MB 38
c8adbf02c7a5 kafka 0.30% 435.7MiB / 1.694GiB 25.11% 1.77MB / 2.93MB 130MB / 86kB 65
92187cc1f68e zookeeper 0.07% 89.78MiB / 1.694GiB 5.18% 2.93MB / 1.77MB 99.5MB / 127kB 19
2.进入mysql容器终端
docker exec -it mysql bash
3.切换进入/etc/mysql/conf.d 目录
cd /etc/mysql/conf.d
4.我们需要进入容器当中进行修改容器里面的配置文件,可能有的服务器是没有安装vim的,所以我们没有的需要安装的
apt-get update
apt-get install vim
5.docker进入mysql容器内,进入/etc/mysql/conf.d 目录执行 vim docker.cnf
vim docker.cnf
6.在对应文件后面添加下面的参数
performance_schema_max_table_instances=400
table_definition_cache=400
performance_schema=off
table_open_cache=64
innodb_buffer_pool_chunk_size=64M
innodb_buffer_pool_size=64M
各参数对应的意义为
[mysqld]
performance_schema_max_table_instances=400
table_definition_cache=400 #缓存
performance_schema=off #用于监控MySQL server在一个较低级别的运行过程中的资源消耗、资源东西
table_open_cache=64 #打开表的缓存
innodb_buffer_pool_chunk_size=64M #InnoDB缓冲池大小调整操作的块大小
innodb_buffer_pool_size=64M #InnoDB 存储引擎的表数据和索引数据的最大内存缓冲区大小
7.退出
exit
8.重启mysql容器
docker stop mysql
docker start mysql
9.观察修改后的内存情况
docker stats
边栏推荐
- 超全!全国近90所大学考研报录比汇总!
- Qt实战案例(56)——利用QProcess实现应用程序重启功能
- Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3
- PyTorch 进阶之路:在 GPU 上训练深度神经网络
- 【每日一题】593. 有效的正方形
- 考研大事件!这6件事考研人必须知道!
- 性能优化——资源优化笔记
- 性能优化——渲染优化笔记
- The problem that the column becomes indexed after pd groupby and the aggregation column has no column name
- iPhone难卖,被欧洲反垄断的服务业务也难赚钱了,苹果的日子艰难
猜你喜欢
Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3
JMP Pro 16.0 software installation package download and installation tutorial
openEuler 社区完成首批顾问专家聘用,共同为社区的发展贡献力量
什么是元编程
ThreadLocal保存用户登录信息
HTB-Shocker
【二叉树】路径总和II
PAT 1167 Cartesian Tree(30)
软件测试之发现和解决bug
沃文特生物IPO过会:年营收4.8亿 养老基金是股东
随机推荐
制售假劣农资、非法占用耕地……公安部公布十起危害粮食生产安全犯罪典型案例
Istio投入生产的障碍以及如何解决这些问题
8. How does the SAP ABAP OData service support the Create operation
datetime64[ns] converted to datetime
E - Red and Blue Graph(组合数学)
立新能源深交所上市:市值55亿 哈密国投与国有基金是股东
模型运营是做什么的(概念模型数据库)
分布式中的远程调用
ABC260 E - At Least One (Dual Pointer)
【无标题】
iframe tag attribute description detailed [easy to understand]
[机缘参悟-57]:《素书》-4-修身养志[本德宗道章第四]
超全!全国近90所大学考研报录比汇总!
2022-07-29 网工进阶(二十二)BGP-其他特性(路由过滤、团体属性、认证、AS欺骗、对等体组、子路由器、路由最大接收数量)
Longkou united chemical registration: through 550 million revenue xiu-mei li control 92.5% stake
Typora报错:This beta version of Typora is expired
龙口联合化学通过注册:年营收5.5亿 李秀梅控制92.5%股权
What is consistent hashing?In what scenarios can it be applied?
D - Draw Your Cards (Simulation)
什么是元编程