Home Database Mysql Tutorial mysql binlog日志优化及思路_MySQL

mysql binlog日志优化及思路_MySQL

Jun 01, 2016 pm 01:41 PM
binary optimization Influence Database installation

bitsCN.com
mysql binlog日志优化及思路 在数据库安装完毕,对于binlog日志参数设置,有一些参数的调整,来满足业务需求或使性能最大化。Mysql日志主要对io性能产生影响,本次主要关注binlog 日志。 查一下二进制日志相关的参数      mysql> show variables like '%binlog%';+--------------------------------+----------------------+ | Variable_name                  | Value                | +--------------------------------+----------------------+ | binlog_cache_size              | 1048576              | | innodb_locks_unsafe_for_binlog | OFF                  | | max_binlog_cache_size          | 18446744073709547520 | | max_binlog_size                | 1073741824           | | sync_binlog                    | 0                    | +--------------------------------+----------------------+5 rows in set (0.14 sec)   其中innodb_locks_unsafe_for_binlog 参数是innodb存储引擎特有的与binlog相关的参数,默认是关闭的 Binlog_cache_size:默认大小是37268即32K.我们计算一下上面binlog_cache_size参数大小,1048576/1024/1024 = 1M,根据事务需要调整大小。次参数表示在事务中容纳二进制日志sql语句的缓存大小。那么怎么理解二进制日志缓存,就是服务器支持事务存储引擎并且服务器启用了二进制日志(-log-bin选项)的前提下为每个客户端分配的内存,是每个client都可以分配设置大小的binlog cache空间。我们可以通过以下两个状态变量判断binlog_cache_size的使用情况: 1  binlog_cache_use: Thenumber of transactions that used the temporary binary log cache.(使用二进制日志缓存的事务的数量)     2   Binlog_cache_disk_use: The number oftransactions that used the binary log cache but that exceeded the value of binlog_cache_size andused a temporary file to store changes from the transaction.  使用二进制日志缓存并且值达到了binlog_cache_size设置的值,用临时文件存储来自事务的变化这样的事务数量 Max_binlog_cache_size: 默认值是18446744073709547520,这个值很大,够我们使用的了。此参数和binlog_cache_size相对应,代表binlog所能使用的cache最大使用大小。如果系统中事务过多,而此参数值设置有小,则会报错。Max_binlog_size: 1073741824=1G  binlog的最大值,一般设置为512M或1G,一般不能超过1G。此参数不能非常严格控制binlog的大小,特别是在遇到大事务时,而binlog日志又到达了尾部,为了保证事务完整性,不切换日志,把所有sql都写到当前日志。这根oracle redo日志有点不一样(感兴趣的可以google)。Mysql记录的是mysql数据库逻辑变化信息,称之为event,实际上就是引起数据库变化的query语句。 Sync_binlog: 参数不仅影响数据库的性能,而且还影响数据库数据的完整性。Sync_binlog参数选项有如下选择   1 Sync_binlog=0,这意味着当事务提交之后,mysql不做fsync(文件系统同步)之类的磁盘同步指令刷新binlog_cache中的信息到磁盘,而让filesystem自行决定什么时候来做同步,或者cache满了之后才同步到磁盘。2 sync_binlog=n,当每进行n次提交之后,mysql将进行一次fsync之类的磁盘同步指令来将binlog_cache中的数据强制写入磁盘。 Sync_binlog=0,这是数据库默认设置,性能也是最好的,也是最危险的。一旦系统crash,在binlog_cache中的所有binlog信息都会被丢失。当synn_binlog=1的时候,是最安全性能消耗也最大,完成一个事务,同步一次。系统crash了,也只是丢掉了未完成的事务信息。没坐过这方面的测试,设置为1和0在性能方面的差距,有做过的说在高并发系统中,两种设置性能可高达5倍甚至更多。  这需要我们来做出选择,是要性能最好,还是最安全。 资料:《mysql性能调优与架构设计》    http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.htmlhttp://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html  作者 aeolus_pu bitsCN.com

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

VBOX_E_OBJECT_NOT_FOUND(0x80bb0001)VirtualBox error VBOX_E_OBJECT_NOT_FOUND(0x80bb0001)VirtualBox error Mar 24, 2024 am 09:51 AM

