当前位置:网站首页>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
边栏推荐
- Nacos - 配置管理
- 性能提升2-3倍!百度智能云第二代昆仑芯服务器上线
- win7 pyinstaller打包exe 后报错 DLL load failed while importing _socket:参数错误
- [MFC development (17)] advanced list control list control
- C语言指针的进阶(上篇)
- Flink interview questions
- DataBinding源码分析
- Embedded Engineer Interview Question 3 Hardware
- jeecg 重启报40001
- TypeError: __ init__ () got an unexpected keyword argument ‘autocompletion‘
猜你喜欢

基础:2.图像的本质

TypeError: __ init__ () got an unexpected keyword argument ‘autocompletion‘

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

Model and view of QT

为什么LTD独立站就是Web3.0网站!

如何做好固定资产管理?易点易动提供智能化方案

小鸟识别APP

截图小妙招

集团公司固定资产管理的痛点和解决方案

Public network cluster intercom +gps visual tracking | help the logistics industry with intelligent management and scheduling
随机推荐
TV size and viewing distance
Advanced level of C language pointer (Part 1)
Jetson Nano 安装TensorFlow GPU及问题解决
MySQL8.0学习记录17 -Create Table
Shell脚本-特殊变量:Shell $#、$*、[email protected]、$?、$$
Shell脚本-case in 和正则表达式
性能提升2-3倍!百度智能云第二代昆仑芯服务器上线
3、Modbus通讯协议详解
C language student information management system
Share 7 books I read in the first half of 2022
Insert mathematical formula in MD document and mathematical formula in typora
The fixed assets management system enables enterprises to dynamically master assets
Dynamic proxy
Redis——Lettuce连接redis集群
Matlab tips (23) matrix analysis -- simulated annealing
为什么LTD独立站就是Web3.0网站!
"Analysis of 43 cases of MATLAB neural network": Chapter 30 design of combined classifier based on random forest idea - breast cancer diagnosis
In depth learning training sample amplification and tag name modification
中考体育项目满分标准(深圳、安徽、湖北)
pcl_viewer命令