ITPub博客

首页 > 数据库 > MySQL > mysql二进制日志相关参数

mysql二进制日志相关参数

原创 MySQL 作者:lsq_008 时间:2015-08-18 10:48:58 0 删除 编辑
1,binlog_cache_size和max_binlog_cache_size
表示的为每个session的事物分配的缓存
当插入或者修改数据的时候,不会立刻写入磁盘,而是会缓存起来,缓存的大小由binlog_cache_size 来控制

mysql> show variables like '%binlog_cache%';
+-----------------------+----------------------+
| Variable_name         | Value                |
+-----------------------+----------------------+
| binlog_cache_size     | 32768                |
| max_binlog_cache_size | 18446744073709547520 |
+-----------------------+----------------------+
2 rows in set (0.00 sec)


2 binlog_cache_use
表示的是当前事物的数量
mysql> show status like '%binlog_cache_use%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Binlog_cache_use | 7     |
+------------------+-------+
1 row in set (0.00 sec)

mysql> show table status like 'emp'\G;
*************************** 1. row ***************************
           Name: emp
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 10
 Avg_row_length: 1638
    Data_length: 16384
Max_data_length: 0
   Index_length: 16384
      Data_free: 141557760
 Auto_increment: NULL
    Create_time: 2015-08-16 21:39:30
    Update_time: NULL
     Check_time: NULL
      Collation: latin1_swedish_ci
       Checksum: NULL
 Create_options: 
        Comment: 
1 row in set (0.05 sec)


ERROR: 
No query specified


mysql> insert into emp values(1000,'lsq');
Query OK, 1 row affected (0.03 sec)

mysql> show status like '%binlog_cache_use%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Binlog_cache_use | 8     |
+------------------+-------+
1 row in set (0.00 sec)

mysql> insert into emp values(1001,'lsq');
Query OK, 1 row affected (0.00 sec)

mysql> insert into emp values(1002,'lsq');
Query OK, 1 row affected (0.04 sec)

mysql> insert into emp values(1003,'lsq');
Query OK, 1 row affected (0.02 sec)


mysql> show status like '%binlog_cache_use%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Binlog_cache_use | 11    |
+------------------+-------+
1 row in set (0.00 sec)

mysql> show variables like 'autocommit%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | ON    |
+---------------+-------+
1 row in set (0.00 sec)


mysql> set autocommit=0;
Query OK, 0 rows affected (0.02 sec)

mysql> show variables like 'autocommit%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | OFF   |
+---------------+-------+
1 row in set (0.00 sec)

mysql> insert into emp values(999,'lsq');
Query OK, 1 row affected (0.00 sec)

mysql> 
mysql> 
mysql> show status like '%binlog_cache_use%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Binlog_cache_use | 11    |
+------------------+-------+
1 row in set (0.00 sec)

mysql> insert into emp values(998,'lsq');
Query OK, 1 row affected (0.00 sec)

mysql> show status like '%binlog_cache_use%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Binlog_cache_use | 11    |
+------------------+-------+
1 row in set (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.02 sec)

mysql> show status like '%binlog_cache_use%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Binlog_cache_use | 12    |
+------------------+-------+
1 row in set (0.00 sec)


3,max_binlog_size 二进制日志文件的大小

4,sync_binlog
当前的参数是0,代表由系统来控制何时同步
mysql> show variables like"%sync_binlog%";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sync_binlog| 0|
+---------------+-------+
1 row in set (0.00 sec)
如果这个参数是1,那么每次提交一个事物都会与磁盘同步一次数据
如果这个参数是2,那么每次提交二个事物都会与磁盘同步一次数据

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10972173/viewspace-1774931/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: mysql查询日志
请登录后发表评论 登录
全部评论
十余年大型金融及电信系统数据库管理经验,曾服务于中国建设银行、中国移动。对oracle,mysql数据库有深入了解。 擅长python开发,独立开发了开源数据库自动化监控运维平台Power Monitor。

注册时间:2008-02-29

  • 博文量
    335
  • 访问量
    1369124