MySQL知识整理

安装

centos安装见

https://blog.csdn.net/wohiusdashi/article/details/89358071

https://blog.csdn.net/q258523454/article/details/84555847

命令

查看表的隔离级别

show variables like 'tx_isolation';

设置表的隔离级别

set tx_isolation='read-committed'

设置非自动提交

set @@autocommit=0;

参数

参数 参数的意义
innodb_version InnoDB引擎版本
tx_isolation 表的隔离级别
innodb_%io_threads IO线程数
innodb_old_blocks_pct LRU算法的midpoint位置,37则为尾端37%的位置
innodb_old_blocks_time 到达midpoint位置后,多久进入LRU热端,单位ms
innodb_log_buffer_size redo重做日志缓冲的大小,单位字节
innodb_max_dirty_pages_pct 脏页数量占比多少时,触发checkpoint,默认75%
innodb_lock_wait_timeout 锁等待超时时间 ,默认50s

引擎状态参数

show engine innodb status;

运行结果


----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 137428992
Dictionary memory allocated 145204
Buffer pool size   8191


## Free列表中页的数量

Free buffers       7813

## LRU列表中页的数量
Database pages     378


Old database pages 0

## 脏页:被修改的页,也就是和磁盘中数据不一致的页,需要checkpoint机制写回磁盘
## 脏页需要放到Flush列表,才会被写回磁盘。脏页也会存在于LRU列表。
## 脏页数量
Modified db pages  0


Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0


## LRU列移动到前端的次数
Pages made young 0, not young 0


0.00 youngs/s, 0.00 non-youngs/s
Pages read 291, created 87, written 461
0.00 reads/s, 0.00 creates/s, 0.00 writes/s

## 缓冲池命中率
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000


Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s

## LRU页的数量,unzipLRU页的数量
LRU len: 378, unzip_LRU len: 0


I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Process ID=4452, Main thread ID=140129213609728, state: sleeping
Number of rows inserted 2100, updated 3, deleted 0, read 2478
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

InnoDB存储引擎结构

缓冲池,数据页、索引页

checkpoint机制

索引

B+树结构

按粒度分

  • 表锁
  • 行锁
  • 意向锁
  • 间隙锁

按性质分

  • 排他锁
  • 共享锁

事务

特性

  • 原子性
  • 一致性
  • 隔离性
  • 持久性

备份

posted @ 2016-08-26 00:16  清泉白石  阅读(2161)  评论(0编辑  收藏  举报