二進制日志的相關系統變量
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,binlog_cache_use
表示的是當前事物的數量
當前沒有事物
mysql> showstatus like "%binlog_cache_use%";
+------------------+-------+
| Variable_name| Value |
+------------------+-------+
| Binlog_cache_use | 0|
+------------------+-------+
創建事物
mysql>show table status like 'tt'\G;
*************************** 1. row***************************
Name: tt
Engine: MyISAM(這種引擎不支持事物)
Version: 10
Row_format: Fixed
Rows: 1
Avg_row_length: 8
Data_length: 8
Max_data_length: 2251799813685247
Index_length: 1024
Data_free: 0
Auto_increment: NULL
Create_time: 2013-09-03 11:42:18
Update_time: 2013-09-03 15:24:13
Check_time: NULL
Collation: utf8_general_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
mysql>drop table tt;
Query OK, 0 rows affected (0.01 sec)
mysql> create table tt(id int)engine=innodb;?設置成innodb的引擎
Query OK, 0 rows affected, 2 warnings (0.02sec)
mysql> insert into tt values(1);
Query OK, 1 row affected (0.00 sec)
mysql> show variables like"autocommit";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit| ON|
+---------------+-------+
1 row in set (0.00 sec)
mysql> setautocommit=0;關閉自動提交事物
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like"autocommit";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit| OFF|
+---------------+-------+
1 row in set (0.01 sec)
mysql> insert into tt values(2);
Query OK, 1 row affected (0.01 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql>showstatus like"%binlog_cache_use%";
+------------------+-------+
| Variable_name| Value |
+------------------+-------+
| Binlog_cache_use | 2|
+------------------+-------+
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,那么每次提交二個事物都會與磁盤同步一次數據
from:?http://wolfword.blog.51cto.com/4892126/1287973
總結
以上是生活随笔為你收集整理的mysql dba系统学习(7)二进制日志binlog之三的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。