When trying to open a disk image in VirtualBox, you may encounter an error indicating that the hard drive cannot be registered. This usually happens when the VM disk image file you are trying to open has the same UUID as another virtual disk image file. In this case, VirtualBox displays error code VBOX_E_OBJECT_NOT_FOUND(0x80bb0001). If you encounter this error, don’t worry, there are some solutions you can try. First, you can try using VirtualBox's command line tools to change the UUID of the disk image file, which will avoid conflicts. You can run the command `VBoxManageinternal

How to turn off the comment function on TikTok? What happens after turning off the comment function on TikTok? How to turn off the comment function on TikTok? What happens after turning off the comment function on TikTok? Mar 23, 2024 pm 06:20 PM

On the Douyin platform, users can not only share their life moments, but also interact with other users. Sometimes the comment function may cause some unpleasant experiences, such as online violence, malicious comments, etc. So, how to turn off the comment function of TikTok? 1. How to turn off the comment function of Douyin? 1. Log in to Douyin APP and enter your personal homepage. 2. Click "I" in the lower right corner to enter the settings menu. 3. In the settings menu, find "Privacy Settings". 4. Click "Privacy Settings" to enter the privacy settings interface. 5. In the privacy settings interface, find "Comment Settings". 6. Click "Comment Settings" to enter the comment setting interface. 7. In the comment settings interface, find the "Close Comments" option. 8. Click the "Close Comments" option to confirm closing comments.

In-depth interpretation: Why is Laravel as slow as a snail? In-depth interpretation: Why is Laravel as slow as a snail? Mar 07, 2024 am 09:54 AM

Laravel is a popular PHP development framework, but it is sometimes criticized for being as slow as a snail. What exactly causes Laravel's unsatisfactory speed? This article will provide an in-depth explanation of the reasons why Laravel is as slow as a snail from multiple aspects, and combine it with specific code examples to help readers gain a deeper understanding of this problem. 1. ORM query performance issues In Laravel, ORM (Object Relational Mapping) is a very powerful feature that allows

Discussion on Golang's gc optimization strategy Discussion on Golang's gc optimization strategy Mar 06, 2024 pm 02:39 PM

Golang's garbage collection (GC) has always been a hot topic among developers. As a fast programming language, Golang's built-in garbage collector can manage memory very well, but as the size of the program increases, some performance problems sometimes occur. This article will explore Golang’s GC optimization strategies and provide some specific code examples. Garbage collection in Golang Golang's garbage collector is based on concurrent mark-sweep (concurrentmark-s

C++ program optimization: time complexity reduction techniques C++ program optimization: time complexity reduction techniques Jun 01, 2024 am 11:19 AM

Time complexity measures the execution time of an algorithm relative to the size of the input. Tips for reducing the time complexity of C++ programs include: choosing appropriate containers (such as vector, list) to optimize data storage and management. Utilize efficient algorithms such as quick sort to reduce computation time. Eliminate multiple operations to reduce double counting. Use conditional branches to avoid unnecessary calculations. Optimize linear search by using faster algorithms such as binary search.

Decoding Laravel performance bottlenecks: Optimization techniques fully revealed! Decoding Laravel performance bottlenecks: Optimization techniques fully revealed! Mar 06, 2024 pm 02:33 PM

Decoding Laravel performance bottlenecks: Optimization techniques fully revealed! Laravel, as a popular PHP framework, provides developers with rich functions and a convenient development experience. However, as the size of the project increases and the number of visits increases, we may face the challenge of performance bottlenecks. This article will delve into Laravel performance optimization techniques to help developers discover and solve potential performance problems. 1. Database query optimization using Eloquent delayed loading When using Eloquent to query the database, avoid

How to read binary files in Golang? How to read binary files in Golang? Mar 21, 2024 am 08:27 AM

How to read binary files in Golang? Binary files are files stored in binary form that contain data that a computer can recognize and process. In Golang, we can use some methods to read binary files and parse them into the data format we want. The following will introduce how to read binary files in Golang and give specific code examples. First, we need to open a binary file using the Open function from the os package, which will return a file object. Then we can make

Easily learn to convert hexadecimal to binary in Go language Easily learn to convert hexadecimal to binary in Go language Mar 15, 2024 pm 04:45 PM

Title: Easily learn to convert hexadecimal to binary in Go language. Specific code examples are required. In computer programming, conversion operations between different base numbers are often involved. Among them, conversion between hexadecimal and binary is relatively common. In the Go language, we can achieve hexadecimal to binary conversion through some simple code examples. Let us learn together. First, let's take a look at the representation methods of hexadecimal and binary. Hexadecimal is a method of representing numbers, using 0-9 and A-F to represent 1

See all articles