mysql维护

1.通过 show engine innodb status命令来查看这些线程的状态:

mysql>show engine innodb status\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
#############################################################################################
#时间戳、监控名称、 per-second averages所基于的秒数&(当前时间与上次监控输出时间的秒数差)
#############################################################################################
Status:
===========================================
2015-11-26 15:10:40 7fcd9e04f700 INNODB MONITOR OUTPUT
==============================
Per second averages calculated from the last 2056 seconds

############################################################################################
#主后台线程的所做的工作
############################################################################################
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 165 srv_active, 0 srv_shutdown, 5784 srv_idle
srv_master_thread log flush and writes: 460

############################################################################################
#线程等待信号量的情况以及线程需要在mutex或rw-lock信号量上spin或者mutex的次数。线程等待信号量
#值越高意味着磁盘IO较高,或者InnoDB内有很多争用情况。争用源于高并发或者OS的线程调度策略问题。可通过适当设置
#innodb_thread_concurrency 系统变量来解决问题。Spin rounds per wait一行显示了每次OS wait的spinlock round数。
#需要注意的是,有关mutex spin waits,rounds和OS waits的信息会在MySQL5.7.8中移除,而在 SHOW ENGINE INNODB MUTEX输出中显示。
############################################################################################
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 64651
OS WAIT ARRAY INFO: signal count 77228
Mutex spin waits 93766, rounds 597449, OS waits 2581
RW-shared spins 100708, rounds 2316693, OS waits 49424
RW-excl spins 18852, rounds 504283, OS waits 8663
Spin rounds per wait: 6.37 mutex, 23.00 RW-shared, 26.75 RW-excl


##############################################################################################
#最近的外键约束错误,若没有则不显示该部分。内容包含失败的语句、引用及被引用的表和失败的外键约束的相关信息
##############################################################################################
------------------------
LATEST FOREIGN KEY ERROR
------------------------

##############################################################################################
#最近一次的死锁信息,若无则不显示该部分。内容包含死锁涉及到的事务、试图执行的语句、事务持有和需要的锁、InnodB决定回滚的事务等信息。
##############################################################################################
------------------------
LATEST DETECTED DEADLOCK
------------------------

