mysql dba系統學習(7)二進制日誌之三

二進制日誌的相關係統變量mysql


1,binlog_cache_sizemax_binlog_cache_sizesql

表示的爲每一個session的事物分配的緩存緩存

通常的當插入或者修改數據的時候,不會馬上寫磁盤,通常會緩存起來,緩存的大小有binlog_cache_size 來控制session

mysql> show variables like"%binlog_cache%";ide

+-----------------------+----------------------+spa

| Variable_name| Value|日誌

+-----------------------+----------------------+orm

| binlog_cache_size| 32768|ci

| max_binlog_cache_size |18446744073709547520 |rem

+-----------------------+----------------------+


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)



3max_binlog_size

表示的是二進制日誌文件的大小


4sync_binlog

當前的參數是0,說明由系統來控制何時同步

mysql> show variables like"%sync_binlog%";

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| sync_binlog| 0|

+---------------+-------+

1 row in set (0.00 sec)

若是這個參數是1,那麼每次提交一個事物都會與磁盤同步一次數據

若是這個參數是2,那麼每次提交二個事物都會與磁盤同步一次數據

相關文章
相關標籤/搜索