mysql 动态脚本 性能_mysql官方性能参数检测脚本

地址:

我的测试机器运行结果。

[root@localhost david_yeung]# ./tuning-primer.sh all|more

-- MYSQL PERFORMANCE TUNING PRIMER --

- By: Matthew Montgomery -

MySQL Version 5.0.45-log i686

Uptime = 15 days 1 hrs 24 min 34 sec

Avg. qps = 1

Total Questions = 2088868

Threads Connected = 13

Server has been running for over 48hrs.

It should be safe to follow these recommendations

To find out more information on how each of these

runtime variables effects performance visit:

http://dev.mysql.com/doc/refman/ ... stem-variables.html

Visit

for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES

The slow query log is enabled.

Current long_query_time = 1 sec.

You have 144295 out of 2088889 that take longer than 1 sec. to complete

Your long_query_time seems to be fine

BINARY UPDATE LOG

The binary update log is enabled

WORKER THREADS

Current thread_cache_size = 32

Current threads_cached = 19

Current threads_per_sec = 0

Historic threads_per_sec = 0

Your thread_cache_size is fine

MAX CONNECTIONS

Current max_connections = 100

Current threads_connected = 13

Historic max_used_connections = 32

The number of used connections is 32% of the configured maximum.

Your max_connections variable seems to be fine.

MEMORY USAGE

Max Memory Ever Allocated : 998 M

Configured Max Per-thread Buffers : 633 M

Configured Max Global Buffers : 796 M

Configured Max Memory Limit : 1 G

Physical Memory : 946.57 M

Max memory limit exceeds 90% of physical memory

KEY BUFFER

Current MyISAM index space = 157 M

Current key_buffer_size = 256 M

Key cache miss rate is 1 : 464

Key buffer fill ratio = 2.00 %

Your key_buffer_size seems to be too high.

Perhaps you can use these resources elsewhere

QUERY CACHE

Query cache is enabled

Current query_cache_size = 256 M

Current query_cache_used = 18 M

Current query_cache_limit = 64 M

Current Query cache Memory fill ratio = 7.37 %

Current query_cache_min_res_unit = 4 K

Your query_cache_size seems to be too high.

Perhaps you can use these resources elsewhere

MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS

Current sort_buffer_size = 1 M

Current read_rnd_buffer_size = 3 M

Sort buffer seems to be fine

JOINS

Current join_buffer_size = 132.00 K

You have had 2 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 = 1024 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 = 512 tables

You have a total of 472 tables

You have 473 open tables.

The table_cache value seems to be fine

TEMP TABLES

Current max_heap_table_size = 64 M

Current tmp_table_size = 64 M

Of 50784 temp tables, 23% were created on disk

Created disk tmp tables ratio seems fine

TABLE SCANS

Current read_buffer_size = 1020 K

Current table scan ratio = 738 : 1

read_buffer_size seems to be fine

TABLE LOCKING

Current Lock Wait ratio = 1 : 11710

Your table locking seems to be fine

RedHat测试通过,ubuntu出了点错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个 MySQL 8.0版本性能参数优化脚本示例: ```bash #!/bin/bash # MySQL 8.0参数优化脚本 # 获取当前CPU核心数 cpu_cores=$(grep -c ^processor /proc/cpuinfo) # 获取当前内存总量 total_mem=$(free -b | grep Mem | awk '{print $2}') # 计算innodb_buffer_pool_size参数大小 innodb_buffer_pool_size=$(echo "scale=0; $total_mem * 0.8" | bc) echo "innodb_buffer_pool_size = $innodb_buffer_pool_size" # 计算innodb_log_file_size参数大小 innodb_log_file_size=$(echo "scale=0; $total_mem * 0.05 / 2" | bc) echo "innodb_log_file_size = $innodb_log_file_size" # 计算innodb_read_io_threads参数大小 innodb_read_io_threads=$(echo "scale=0; $cpu_cores * 2" | bc) echo "innodb_read_io_threads = $innodb_read_io_threads" # 计算innodb_write_io_threads参数大小 innodb_write_io_threads=$(echo "scale=0; $cpu_cores * 2" | bc) echo "innodb_write_io_threads = $innodb_write_io_threads" # 计算innodb_thread_concurrency参数大小 innodb_thread_concurrency=$(echo "scale=0; $cpu_cores * 2" | bc) echo "innodb_thread_concurrency = $innodb_thread_concurrency" # 检查并设置参数 mysql -e "SET GLOBAL innodb_buffer_pool_size=$innodb_buffer_pool_size;" mysql -e "SET GLOBAL innodb_log_file_size=$innodb_log_file_size;" mysql -e "SET GLOBAL innodb_read_io_threads=$innodb_read_io_threads;" mysql -e "SET GLOBAL innodb_write_io_threads=$innodb_write_io_threads;" mysql -e "SET GLOBAL innodb_thread_concurrency=$innodb_thread_concurrency;" ``` 该脚本会根据当前系统的CPU核心数和内存总量计算出可用的 innodb_buffer_pool_size、innodb_log_file_size、innodb_read_io_threads、innodb_write_io_threads 和 innodb_thread_concurrency 参数大小,并设置相应的参数值。你可以根据实际情况修改计算公式和需要设置的参数。注意,执行该脚本需要有足够的权限。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值