Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Mysql check the number of connections and status information

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to check connection number and status information in Mysql". In daily operation, I believe many people have doubts about how to view connection number and status information in Mysql. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to view connection number and status information in Mysql". Next, please follow the editor to study!

I. description of the problem

Today, my colleagues in operation and maintenance came to me and asked me that the number of connections in two databases MYSQL exceeded the monitoring threshold (700). Of course, their monitoring (zabbix) had just been set up. Indicates that the value has been adjusted up from a very low value, but still gives an alarm. So I found me, as an ORACLE's DBA, ready to become a dual-material DBA, this is a good time to learn. Let's learn how to query the number of connections in MYSQL.

2. Experiment

1.show status looks at all the status parameters, including the current number of connections to Threads_connected, the total number of connections Connections is trying to connect to (whether successful or not) to the MYSQL server, and the maximum number of connections (concurrency) that have been used simultaneously since the Max_used_connections server was started.

Mysql > show status like'% connect%'

+-+ +

| | Variable_name | Value |

+-+ +

| | Aborted_connects | 163|

| | Connections | 1116123 | |

| | Max_used_connections | 266 |

| | Threads_connected | 208 |

+-+ +

4 rows in set (0.00 sec)

Mysql >

2.show processlist displays the currently executing mysql connection

Mysql > show processlist

+-+ +

| | Id | User | Host | db | Command | Time | State | Info |

+-+ +

| | 1105357 | tjuser | 10.10.100.30 Sleep 36210 | testdb | Sleep | 1377 | | NULL |

| | 1112435 | tjuser | 10.10.100.30 Sleep 54112 | testdb | Sleep | 1616 | | NULL |

|. Slightly

| | 1116128 | tjuser | 10.10.100.21 Sleep 47484 | testdb | Sleep | 1 | | NULL |

| | 1116129 | tjuser | 10.10.100.21 Sleep 47485 | testdb | Sleep | 64 | | NULL |

+-+ +

207 rows in set (0.00 sec)

3.mysqladmin-u-p-h status displays the current mysql status

[root@db] # mysqladmin-uroot-p-hlocalhost status

Enter password:

Uptime: 14604445 Threads: 208 Questions: 34034734 Slow queries: 179 Opens: 12553 Flush tables: 3 Open tables: 977 Queries per second avg: 2.330

[root@db ~] #

4.mysqladmin-u-p-h extended-status shows other states of mysql

[root@db] # mysqladmin-uroot-p-hlocalhost extended-status

Enter password:

+-+ +

| | Variable_name | Value |

+-+ +

| | Aborted_clients | 53041 | |

| | Aborted_connects | 163|

| | Connections | 1116157 | |

…… Slightly

| | Threads_connected | 206 | |

| | Threads_created | 633 | |

| | Threads_running | 1 | |

| | Uptime | 14604661 | |

| | Uptime_since_flush_status | 14604661 | |

+-+ +

[root@db ~] #

III. Summary

This query only needs to master the show status,show process list command in mysql, as well as the command mysqladmin. Through the above command, you can quickly get the MYSQL database connection parameters and status values. After querying the database, the number of connect is set to 1000, which is normal after telling colleagues to modify the threshold.

At this point, the study on "how to check the number and status of connections in Mysql" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report