##############################################################################################
#当前的事务相关信息,如果这部分报锁等待则说明应用存在锁争用,该部分的输出也可用以排查死锁
##############################################################################################
------------
TRANSACTIONS
------------
Trx id counter 932478331
Purge done for trx's n:o < 932478242 undo n:o < 0 state: running but idle
History list length 1297
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 72, OS thread handle 0x7fcd9e04f700, query id 358704 localhost root init
show engine innodb status
---TRANSACTION 932478196, not started
MySQL thread id 69, OS thread handle 0x7fcd9e5e5700, query id 358152 10.232.70.77 root cleaning up
---TRANSACTION 932478203, not started
MySQL thread id 70, OS thread handle 0x7fcd9e00e700, query id 358169 10.232.70.77 root cleaning up
---TRANSACTION 932478233, not started
MySQL thread id 71, OS thread handle 0x7fcd9e35b700, query id 358289 10.232.70.77 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 65, OS thread handle 0x7fcd9dfcd700, query id 334645 10.190.137.234 root cleaning up
---TRANSACTION 932472722, not started
MySQL thread id 66, OS thread handle 0x7fcd9df8c700, query id 339358 10.190.137.234 root cleaning up
---TRANSACTION 932478186, not started
MySQL thread id 61, OS thread handle 0x7fcd9e563700, query id 358119 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 932460023, not started
MySQL thread id 60, OS thread handle 0x7fcd9e0d1700, query id 291235 10.190.137.234 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 56, OS thread handle 0x7fcd9e1d5700, query id 269842 10.190.137.234 root cleaning up
---TRANSACTION 932478180, not started
MySQL thread id 54, OS thread handle 0x7fcd9e257700, query id 358106 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 932451765, not started
MySQL thread id 59, OS thread handle 0x7fcd9e112700, query id 259343 10.232.70.77 root cleaning up
---TRANSACTION 932478327, not started
MySQL thread id 58, OS thread handle 0x7fcd9e153700, query id 358651 10.232.70.77 root cleaning up
---TRANSACTION 932454338, not started
MySQL thread id 57, OS thread handle 0x7fcd9e194700, query id 269171 10.190.137.234 root cleaning up
---TRANSACTION 932475593, not started
MySQL thread id 55, OS thread handle 0x7fcd9e216700, query id 350465 10.190.137.234 root cleaning up
---TRANSACTION 932478139, not started
MySQL thread id 48, OS thread handle 0x7fcd9e6a8700, query id 358006 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 932477408, not started
MySQL thread id 42, OS thread handle 0x7fcd9ebbc700, query id 355820 10.190.137.234 root cleaning up
---TRANSACTION 932478260, not started
MySQL thread id 41, OS thread handle 0x7fcd9e31a700, query id 358374 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 932417383, not started
MySQL thread id 38, OS thread handle 0x7fcd9e3dd700, query id 358703 10.190.137.234 root cleaning up
---TRANSACTION 932478185, not started
MySQL thread id 37, OS thread handle 0x7fcd9e41e700, query id 358118 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 932370687, not started
MySQL thread id 35, OS thread handle 0x7fcd9e4a0700, query id 8695 10.190.137.234 root cleaning up
---TRANSACTION 932370593, not started
MySQL thread id 33, OS thread handle 0x7fcd9e4e1700, query id 8249 10.190.137.234 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 30, OS thread handle 0x7fcd9e5a4700, query id 166346 10.190.137.234 root cleaning up
---TRANSACTION 932421709, not started
MySQL thread id 26, OS thread handle 0x7fcd9e667700, query id 144410 10.190.137.234 root cleaning up
---TRANSACTION 932478272, not started
MySQL thread id 24, OS thread handle 0x7fcd9e6e9700, query id 358410 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 22, OS thread handle 0x7fcd9e76b700, query id 269893 10.190.137.234 root cleaning up
---TRANSACTION 932368911, not started
MySQL thread id 23, OS thread handle 0x7fcd9e72a700, query id 1337 10.190.137.234 root cleaning up
---TRANSACTION 932368830, not started
MySQL thread id 21, OS thread handle 0x7fcd9e7ac700, query id 985 10.190.137.234 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 20, OS thread handle 0x7fcd9e86f700, query id 1520 10.190.137.234 root cleaning up
---TRANSACTION 932474399, not started
MySQL thread id 19, OS thread handle 0x7fcd9e7ed700, query id 345728 10.232.70.77 root cleaning up
---TRANSACTION 932476821, not started
MySQL thread id 18, OS thread handle 0x7fcd9e82e700, query id 354071 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 16, OS thread handle 0x7fcd9e8b0700, query id 899 10.190.137.234 root cleaning up
---TRANSACTION 932478329, not started
MySQL thread id 13, OS thread handle 0x7fcd9e973700, query id 358657 10.232.70.77 root cleaning up
---TRANSACTION 932369105, not started
MySQL thread id 14, OS thread handle 0x7fcd9e932700, query id 355285 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 932477233, not started
MySQL thread id 7, OS thread handle 0x7fcd9eab8700, query id 355314 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 932477046, not started
MySQL thread id 12, OS thread handle 0x7fcd9e9b4700, query id 354680 10.232.70.77 root cleaning up
---TRANSACTION 932478188, not started
MySQL thread id 11, OS thread handle 0x7fcd9e9f5700, query id 358126 10.232.70.77 root cleaning up
---TRANSACTION 932478259, not started
MySQL thread id 10, OS thread handle 0x7fcd9ea36700, query id 358372 t7.accounttxn.api.dcfservice.com 10.190.137.237 root cleaning up
---TRANSACTION 932370737, not started
MySQL thread id 9, OS thread handle 0x7fcd9eb7b700, query id 13804 10.190.137.234 root cleaning up
---TRANSACTION 932427382, not started
MySQL thread id 6, OS thread handle 0x7fcd9eaf9700, query id 358701 10.190.137.234 root cleaning up
---TRANSACTION 932368852, not started
MySQL thread id 2, OS thread handle 0x7fcd9ebfd700, query id 2495 10.232.70.77 root cleaning up
---TRANSACTION 932478330, not started
MySQL thread id 1, OS thread handle 0x7fcda84c5700, query id 358664 10.232.70.77 root cleaning up

