当前位置:网站首页>MySQL takes up too much memory solution
MySQL takes up too much memory solution
2022-07-06 12:13:00 【A pole】
List of articles
Preface
For some petty bourgeoisie players , The number of servers and memory are often very limited , My personal server configuration is 2 nucleus 4G5M.
4G Memory for Java Game player , It's really not big , Open several middleware + Their own micro services are really crowded , Then spread it MySQL This big enemy . I'm on this machine MySQL Only a few M Memory ( Although I don't use it very much , But this machine MySQL It's really on ):

And the server accounts for 400M, In fact, there is no throughput , Just play by yourself , This memory occupation is really a little unbearable ...

Solution
Learned that you can reduce by modifying the configuration MySQL Memory footprint , I tried , And recorded . Because I have two servers at the same time , One is equipped with windows service 2016, Another one is equipped with CentOS7, The situation of both sets is similar , So make two records at the same time , For your reference .
Find the configuration file
Windows Service 2016
The default location of the configuration file is C:\ProgramData\MySQL\MySQL Server 8.0\my.ini, If there is any modification , Find out according to your actual situation .

CentOS7
The default path of the configuration file is /etc/my.cnf, If there is any modification , Find out according to your actual situation .
Modify the configuration file
Windows It can be used Ctrl + F To search ,Linux It can be used ‘/key’ To search , If not, you can refer to Baidu .
There are three things we need to find and modify :
find
table_definition_cache, Let's change it to 400The official explanation is : The number of table definitions that can be stored in the definition cache ( come from .frm file ). If you use a large number of tables , You can create a large table definition cache to speed up the opening of tables . Different from ordinary table caching , The table definition cache takes up less space , And do not use file descriptors . The minimum and default values are 400.
find
table_open_cache, Let's change it to 256MySQL Every time I open a watch , Will read in some data to table_open_cache In cache , When MySQL When no corresponding information is found in this cache , Will go to the disk to read .
The official explanation is : Number of open tables for all threads . Increasing this value will increase mysqld Number of file descriptors required . therefore , You have to make sure that at [mysqld safe] Partial variables “open files limit” Set the number of files allowed to be opened to at least 4096.
find
performance_schema, It is amended as follows offIf you can't find this , Directly add
performance_schema = offthat will do .Used to monitor MySQL server Resource consumption in a lower level of running process 、 Resource waiting, etc , You can save money after closing , Will not make server Your behavior changes .
Save and exit after modification .
restart MySQL
Windows Service 2016
Start the console as an administrator , Input net stop mysql, And then you type in net start mysql.
After restart, it still takes 62M.

CentOS7
Console input service mysqld restart You can restart .

If not , You can try /etc/init.d/mysqld restart This instruction .
Occupied after restart 92M, Than Windows That one is more .

Postscript
In this way, it can really reduce mysql Memory footprint , But I'm just trading performance for memory , If the throughput requirements are relatively high , It certainly cannot be modified directly like this , It has to be adjusted according to the actual request .
边栏推荐
- Fashion-Gen: The Generative Fashion Dataset and Challenge 论文解读&数据集介绍
- Page performance optimization of video scene
- 机器学习--决策树(sklearn)
- Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights
- RT-Thread的main线程“卡死”的一种可能原因及解决方案
- C语言回调函数【C语言】
- Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
- [Red Treasure Book Notes simplified version] Chapter 12 BOM
- ESP学习问题记录
- GNN的第一个简单案例:Cora分类
猜你喜欢

RT-Thread 线程的时间片轮询调度

Reno7 60W super flash charging architecture
![[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree](/img/6e/0802a92511ac50a652afa1678ad28c.jpg)
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree

arduino UNO R3的寄存器写法(1)-----引脚电平状态变化

Understanding of AMBA, AHB, APB and Axi

JS變量類型以及常用類型轉換

RT-Thread API参考手册

高通&MTK&麒麟 手机平台USB3.0方案对比

機器學習--線性回歸(sklearn)

C语言回调函数【C语言】
随机推荐
arduino JSON数据信息解析
ESP8266通过arduino IED连接巴法云(TCP创客云)
arduino获取数组的长度
RT-Thread API参考手册
Reno7 60W超级闪充充电架构
The first simple case of GNN: Cora classification
Imgcat usage experience
C语言,log打印文件名、函数名、行号、日期时间
Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
Characteristics, task status and startup of UCOS III
Programmers can make mistakes. Basic pointers and arrays of C language
.elf .map .list .hex文件
Detailed explanation of 5g working principle (explanation & illustration)
imgcat使用心得
Detailed explanation of Union [C language]
Redis interview questions
C语言函数之可变参数原理:va_start、va_arg及va_end
The dolphin scheduler remotely executes shell scripts through the expect command
基于Redis的分布式锁 以及 超详细的改进思路