stay MySQL How to calculate 、 Statistics redo log （redo log) How about the generation of ？ for example 10 Within minutes , How much is generated M Of redo log Well ?30 How much more... In minutes M Of redo log......MySQL Didn't like Oracle The system view like in counts the data , But we can use some methods to calculate the amount of binary log generated .
Although I am in this blog “MySQL in Redo Log Summary of relevant important parameters ” This paper introduces the in ,MySQL 8.0 Introduced innodb_dedicated_server Adaptive parameters , It can be set dynamically based on the memory of the server innodb_buffer_pool_size,innodb_log_file_size and innodb_flush_method. By default , This parameter is off . But in MySQL 8.0 Before , By calculating redo logs （redo log） To judge by the amount of production innodb_log_buffer_size and innodb_log_file_size It's very necessary to know if the size is right , I think that even if MySQL 8.0 Under the version , This is also of great reference and research significance . We do statistics 、 Analyze and calculate redo logs （redo log） Production of , To judge InnoDB How long can the transaction log file of the transaction log file support be switched . Supported by specific data , You can analyze and judge , Otherwise, it's hard to make bricks without straw .
stay MySQL Of information_schema.global_status or performance_schema.global_status There is a server state variable in (Server Status Variables）Innodb_os_log_written, It records Innodb Redo log of （redo log） Production of , It records and writes InnoDB The number of bytes in the redo log file , It's a cumulative value . The official document describes this server state variable as follows
We're mainly through a planned mission / Events are scheduled to be collected periodically Innodb_os_log_written The server state variable gets the size of the redo log , Store it in innodb_log_size_his In the table , Convenient for analysis and statistics . The specific script is as follows ：
Be careful ：performance_schema.global_status yes MySQL 5.7 Introduced , and MySQL 8.0 Start ,information_schema.global_status It's just thrown away . So pay attention to MySQL edition , Choose the right script .
Then create MySQL Scheduled tasks for / Event scheduling , This can be set according to demand elasticity .
Then you can do some simple analysis and statistics based on this table , for example , Statistics 10 How many redo logs generated in minutes . As shown below ：