##############################################################################################
#InnoDB用于执行各类IO操作的线程相关信息,包含一个insert buffer thread、一个log thread、四个read thread、四个write thread。该部分内容还包含pending IO操作的信息和关于 IO性能统计信息线程的数量由
#innodb_read_io_threads 和 innodb_write_io_threads 参数控制
##############################################################################################
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
 ibuf aio reads: 0, log i/o&#39;s: 0, sync i/o&#39;s: 0
Pending flushes (fsync) log: 0; buffer pool: 0
4359829 OS file reads, 5273 OS file writes, 2209 OS fsyncs
1119.92 reads/s, 16413 avg bytes/read, 1.13 writes/s, 0.42 fsyncs/s

##############################################################################################
#insert buffer(也称change buffer)以及adaptive hash index相关信息。
#size:change buffer中使用的page数,等于seg size - (1 + free list len),其中1 +代表change buffer的header page。
#free list len:change buffer中空闲page数;seg_size:change buffer中的总page数;merges:change buffer merges总数;
#merged operation -insert:插入的记录merge数 -delete mark:deleted记录merge数 --delete&#xff1a;purge记录merge数;
#discarded operation --insert:插入合并操作取消的数量 --delete mark:删除合并操作取消的数量 --delete 清理合并操作取消的数量。
#自适应哈希索引状态信息:Hash table size:自适应哈希索引分配的数组单元总数;自适应哈希索引分配的页数;hash searches/s: 每秒平均hash 索引查找总数
#non-hash searches/s:每秒非hash索引查找总数
##############################################################################################
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 3915, seg size 3917, 60 merges
merged operations:
 insert 114, delete mark 3, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 1106381, node heap has 615 buffer(s)
1521.00 hash searches/s, 2153.74 non-hash searches/s

##############################################################################################
#InnoDB log相关信息。当前的log sequence number&#xff0c;有多少log刷到了磁盘,上一个检查点的位置,
#以及pending write和write性能统计
##############################################################################################
---
LOG
---
Log sequence number 104178900770
Log flushed up to   104178900770
Pages flushed up to 104178900770
Last checkpoint at  104178900770
0 pending log writes, 0 pending chkp writes
1117 log i/o&#39;s done, 0.22 log i/o&#39;s/second

##############################################################################################
#InnoDB Buffer Pool中页的读写统计。可通过这些数据计算出当前查询的数据文件IO操作数
##############################################################################################
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 549453824; in additional pool allocated 0
Dictionary memory allocated 726989
Buffer pool size   32767
Free buffers       1024
Database pages     31128
Old database pages 11470
Modified db pages  0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 2064783, not young 32472025
47.93 youngs/s, 8568.98 non-youngs/s
Pages read 4359179, created 1933, written 3574
1119.88 reads/s, 0.47 creates/s, 0.80 writes/s
Buffer pool hit rate 936 / 1000, young-making rate 2 / 1000 not 490 / 1000
Pages read ahead 794.26/s, evicted without access 1.88/s, Random read ahead 0.00/s
LRU len: 31128, unzip_LRU len: 0
I/O sum[0]:cur[2300927], unzip sum[0]:cur[0]

##############################################################################################
#InnoDB主线程正在做的事情&#xff0c;包括各类行操作的数量和性能等
##############################################################################################
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Main thread process no. 30837, id 140521232324352, state: sleeping
Number of rows inserted 224, updated 108, deleted 2, read 39335857
0.07 inserts/s, 0.03 updates/s, 0.00 deletes/s, 10691.56 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值