设为首页 加入收藏

TOP

mysql配置(二)
2015-11-21 01:28:09 来源: 作者: 【 】 浏览:1
Tags:mysql 配置
g issues. Because the flush to disk operation only occurs approximately once
per second, you can lose up to a second of transactions with any mysqld process crash.
? With a value of 2, the contents of the InnoDB log buffer are written to the log file after each transaction
commit and the log file is flushed to disk approximately once per second. Once-per-second flushing
is not 100% guaranteed to happen every second, due to process scheduling issues. Because the
flush to disk operation only occurs approximately once per second.

大致的意思是将该属性主要是为数据库的ACID原则进行服务的,并且默认为1,但是实际情况下(我们项目是结合spring和mybatis,可能是某一方面设置不当),设置为2会提高很多的事务性能,从文档中可以看得出来,“1的时候,innodb的缓存会在事务提交或者每秒钟时都会进行磁盘的刷新操作,2的时候,innodb缓存会在提交事务时写入到事务日志但不会刷新磁盘,然后在每秒钟时进行磁盘刷新操作”,2要比1提高很多性能,但是对于隐患来说,我没有太好的理解,按照文档中给出的结果好像是“在操作系统崩溃的时候,2的情况下,会丢失1秒的数据”,但是仔细想想发生的时间节点,1.事务没有commit时,断电了,此时肯定数据是没有更新成功的,因为都还没有来得及写入事务日志,2.事务提交后,在写入事务日志的时候,发生断电,此时无论是参数的值是1还是2,都应该恢复不了数据了,3.每秒钟刷新磁盘时,发生断电,按照《高性能mysql》的字面意思,此时既然事务日志已经持久化了,那么重启后,数据是会自动恢复的。那么疑问来了,2和1的隐患到底在什么情况下会发生。

我在http://blog.csdn.net/qing_gee/article/details/42551179,这篇文章中有介绍。

2.innodb_buffer_pool_size=2G
innodb_buffer_pool_instances=1

这两个参数,你必须得看看这个mysql:提升性能的最关键参数

3.binlog-format = MIXED

binlog_format=mixed:二进制日志的格式为mixed,该中模式是statement和row模式的结合体,注意查看我同事写的http://www.xx566.com/detail/177.html这篇文章,里面讲解了我们项目在二进制日志设置上遇到的问题和解决办法,如果遇到类似的问题后,会有所帮助。
In MySQL 5.7, the default format is STATEMENT.
You must have the SUPER privilege to set either the global or session binlog_format value.
The rules governing when changes to this variable take effect and how long the effect lasts are the same
as for other MySQL server system variables. See Section 13.7.4, “SET Syntax”, for more information.
When MIXED is specified, statement-based replication is used, except for cases where only row-based
replication is guaranteed to lead to proper results. For example, this happens when statements contain
user-defined functions (UDF) or the UUID() function. An exception to this rule is that MIXED always
uses statement-based replication for stored functions and triggers.

4.innodb_lock_wait_timeout = 20
你可以看看这个Transactional和mysql究竟有什么关系,你会明白的,我相信!

5.transaction-isolation = REPEATABLE-READ
高性能mysql札记:事务,这里面,我有大量的论证。

当然了,我之前也从各地摘录了一些关于参数介绍的,如果你觉得需要的话,我会给你地址的。mysql:配置参数优化建议

写到这,我觉得我的套路就要结束了,这些经验,我真想不说出来的!

最后啊,记得要重启mysql的不然,肯定是没有效果的。

service mysql restart

结语:分享知识是快乐的,我只好这样安慰自己吧,哈哈,其实我心态是很宽的,所谓“人逢知己千杯少”,我主要是想结交朋友的,哈哈。

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇统计mysql数据库、表大小 下一篇mysql学习记录(二十)--MysqlSer..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: