1. 參見《高性能mysql》的第8章;mysql
2. 在第一步的基礎上,而後藉助https://tools.percona.com/來建立。sql
如下是經過tools.percona.com生成的mysql.cnf配置文件,基於16c,32G的配置socket
[mysql]性能
# CLIENT #
port = 3306
socket = /var/lib/mysql/mysql.sockit
[mysqld]io
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /var/lib/mysql/mysql.sock
pid-file = /var/lib/mysql/mysql.pidinnodb
# MyISAM #
key-buffer-size = 32M
myisam-recover-options = FORCE,BACKUPtable
# SAFETY #
max-allowed-packet = 16M
max-connect-errors = 1000000
innodb = FORCEclass
# DATA STORAGE #
datadir = /var/lib/mysql/thread
# BINARY LOGGING #
log-bin = /var/lib/mysql/mysql-bin
expire-logs-days = 14
sync-binlog = 1
# CACHES AND LIMITS #
tmp-table-size = 32M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0
max-connections = 5000
thread-cache-size = 100
open-files-limit = 65535
table-definition-cache = 4096
table-open-cache = 4096
# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 26G
# LOGGING #log-error = /var/lib/mysql/mysql-error.loglog-queries-not-using-indexes = 1slow-query-log = 1slow-query-log-file = /var/lib/mysql/mysql-slow.log