페이지 트리

이 페이지는 모니터링 해야하는 MySQL metric에 대해 정리한다.

Monitoring Metrics

MySQL provides a few good metrics for monitoring your connections:

VariableWhat it representsWhy you should monitor it
Threads_connectedThis variable indicates the total number of clients that have currently open connections to the server.It provides real-time information on how many clients are currently connected to the server. This can help in traffic analysis or in deciding the best time for a server re-start.
Threads_runningThe number of threads that are not sleeping.It’s good for isolating which connected threads are actively processing queries at any given time, as opposed to connections that are open but are currently idle.
ConnectionsThe number of connection attempts (successful or not) to the MySQL server.It can give you a good idea of how many people and applications are accessing the database. Over time, these numbers reveal busiest times and average usage numbers.
Connection_errors_internalThe number of connections refused due to internal server errors, such as failure to start a new thread or an out-of-memory condition.Although MySQL exposes several metrics on connection errors, Connection_errors_internal is probably the most useful, because it is incremented only when the error comes from the server itself. Internal errors can indicate an out-of-memory condition or an inability to start a new thread.

How to monitor

We can use the MySQL show status command to show MySQL variables and status information. Here are a few examples:

 SHOW GLOBAL STATUS LIKE '%Threads_connected%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_connected | 2 |
+-------------------+-------+
SHOW GLOBAL STATUS LIKE '%Threads_running%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| Threads_running | 1 |
+-----------------+-------+
SHOW GLOBAL STATUS LIKE 'Connections';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 20 |
+---------------+-------+
  • 레이블 없음