In the mysql database, slow query logs can be recorded, and for commands that take a long time, they are recorded in the log file, and redis also has slow query logs, which are enabled by default and recorded in memory. In the server redis logs, it looks like this:
84192:C 02 Jun 2021 05:32:28.074 * RDB: 0 MB of memory used by copy-on-write 11833:S 02 Jun 2021 05:32:28.158 * Background saving terminated with success 11833:S 02 Jun 2021 05:35:28.598 * FAIL message received from a1d5197856bc3da8c376cac9944c1094c47ab113 about b253fafced7217460b528b16d2efbc9059ec89a6 11833:S 02 Jun 2021 05:35:28.599 # Cluster state changed: fail 11833:S 02 Jun 2021 05:35:32.023 # Cluster state changed: ok 11833:S 02 Jun 2021 05:35:35.715 * Clear FAIL state for node b253fafced7217460b528b16d2efbc9059ec89a6: replica is reachable again. 11833:S 02 Jun 2021 05:37:29.073 * 10 changes in 300 seconds. Saving... 11833:S 02 Jun 2021 05:37:29.081 * Background saving started by pid 85398 Found a FAIL message log.
Query slow query logs
Query the current number of slow query log records
Clear the slow query logs
View the configuration
1) "slowlog-log-slower-than" 2) "10000" 3) "slowlog-max-len" 4) "128" slowlog-log-slower-than represents the threshold for slow queries in microseconds. When the execution time of a query command exceeds the configured threshold, the command is logged to the slow query log. When slowlog-log-slower-than=0, log all commands. slowlog-log-slower-than<0, no commands are logged. The default value for slowlog-log-slower-than is 10000 (10 ms, 1 second = 1,000 ms = 1,000,000 microseconds).
slowlog-max-len represents the maximum number of slow query logs. It is a storage structure in the form of a queue, a first-in, first-out queue, that is, when the maximum number of slow query logs reaches the maximum number, the earliest recorded log entries will be destroyed. The default value of slowlog-max-len is 128 and is stored in memory, so restarting redis will clear the slow query logs.
Modify the configuration
(End)
|