In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly tells you how to configure mysql slow query and how to view mysql process methods. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, let's go straight to the topic. I hope that mysql slow query how to configure and view mysql process methods this article can bring you some practical help.
I. command operation
A) Database query current connection: showprocesslist;&&show status
B) Database view status: status
C) View cpu occupancy: top
D) refresh reported memory usage: free-b-S5
Free command:
Total: the total amount of physical memory.
Used: how much has been used.
Free: how many are available?
Shared: the total amount of memory shared by multiple processes.
Buffers/cached: size of the disk cache.
The third line (- / + buffers/cached):
Used: how much has been used.
Free: how many are available?
II. Database
MySQL slow query configuration
1. What's the use of slow inquiry?
It can record all the SQL statements that exceed the long_query_time time, help you find the slow SQL, and facilitate us to optimize these SQL.
two。 Open slow query
Check whether the slow query status of MYSQL CVM is enabled. Execute the following command:
Show variables like'% slow%'
The current log_slow_queries status is OFF, indicating that slow queries are not currently open.
Enable slow query =:
Add the following information to [mysqld]:
[mysqld]
Log-slow-queries= "/ data/MySQLdata/mysql-slow.log"
Long_query_time = 4 (in s)
Log-queries-not-using-indexes
Log-slow-queries: represents the log storage directory of MYSQL slow query. This directory file must have write permission.
Long_query_time: maximum execution time. (as shown in the figure, MSYQL will record all SQL statements with more than 2 execution times. Here, the test time should not be too small, preferably within 5-10 seconds. Of course, it can be determined according to your own standards)
Log-queries-not-using-indexes: queries that do not use indexes will also be recorded in the log
Restart a MYSQL service after configuration
Or: run the following command to run the slow query log
Mysql > set global slow_query_log=ON
Query OK, 0 rows affected (0.03 sec)
Mysql > set global slow_launch_time=5
Query OK, 0 rows affected (0.00 sec)
Since mysql version 5.1.6, slow_query_log and slow_launch_time support writing files or database tables, and log opening and output modification can be dynamically modified at the global level.
You can simply start a slow query through set global slow_query_log=ON; without restarting the database!
3. Can be written directly to the configuration file my.cnf
Slow_query_log_file=/mysql/log/nagiosdb-slow.log
Slow_launch_time=5
Configuration can be completed!
Mysql slow query how to configure and view the mysql process method to tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.