这里使用的是mysql Ver 14.14 Distrib 5.6.19, for Linux (i686) using EditLine wrapper一、mysql目录文件ibdata1:系统表空间 包含数据字典、回滚日志/undolog等(insert buff ...
这里使用的是mysql Ver 14.14 Distrib 5.6.19, for Linux (i686) using EditLine wrapper
一、mysql目录文件
ibdata1:系统表空间 包含数据字典、回滚日志/undolog等
(insert buffer segment/double write segment/rollback segment/index segment/dictionary segment/undo segment)
ib_logfile0/ib_logfile1:事务日志/redolog
mysql-relay-bin:中继日志
binarylog:二进制日志
general_log.log:常规日志
mysql_error.log:错误日志
slow_query.log:慢日志
.ibd:用户表空间-数据文件(insert buffer bitmap page/leaf page segment/none leaf page segment)
Innodb buffer pool(内存):undo page /insert buffer page/adaptive hash index/index page/lock info/data dictionary
二、mysql线程
FILE IO
--------FILE I/O--------I/O thread 0 state: waiting for i/o request (insert buffer thread)I/O thread 1 state: waiting for i/o request (log thread)I/O thread 2 state: waiting for i/o request (read thread)I/O thread 3 state: waiting for i/o request (read thread)I/O thread 4 state: waiting for i/o request (read thread)I/O thread 5 state: waiting for i/o request (read thread)I/O thread 6 state: waiting for i/o request (write thread)I/O thread 7 state: waiting for i/o request (write thread)I/O thread 8 state: waiting for i/o request (write thread)I/O thread 9 state: waiting for i/o request (write thread)Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] , ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0Pending flushes (fsync) log: 0; buffer pool: 0393 OS file reads, 5 OS file writes, 5 OS fsyncs0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
InnoDB Plugin版本开始增加了默认IO thread的数量,默认的read thread和write thread分别增大到了4个,并且不再使用innodb_file_io_threads参数,而是分别使用innodb_read_io_threads和innodb_write_io_threads参数。
运行情况Binlog_cache_use 表示binlog_cache内存方式被用上了多少次,Binlog_cache_disk_use表示binlog_cache临时文件方式被用上了多少次
13、innodb_file_per_table
innodb_file_per_table=1
独立表空间
优点:
缺点:单表增加过大,如超过100个G
结论:共享表空间在Insert操作上少有优势。其它都没独立表空间表现好。当启用独立表空间时,请合理调整一 下:innodb_open_files ,InnoDB Hot Backup(冷备)的表空间cp不会面对很多无用的copy了。而且利用innodb hot backup及表空间的管理命令可以实现单现移动。
14、增加本地端口,以应对大量连接
echo ‘1024 65000′ > /proc/sys/net/ipv4/ip_local_port_range
该参数指定端口的分配范围,该端口是向外访问的限制。mysql默认监听的3306端口即使有多个请求链接,也不会有影响。但是由于mysql是属于高内存、高cpu、高io应用,不建议把多少应用于mysql混搭在同一台机器上。即使业务量不大,也可以通过降低单台机器的配置,多台机器共存来实现更好。
15、增加队列的链接数
echo ‘1048576’ > /proc/sys/net/ipv4/tcp_max_syn_backlog
建立链接的队列的数越大越好,但是从另一个角度想,实际环境中应该使用连接池更合适,避免重复建立链接造成的性能消耗。使用连接池,链接数会从应用层面更可控些。
16、设置链接超时时间
echo ’10’ > /proc/sys/net/ipv4/tcp_fin_timeout
该参数主要为了降低TIME_WAIT占用的资源时长。尤其针对http短链接的服务端或者mysql不采用连接池效果比较明显。
参考文章
http://dev.cmcm.com/archives/107/comment-page-1
http://www.zhdba.com/mysqlops/2012/05/24/mysql-io/
http://blog.itpub.net/22664653/viewspace-1063134/
http://liyangliang.me/posts/2014/03/innodb_flush_log_at_trx_commit-and-sync_binlog/
http://www.cnblogs.com/snifferhu/p/4736479.html
http://www.cnblogs.com/xuanzhi201111/p/4040681.html
http://mysqllover.com/?p=636
原标题:【mysql】关于IO/内存方面的一些优化
关键词:MYSQL
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。