Mysql高并发优化
my.cnf配置如下(仅供参考):
[client]
port=3306
socket=/usr/local/mysql/mysql.sock
[mysqld]
port=3306
socket=/usr/local/mysql/mysql.sock
binlog_format=MIXED
skip-external-locking
default-storage-engine=INNODB
key_buffer_size=512M
max_allowed_packet=16M
#每个连接需要的内存
sort_buffer_size=8M
read_buffer_size=8M
read_rnd_buffer_size=32M
myisam_sort_buffer_size=32M
myisam_max_sort_file_size=64M
thread_cache_size=64
query_cache_size=256M
query_cache_type=1
query_cache_limit=2M
thread_concurrency=16
max_connections=10000
max_connect_errors=10000
max_heap_table_size=32M
tmp_table_size=32M
ft_min_word_len=1
ft_stopword_file=
delay_key_write=ALL
#内部内存临时表的最大大小。这个变量不适用于用户创建的MEMORY表。
tmp_table_size=400M
tmpdir=/usr/local/mysql/temp
skip-name-resolve
#服务器在关闭非交互式连接之前等待活动的秒数
wait_timeout=28800
#服务器在关闭交互式连接之前等待活动的秒数
interactive_timeout=28800
innodb_buffer_pool_size=20000M
innodb_log_buffer_size=16M
innodb_log_file_size=256M
log-error=/usr/local/mysql/logs/mysql_error.log
pid-file=/usr/local/mysql/mysql.pid
datadir=/data/mysql/data
log-bin-index=mysql-bin.index
log_bin_trust_function_creators=1
innodb_flush_log_at_trx_commit=2
log_slave_updates
expire_logs_days=3
long_query_time=1
[mysqldump]
quick
max_allowed_packet=16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer=256M
read_buffer=2M
write_buffer=2M
[myisamchk]
key_buffer=256M
read_buffer=2M
write_buffer=2M
[mysqlhotcopy]
interactive-timeout