# MySQL client
[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
# MySQL server
[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
max-heap-table-size = 64M
thread-concurrency = 16
ft-min-word-len = 4
default-storage-engine = INNODB
transaction-isolation = REPEATABLE-READ
tmp-table-size = 64M
bulk-insert-buffer-size = 64M
# *** NETWORK ***
back-log = 50
max-connections = 1024
max-user-connections = 0
max-connect-errors = 10
net_buffer_length = 8K
max-allowed-packet = 16M
# *** SESSION THREAD ***
thread-cache-size = 64
thread-stack = 192K
# *** TABLE CACHE ***
table-open-cache = 2048
sort-buffer-size = 8M
join-buffer-size = 8M
# *** QUERY Specific options ***
query-cache-limit = 2M
query-cache-min-res-unit = 4096
query-cache-size = 64M
query-cache-strip-comments = 0
query-cache-type = 1
query-cache-wlock-invalidate = 0
# *** LOG ***
Slow-query-log
long-query-time = 1
#log-queries-not-using-indexes
#log-error
# *** Replication related settings ***
server-id = 2
binlog-format = mixed
binlog-cache-size = 32K
max-binlog-size = 512M
sync-binlog = 0
#innodb-support-xa = 1
log-bin = mysql-bin
log-bin-index = mysql-bin.index
relay-log = mysql-relay-bin
relay-log-index = mysql-relay-bin.index
expire-logs-days = 10
log-slave-updates = 1
skip-slave-start
# *** MyISAM Specific options ***
read-buffer-size = 2M
read-rnd-buffer-size = 16M
key-buffer-size = 1024M
myisam-sort-buffer-size = 16M
myisam-max-sort-file-size = 10G
myisam-repair-threads = 1
myisam-recover
# *** INNODB Specific options ***
innodb-fast-shutdown = 1
innodb-force-recovery = 0
innodb-buffer-pool-size = 4G
innodb-additional-mem-pool-size = 16M
innodb-log-buffer-size = 8M
innodb-log-file-size = 256M
innodb-log-files-in-group = 3
innodb-mirrored-log-groups = 1
innodb-data-file-path = ibdata1:10240M:autoextend
#innodb-autoextend-increment = 8M
innodb-file-per-table = 1
innodb-write-io-threads = 8
innodb-read-io-threads = 8
innodb-thread-concurrency = 16
innodb-flush-log-at-trx-commit = 2
innodb-flush-method = O-DIRECT
innodb-max-dirty-pages-pct = 90
innodb-lock-wait-timeout = 120
[mysqldump]
quick
max-allowed-packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key-buffer-size = 512M
sort-buffer-size = 512M
read-buffer = 8M
write-buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld-safe]
open-files-limit = 60000
## 参数解释
##
## *** NETWORK ***
## back-log连接请求队列中允许存放的最大连接请求数
## max-connections最大连接数
## max-user-connections每个用户的最大连接数,0为不限制
## max-connect-errors最大的错误连接数
## net_buffer_length网络包传输中,传输消息之前的net buffer初始化大小
## max-allowed-packet与上面的net参数相对应,是net_buffer_length的最大值
##
## *** SESSION THREAD ***
## thread-cache-size线程缓冲池中存放的连接线程数
## thread-stack每个连接线程被创建的时候,分配内存的大小,系统默认192K(不需要更改)
## show status like '%thread%';查看状态
##
## *** QUERY Specific options ***
## query-cache-limit存放的单条Query最大Result Set,默认1M
## query-cache-min-res-unit每个Result Set存放的最小内存大小,默认4K
## query-cache-size系统中用于Query Cache内存的大小
## query-cache-strip-comments = 0
## query-cache-type系统中是否打开Query Cache功能
## query-cache-wlock-invalidate针对MyISAM存储引擎,设置当有write lock在某个表上面的时候,读请求时要等待write lock释放资源之后
## 再查询还是允许直接从Query Cache中读取结果,默认值为0,可以直接从Query Cache中读取结果
## show status like 'Qcache%';查看效果
##
## *** INNODB Specific options ***
## innodb-fast-shutdown有0,1,2三个值
## 0代表当MySQL关闭时,InnoDB需要完成所有的full purge和merge insert buffer操作,这可能几个小时,一般升级plugin时,设置0
## 1是默认值,不完成full和merge,但是在缓冲池的一些数据脏页会刷新到磁盘
## 2表示不完成full和merge,也不把缓冲池中的数据脏页刷新到磁盘,而是将日志写入日志文件,虽然不会丢失数据,但下次启动MySQL的时间会变长
##
## innodb-force-recovery默认值是0,表示当需要恢复时,执行所有的恢复操作。当不能恢复时,记录到错误日志。《InnoDB...》P40
## innodb-buffer-pool-size使用show engine innodb status在BUFFER POOL AND MEMORY可以查看使用情况
## innodb-file-per-table将每个基于InnoDB存储引擎的表单独产生一个表空间。表名.ibd
## innodb-mirrored-log-groups指定了日志镜像文件组的数量,默认为1,代表只有一个日志文件组,没有镜像。
## innodb-flush-log-at-trx-commit有0,1,2三个值
## 0代表当提交事务时,并不将事务的重做日志写入磁盘上的日志文件,而是等待主线程每秒的刷新
## 1在commit时将重做日志缓冲同步写到磁盘
## 2在异步到磁盘
## innodb-autoextend-increment可以设置最后一个数据文件每次自动扩展的大小
## 默认大小为8M,最大是1000M,如果设置自动扩展的大小大于初始的大小,则产生的表空间文件大小为两个值的和
## innodb-flush-method用来设置InnoDB打开和同步数据文件以及日志文件的方式
## innodb-thread-concurrency要控制Innodb 内部的并发处理线程数量的最大值,系统内部会有相应的检测机制进行检测控制并发线程数量
## Query Cache 存放的单条Query 最大Result Set ,默认1M
##
## *** LOG ***
## log-queries-not-using-indexes如果运行的SQL语句没有使用索引,则MySQl数据库同样会将这条SQL语句记录到慢查询日志文件
## log-error错误日志,在MySQL5.5中自动打开
##
## *** Replication related settings ***
## binlog-cache-size 该参数是基于session<>P57,通过SHOW GLOBAL STATUS LIKE 'binlog-cache%',查看临时文件使用次数和缓冲使用次数
## sync-binlog=[N]表示没写缓冲多少次就同步到磁盘,设置为1,表示同步写磁盘。默认为0《InnoDB...》P58