当前位置:网站首页>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
边栏推荐
- Shell脚本-case in 和正则表达式
- Serial port to WiFi module communication
- 3. Detailed explanation of Modbus communication protocol
- The meaning of yolov5 training visualization index
- FreeRTOS learning easy notes
- 嵌入式工程师面试题3-硬件
- Shell script - positional parameters (command line parameters)
- FreeRTOS学习简易笔记
- pcl_ Viewer command
- Shell脚本-数组定义以及获取数组元素
猜你喜欢
随机推荐
5mo3 UHI HII HII 17mn4 19Mn6 executive standard
TV size and viewing distance
Shell脚本-if else语句
Advanced C language pointer (Part 2)
1. Connection between Jetson and camera
In depth learning training sample amplification and tag name modification
钓鱼识别app
Shell script - definition, assignment and deletion of variables
I would like to know the process of stock registration and account opening by mobile phone? In addition, is it safe to open a mobile account?
小鸟识别APP
Differences among tasks, threads and processes
Shell script echo command escape character
明明设计的是高带宽,差点加工成开路?
大型工厂设备管理痛点和解决方案
嵌入式工程师常见面试题2-MCU_STM32
Personal decoration notes
安装Oracle EE
Shell脚本-echo命令 转义符
19Mn6 German standard pressure vessel steel plate 19Mn6 Wugang fixed binding 19Mn6 chemical composition
Shell脚本-select in循环