当前位置:网站首页>MySQL master database operation large table DDL, slave database crash and system parameter error setting
MySQL master database operation large table DDL, slave database crash and system parameter error setting
2022-06-10 12:43:00 【51CTO】

Here's the thing , A user test UAT library , Frequent error reports from the database without any reason


Memory itself is OK Of . But why MYSQL The version of is official 8.011

First of all, I am getting this question , Want to pass PERCONA Tool set pt-pmp To analyze , But it's starting pt-pmp It was found that it could not run , Direct report virtual memory exhausted

But the problem is that the memory is not used up , We also have SWAP ah , In the end how can not be divided into pieces of memory . I suddenly think of an article I saw before , Is it because overcommit_memory There is a problem with the configuration of , This leads to the obvious memory , But the problem is that it can't be allocated .
First of all, let's get familiar with overcommit The value of is 0 1 2
By default, most systems choose 0 , The official documentation is described as applicable to a typical system , Allocations of memory that are significantly larger than expected are rejected , And will use as little as possible SWAP Of memory space
1 Is a special Liezi , He doesn't care if the memory of the system has been over allocated , This configuration is only applicable to some special applications .
2 And 1 Counter examples of , The memory allocation provided by him will only affect the overall system 50% Distribute , SWAP + Overall memory 50% Is the most he can allocate , When memory cannot be allocated to an application , The system does not OOM application , But the application will receive a memory allocation error .
My first reaction is to query /proc/sys/vm/overcommit_memory , Sure enough, the state inside is 2 .
Modify the parameters now sudo vi /etc/sysctl.conf
And then in the sysctl -p
Start again PT-PMP command
pt-pmp --binary mysqld --iterations 2 --interval 1 --save-samples mysql.txt

After modification

In the view MYSQL Error log for ,, After modification , There are no errors in the system . Later others DBA I think it was to test the impact of this parameter on the database , And adjusted the parameters . Forgot to change it back . But it's good , Through this matter, we can also thoroughly understand overcommit If the parameter is set to... By default 2 ,MYSQL Possible problems .
Related code
- int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
- {
- unsigned long free, allowed;
- vm_acct_memory(pages);
- /*
- * Sometimes we want to use more memory than we have
- */
- if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS) //overcommit_memory=1, Go straight back to success , No restrictions .
- return 0;
- if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) { //overcommit_memory=0, Heuristics , Determine whether memory can be allocated according to the free memory status in the current system .
- unsigned long n;
- free= global_page_state(NR_FILE_PAGES);
- free+= nr_swap_pages;
- /*
- * Any slabs which are created with the
- * SLAB_RECLAIM_ACCOUNT flag claim to have contents
- * which are reclaimable, under pressure. The dentry
- * cache and most inode caches should fall into this
- */
- free+= global_page_state(NR_SLAB_RECLAIMABLE);
- /*
- * Leave the last 3% for root
- */
- if (!cap_sys_admin)
- free-= free / 32; //root Users can go to free less (3%) When , Allocate memory .
- if (free > pages) // pages The size of memory to be allocated ,free It is calculated according to certain rules “ Free memory size ”, for the first time free Only for NR_FILE_PAGES+NR_SLAB_RECLAIMABLE, Directly or in the system “ Actual idle ” The memory cost is relatively high , So make a step-by-step judgment , Increase of efficiency .
- return 0;
- /*
- * nr_free_pages() is very expensive on large systems,
- * only call if we're about to fail.
- */
- n = nr_free_pages(); // When the memory allocation condition is not satisfied for the first time , Proceed again “ Actual idle ” Memory acquisition operation .
- /*
- * Leave reserved pages. The pages are not for anonymous pages.
- */
- if (n <= totalreserve_pages)
- goto error;
- else
- n -= totalreserve_pages;
- /*
- * Leave the last 3% for root
- */
- if (!cap_sys_admin)
- n -= n / 32;
- free += n;
- if (free > pages)
- return 0;
- goto error;
- }
- allowed = (totalram_pages - hugetlb_total_pages()) // When overcommit_memory=2 when , It is limited according to the total amount of virtual address space in the system .
- * sysctl_overcommit_ratio / 100;
- /*
- * Leave the last 3% for root
- */
- if (!cap_sys_admin)
- allowed -= allowed / 32;
- allowed += total_swap_pages;
- /* Don't let a single process grow too big:
- leave 3% of the size of this process for other processes */
- if (mm)
- allowed-= mm->total_vm / 32;
- if (percpu_counter_read_positive(&vm_committed_as) < allowed)
- return 0;
- error:
- vm_unacct_memory(pages);
- return-ENOMEM;
- }

边栏推荐
- JS translates Arabic numerals into Chinese capital figures, JS converts figures into capital amounts (sorting)
- VS2010 undefined identifier round
- JTAG-to-AXI Master调试AXI BRAM Controller
- 2022 Zhejiang provincial competition
- 2022年6月中国数据库排行榜:TiDB卷土重来摘桂冠,达梦蛰伏五月夺探花
- C# 实现气泡窗体
- Can chip learning of max3051
- DynaSLAM II: Tightly-Coupled Multi-Object Tracking and SLAM 论文阅读
- 日本版arXiv凉得一批:2个多月了,才收到37篇论文
- 技术分享| 快对讲,全球对讲
猜你喜欢
随机推荐
2022年6月中国数据库排行榜:TiDB卷土重来摘桂冠,达梦蛰伏五月夺探花
STM32F407时钟树与系统时钟学习笔记
(五)类和对象及类的分文件操作(2)
Gimp - free and open source image processing software with powerful functions, known as an excellent substitute for Photoshop
Oceanbase, phase II of the document promotion plan, invites you to jointly build documents
Today, a couple won the largest e-commerce IPO in Hong Kong
向数据库中注册用户名和密码的功能
VDMA commissioning summary
Lua syntax
(6) Classes and objects, object initialization and copy constructors (3)
VS2010 undefined identifier round
蔚来:“拿捏”了数据,“扭捏”着未来
[solved] vagrant up solution to slow download box
(十 一)const修飾成員函數
Unity3d 使用URP渲染管线实现AR阴影(阴影投射再透明地面)
Unity3D开发MR实现模型遮挡与透明地面接收阴影
20年技术老兵放弃大厂CTO头衔!这家创业公司凭什么吸引他?
H5 pop up prompt layer - top, bottom, left and right center
Slm4054 independent linear lithium battery charger chip learning
Technology sharing | quick intercom, global intercom







