rss· 投稿· 设为首页· 加入收藏· 繁體版
当前位置: 火魔网 » 数据库 » MySQL

mysql tuner-primer使用说明(mysql运行状态的shell脚本)

        mysql tuner-primer 是一个比较简单好用的检查mysql运行状态的shell脚本,它主要通过查询mysql中的variables设定和status 并结合当前系统情况给出mysql运行的状态和建议,主要包括以下内容的检查
slow query慢速查询
binlog 二进制日志
max connections 最大连接数
threads 线程数
key buffer size 关键字缓冲
query cache 查询缓存
sort operations 排序
join operations 多表联接
tmp tables 临时表
open files 打开文件数
table cache 表缓存
table locking 锁表
table scans 表扫描
innodb status
total memory used 内存使用

下载并改变执行权限:

wget http://www.day32.com/MySQL/tuning-primer.sh
chmod a+x tuning-primer.sh
./tuning-primer.sh

首先会要求输入服务器的用户名和密码,并提示保存在当前用户目录下配置文件。

再次执行脚本就会运行,并分别给出参数配置。返回例子如下:

        -- MYSQL PERFORMANCE TUNING PRIMER --
             - By: Matthew Montgomery -MySQL Version 5.0.45-log i686Uptime = 3 days 2 hrs 48 min 39 sec
Avg. qps = 20
Total Questions = 5628906
Threads Connected = 2Server has been running for over 48hrs.
It should be safe to follow these recommendationsTo find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory ServiceSLOW QUERIES
The slow query log is enabled.
Current long_query_time = 10 sec.
You have 0 out of 5628927 that take longer than 10 sec. to complete
Your long_query_time may be too high, I typically set this under 5 sec.BINARY UPDATE LOG
The binary update log is enabled
The expire_logs_days is not set.
The mysqld will retain the entire binary log until RESET MASTER or PURGE MASTER LOGS commands are run manually
Setting expire_log_days will allow you to remove old binary logs automatically
See http://dev.mysql.com/doc/refman/5.0/en/purge-master-logs.htmlWORKER THREADS
Current thread_cache_size = 8
Current threads_cached = 6
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fineMAX CONNECTIONS
Current max_connections = 1000
Current threads_connected = 2
Historic max_used_connections = 22
The number of used connections is 2% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See "MEMORY USAGE" section to make sure you are not over-allocatingMEMORY USAGE
Max Memory Ever Allocated : 114 M
Configured Max Per-thread Buffers : 2 G
Configured Max Global Buffers : 58 M
Configured Max Memory Limit : 2 G
Physical Memory : 3.95 G
Max memory limit seem to be within acceptable normsKEY BUFFER
Current MyISAM index space = 4 M
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 17932
Key buffer fill ratio = 8.00 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhereQUERY CACHE
Query cache is enabled
Current query_cache_size = 32 M
Current query_cache_used = 12 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 37.96 %
Current query_cache_min_res_unit = 4 K
MySQL won't cache query results that are larger than query_cache_limit in sizeSORT OPERATIONS
Current sort_buffer_size = 1 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fineJOINS
Current join_buffer_size = 132.00 K
You have had 39 queries where a join could not use an index properly
You have had 2 joins without keys that check for key usage after each row
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.OPEN FILES LIMIT
Current open_files_limit = 5000 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE

Current table_cache value = 256 tables
You have a total of 560 tables
You have 256 open tables.
Current table_cache hit rate is 39%, while 100% of your table cache is in use
You should probably increase your table_cacheTEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 152787 temp tables, 96% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.TABLE SCANS
Current read_buffer_size = 1020 K
Current table scan ratio = 198 : 1
read_buffer_size seems to be fineTABLE LOCKING
Current Lock Wait ratio = 1 : 3538
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=2'.

顶一下
(0)
踩一下
(0)