db1 my.cnf
[client]
port = 3306
socket = /data/mysql55/mysql.sock
[mysqld]
port = 3306
socket = /data/mysql55/mysql.sock
datadir = /data/mysql55
server-id = 2
expire_logs_days = 15
log-bin = /data/mysqllog55/mysql-bin
binlog-do-db =
binlog-do-db = mysql
#binlog-ignore-db = mysql
#log_slave_updates = 1
#master-host = 172.16.1.15
#master-user = rep
#master-password = reppass
#master-port = 3306
#master-connect-retry = 60
replicate-do-db =
replicate-do-db = mysql
#general_log=1
#general_log_file = /data/mysql55/my.log
wait_timeout = 120
#interactive_timeout = 64800
skip-name-resolve
#explicit_defaults_for_timestamp
##default-character-set = utf8
#lower_case_table_names = 1
back_log = 300
max_connections = 1000
max_connect_errors = 32
max_allowed_packet = 16M
table_cache = 2048
binlog_cache_size = 1M
max_heap_table_size = 64M
tmp_table_size = 64M
key_buffer_size = 32M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
sort_buffer_size = 4M
join_buffer_size = 2M
thread_cache_size = 64
thread_concurrency = 8
thread_stack = 192K
query_cache_type = 1
query_cache_size = 64M
query_cache_limit = 2M
tmp_table_size = 64M
#ft_min_word_len = 2
##default_storage_engine = INNODB
##default_table_type = INNODB
transaction_isolation = REPEATABLE-READ
##log_slow_queries
slow_query_log
long_query_time = 6
#log_long_format
slow_query_log_file = /data/mysql55/slow.log
#
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
#myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
#skip-bdb
##innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2G
##innodb_data_file_path = ibdata1:128M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
测试结果:
[root@db1 ~]# ./tuning-primer.sh
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
- Modified By: Darkz 2011-11-21 -
MySQL Version 5.5.32-log x86_64
Uptime = 25 days 11 hrs 37 min 2 sec
Avg. qps = 337
Total Questions = 744041305
Threads Connected = 11
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/5.5/en/server-system-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 = 6.000000 sec.
You have 1174 out of 744041329 that take longer than 6.000000 sec. to complete
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is enabled
Binlog sync is not enabled, you could loose binlog records during a server crash
WORKER THREADS
Current thread_cache_size = 64
Current threads_cached = 53
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 1000
Current threads_connected = 13
Historic max_used_connections = 268
The number of used connections is 26% of the configured maximum.
Your max_connections variable seems to be fine.
INNODB STATUS
Current InnoDB index space = 1.51 G
Current InnoDB data space = 6.40 G
Current InnoDB buffer pool free = 0 %
Current innodb_buffer_pool_size = 2.00 G
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory
MEMORY USAGE
Max Memory Ever Allocated : 8.70 G
Configured Max Per-thread Buffers : 24.59 G
Configured Max Global Buffers : 2.10 G
Configured Max Memory Limit : 26.70 G
Physical Memory : 23.44 G
Max memory limit exceeds 90% of physical memory
KEY BUFFER
Current MyISAM index space = 106 K
Current key_buffer_size = 32 M
Key cache miss rate is 1 : 10
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine
QUERY CACHE
Query cache is enabled
Current query_cache_size = 64 M
Current query_cache_used = 27 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 43.66 %
Current query_cache_min_res_unit = 4 K
MySQL won't cache query results that are larger than query_cache_limit in size
SORT OPERATIONS
Current sort_buffer_size = 4 M
Current read_rnd_buffer_size = 16 M
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 2.00 M
You have had 2227 queries where a join could not use an index properly
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 = 8192 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_open_cache = 2048 tables
Current table_definition_cache = 400 tables
You have a total of 345 tables
You have 1420 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 775049 temp tables, 9% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 2 M
Current table scan ratio = 25 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 66333
Your table locking seems to be fine
修改最大连接数:
mysql> set GLOBAL max_connections = 500;
再次测试:
[root@db1 ~]# ./tuning-primer.sh
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
- Modified By: Darkz 2011-11-21 -
MySQL Version 5.5.32-log x86_64
Uptime = 25 days 12 hrs 0 min 57 sec
Avg. qps = 337
Total Questions = 744170432
Threads Connected = 9
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/5.5/en/server-system-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 = 6.000000 sec.
You have 1174 out of 744170494 that take longer than 6.000000 sec. to complete
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is enabled
Binlog sync is not enabled, you could loose binlog records during a server crash
WORKER THREADS
Current thread_cache_size = 64
Current threads_cached = 55
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 500
Current threads_connected = 10
Historic max_used_connections = 268
The number of used connections is 53% of the configured maximum.
Your max_connections variable seems to be fine.
INNODB STATUS
Current InnoDB index space = 1.51 G
Current InnoDB data space = 6.40 G
Current InnoDB buffer pool free = 0 %
Current innodb_buffer_pool_size = 2.00 G
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory
MEMORY USAGE
Max Memory Ever Allocated : 8.70 G
Configured Max Per-thread Buffers : 12.29 G
Configured Max Global Buffers : 2.10 G
Configured Max Memory Limit : 14.40 G
Physical Memory : 23.44 G
Max memory limit seem to be within acceptable norms #最大内存限制似乎在可接受标准
KEY BUFFER
Current MyISAM index space = 106 K
Current key_buffer_size = 32 M
Key cache miss rate is 1 : 10
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine
QUERY CACHE
Query cache is enabled
Current query_cache_size = 64 M
Current query_cache_used = 31 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 49.36 %
Current query_cache_min_res_unit = 4 K
MySQL won't cache query results that are larger than query_cache_limit in size
SORT OPERATIONS
Current sort_buffer_size = 4 M
Current read_rnd_buffer_size = 16 M
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 2.00 M
You have had 2230 queries where a join could not use an index properly
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 = 8192 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_open_cache = 2048 tables
Current table_definition_cache = 400 tables
You have a total of 345 tables
You have 1420 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 775587 temp tables, 9% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 2 M
Current table scan ratio = 25 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 66349
Your table locking seems to be fine
阅读(3844) | 评论(0) | 转发(0) |