mysql配置文件优化

cdshrewd Oracle DBA  2009-06-03 09:01:23
8G内存,2CPU,show status如下:
+-----------------------------------+------------+
| Variable_name | Value |
+-----------------------------------+------------+
| Aborted_clients | 187 |
| Aborted_connects | 403 |
| Binlog_cache_disk_use | 0 |
| Binlog_cache_use | 425 |
| Bytes_received | 531 |
| Bytes_sent | 13404 |
| Com_show_processlist | 7 |
| Com_show_slave_hosts | 0 |
| Com_show_slave_status | 0 |
| Com_show_status | 1 |
| Compression | OFF |
| Connections | 4223 |
| Created_tmp_disk_tables | 0 |
| Created_tmp_files | 1034 |
| Created_tmp_tables | 3 |
| Delayed_errors | 0 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| Flush_commands | 1 |
| Handler_commit | 0 |
| Handler_delete | 0 |
| Handler_discover | 0 |
| Handler_prepare | 0 |
| Handler_read_first | 2 |
| Handler_read_key | 0 |
| Handler_read_next | 852768 |
| Handler_read_prev | 0 |
| Handler_read_rnd | 94 |
| Handler_read_rnd_next | 234 |
| Handler_rollback | 0 |
| Handler_savepoint | 0 |
| Handler_savepoint_rollback | 0 |
| Handler_update | 2 |
| Handler_write | 852900 |
| Innodb_buffer_pool_pages_data | 977 |
| Innodb_buffer_pool_pages_dirty | 0 |
| Innodb_buffer_pool_pages_flushed | 1571 |
| Innodb_buffer_pool_pages_free | 130088 |
| Innodb_buffer_pool_pages_latched | 0 |
| Innodb_buffer_pool_pages_misc | 7 |
| Innodb_buffer_pool_pages_total | 131072 |
| Innodb_buffer_pool_read_ahead_rnd | 2 |
| Innodb_buffer_pool_read_ahead_seq | 0 |
| Innodb_buffer_pool_read_requests | 1557762 |
| Innodb_buffer_pool_reads | 546 |
| Innodb_buffer_pool_wait_free | 0 |
| Innodb_buffer_pool_write_requests | 136454 |
| Innodb_data_fsyncs | 1298 |
| Innodb_data_pending_fsyncs | 0 |
| Innodb_data_pending_reads | 0 |
| Innodb_data_pending_writes | 0 |
| Innodb_data_read | 12226560 |
| Innodb_data_reads | 569 |
| Innodb_data_writes | 2136 |
| Innodb_data_written | 59769856 |
| Innodb_dblwr_pages_written | 1571 |
| Innodb_dblwr_writes | 230 |
| Innodb_log_waits | 0 |
| Innodb_log_write_requests | 16006 |
| Innodb_log_writes | 618 |
| Innodb_os_log_fsyncs | 821 |
| Innodb_os_log_pending_fsyncs | 0 |
| Innodb_os_log_pending_writes | 0 |
| Innodb_os_log_written | 8187392 |
| Innodb_page_size | 16384 |
| Innodb_pages_created | 364 |
| Innodb_pages_read | 613 |
| Innodb_pages_written | 1571 |
| Innodb_row_lock_current_waits | 0 |
| Innodb_row_lock_time | 0 |
| Innodb_row_lock_time_avg | 0 |
| Innodb_row_lock_time_max | 0 |
| Innodb_row_lock_waits | 0 |
| Innodb_rows_deleted | 2084 |
| Innodb_rows_inserted | 39831 |
| Innodb_rows_read | 1280978 |
| Innodb_rows_updated | 0 |
| Key_blocks_not_flushed | 392 |
| Key_blocks_unused | 275516 |
| Key_blocks_used | 279690 |
| Key_read_requests | 1320018326 |
| Key_reads | 40555791 |
| Key_write_requests | 162387880 |
| Key_writes | 21700413 |
| Last_query_cost | 0.000000 |
| Max_used_connections | 62 |
| Ndb_cluster_node_id | 0 |
| Ndb_config_from_host | |
| Ndb_config_from_port | 0 |
| Ndb_number_of_data_nodes | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_files | 887 |
| Open_streams | 0 |
| Open_tables | 567 |
| Opened_tables | 1 |
| Prepared_stmt_count | 8 |
| Qcache_free_blocks | 0 |
| Qcache_free_memory | 0 |
| Qcache_hits | 0 |
| Qcache_inserts | 0 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 0 |
| Qcache_queries_in_cache | 0 |
| Qcache_total_blocks | 0 |
| Questions | 3789028 |
| Rpl_status | NULL |
| Select_full_join | 0 |
| Select_full_range_join | 0 |
| Select_range | 0 |
| Select_range_check | 0 |
| Select_scan | 4 |
| Slave_open_temp_tables | 0 |
| Slave_retried_transactions | 0 |
| Slave_running | OFF |
| Slow_launch_threads | 0 |
| Slow_queries | 0 |
| Sort_merge_passes | 0 |
| Sort_range | 0 |
| Sort_rows | 94 |
| Sort_scan | 1 |
| Table_locks_immediate | 2564450 |
| Table_locks_waited | 0 |
| Tc_log_max_pages_used | 0 |
| Tc_log_page_size | 0 |
| Tc_log_page_waits | 0 |
| Threads_cached | 0 |
| Threads_connected | 8 |
| Threads_created | 4222 |
| Threads_running | 2 |
| Uptime | 272066 |
| Uptime_since_flush_status | 272066 |
+-----------------------------------+------------+
...全文
32 点赞 收藏 2
写回复
2 条回复
phpboy 2009年06月04日
sort_buffer_size、read_buffer_size 设置为 8 M 就差不多了

key_buffer = 2G

max_connections=300

如果不行的话,再适当降低 max_connections 增加 sort_buffer_size、read_buffer_size

回复 点赞
cdshrewd 2009年06月03日
配置如下:

# The following options will be passed to all MySQL clients
[client]
port = 3306
default-character-set=utf8
[mysqld]
port = 3306
skip-locking
key_buffer = 4G
max_allowed_packet = 16M
table_cache = 600
tmp_table_size = 256M
sort_buffer_size = 64M
net_buffer_length = 8K
read_buffer_size = 64M
read_rnd_buffer_size = 64M
#myisam_sort_buffer_size = 16M
myisam_sort_buffer_size = 1G
myisam_max_sort_file_size= 6G
myisam_max_extra_sort_file_size=4G
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
default-character-set=utf8
max_connections=150
bulk_insert_buffer_size=64M
thread_concurrency = 8
log-bin=mysql-bin

server-id = 1

innodb_data_home_dir = /lonton/data/mysql/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /lonton/data/mysql/
innodb_log_arch_dir = /lonton/data/mysql/
innodb_buffer_pool_size = 2G
innodb_additional_mem_pool_size = 32M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_thread_concurrency = 8
[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
应该如何优化呢?
回复 点赞
发动态
发帖子
MySQL
创建于2007-09-28

2.4w+

社区成员

5.5w+

社区内容

MySQL相关内容讨论专区
社区公告
暂无公告