当前位置:网站首页>MySQL optimization
MySQL optimization
2022-07-01 08:54:00 【The most beautiful programmer】
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
see MySQL Connection time configuration
show global variables like “%timeout%”;

No connection available
SET GLOBAL net_write_timeout = 120;
SET GLOBAL net_read_timeout = 60
Report of accident received , see mysql The database has the following parameters
1、innodb_buffer_pool_size
2、max_connections
This parameter defines the data buffer buffer pool size , Be similar to oracle Of db_cache_size
show global variables like ‘innodb_buffer_pool_size’;
So how to set the parameter size ? First look at the runtime buffer pool Related data indicators :
show global status like ‘Innodb_buffer_pool_pages_data’;
show global status like ‘Innodb_buffer_pool_pages_total’;
show global status like ‘Innodb_page_size’;
Calculation Innodb_buffer_pool_pages_data/Innodb_buffer_pool_pages_total*100%
When it turns out > 95% Increase innodb_buffer_pool_size, It is recommended to use physical memory 75%
When it turns out < 95% Then reduce innodb_buffer_pool_size,
It is recommended to set the size to : Innodb_buffer_pool_pages_data* Innodb_page_size * 1.05 / (102410241024)
MySQL The number of connections to the server is not intended to reach the maximum 100% For good
show variables like ‘max_connections’;
The machine MySQL The maximum number of server connections is 256, Then query the maximum number of connections that the server responds to :
show global status like ‘Max_used_connections’;
MySQL The maximum number of connections to the server in the past was 245, The maximum number of server connections has not been reached 256, There should be no 1040 error , The ideal setting is :
Max_used_connections / max_connections * 100% ≈ 85%
The maximum number of connections accounts for... Of the maximum number of connections 85% about , If it turns out that the ratio is 10% following ,MySQL The server connection is set too high .
mysql There is a difference between the database insertion time and the system time 12 Hours
modify catalina.sh file
open tomcat Under the table of contents /bin/catalina.sh file , Write... At the beginning of the file :
export JAVA_OPTS=“$JAVA_OPTS -Duser.timezone=Asia/shanghai”
And then it rebooted tomcat.
MySQL Too many database connections , Most of the Sleep
1. View details of all current connections : mysqladmin -uroot -proot processlist
Client side usage :
show full processlist
2、 Only view the current number of connections (Threads Is the number of connections .):
mysqladmin -uroot -proot status
Client side usage :
3. See the maximum number of connections
show variables like “max_connections”;
4: View the current number of connections :
show global status like ‘Max_used_connections’;
If there are too many processes, print them out :
mysql -e ‘show full processlist;’ > 111
terms of settlement :
SHOW GLOBAL VARIABLES LIKE ‘wait_timeout’; SHOW GLOBAL VARIABLES LIKE ‘interactive_timeout’;
set global wait_timeout=100; SET GLOBAL interactive_timeout=100;
Modify the waiting time of the connection , Time expired to release the connection .
The above is the failure after real-time modification and database restart
Can be found in my.cnf Add
wait_timeout=100
interactive_timeout=100
If you check again, you may find that the connection still cannot be released . Need to restart the database .
Probably Shutdown mysqld Failure . always …
Restart the server .
mysql The database is not responding . Can only be forced to restart
You can also modify the maximum number of connections ( Don't suggest ):
MySQL The maximum number of connections to the server in the past was 245, The maximum number of server connections has not been reached 256, There should be no 1040 error , The ideal setting is :
Max_used_connections / max_connections * 100% ≈ 85%
Temporary modification
set GLOBAL max_connections=1000;
Permanent modification :
To configure /etc/my.cnf
[mysqld] Add a new line as follows :
max_connections=1000
show variables like ‘max_connections’; If it's not the biggest one we've seen 1000;
This is because mariadb There is a default limit on the number of open files . Can be configured by /usr/lib/systemd/system/mariadb.service To increase the number of open files .
To configure /usr/lib/systemd/system/mariadb.service
[Service] Add two new lines as follows :
LimitNOFILE=10000
LimitNPROC=10000
Reload system services , And restart mariadb service
systemctl --system daemon-reload
systemctl restart mariadb.service
边栏推荐
- [MFC development (17)] advanced list control list control
- Embedded Engineer Interview Question 3 Hardware
- Shell脚本-位置参数(命令行参数)
- R语言观察日志(part24)--初始化设置
- 用C语言编程:用公式计算:e≈1+1/1!+1/2! …+1/n!,精度为10-6
- Brief introduction to AES
- 个人装修笔记
- 19Mn6 German standard pressure vessel steel plate 19Mn6 Wugang fixed binding 19Mn6 chemical composition
- Matlab [function derivation]
- Guidelines and principles of did
猜你喜欢
![Matlab [function derivation]](/img/ba/9fb9da8a458d0c74b29b21a17328fc.png)
Matlab [function derivation]

Brief introduction to AES

Glitch free clock switching technology

Centos7 shell script one click installation of JDK, Mongo, Kafka, FTP, PostgreSQL, PostGIS, pgrouting

5mo3 UHI HII HII 17mn4 19Mn6 executive standard

避免按钮重复点击的小工具bimianchongfu.queren()

Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched

截图小妙招

MD文档中插入数学公式,Typora中插入数学公式

Ape anthropology topic 20 (the topic will be updated from time to time)
随机推荐
个人装修笔记
Shell script - definition, assignment and deletion of variables
通过 代码实例 理解 浅复制 与 深复制
Common interview questions for embedded engineers 2-mcu_ STM32
[MFC development (16)] tree control
嵌入式工程师面试-常问问题集
factory type_ Id:: create process resolution
如何一站式高效管理固定资产?
软件工程师面试刷题网站、经验方法
TV size and viewing distance
Personal decoration notes
Shell script echo command escape character
Nacos - service discovery
"Analysis of 43 cases of MATLAB neural network": Chapter 30 design of combined classifier based on random forest idea - breast cancer diagnosis
日常办公耗材管理解决方案
【MFC开发(17)】高级列表控件List Control
1.jetson与摄像头的对接
Vscode customize the color of each area
TypeError: __ init__ () got an unexpected keyword argument ‘autocompletion‘
Shell script -for loop and for int loop