0%

MySQL配置文件

在启动MySQL数据库时可以没有配置文件,这种情况下,MySQL会按照编译时的默认参数设置启动实例

1
2
3
4
# 查看MySQL数据库实例启动时,会在哪些位置查找配置文件
mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf /usr/local/mysql/bin/my.cnf ~/.my.cnf

按照顺序读取配置文件,且如果多个配置文件中有相同的参数,则以读取到的最后一个配置文件为准

为什么springboot可以直接执行

先看一下springboot打包生成的MANIFEST.MF内容是什么

1
2
3
4
5
6
7
8
9
10
11
12
Manifest-Version: 1.0
Implementation-Title: exam-admin
Implementation-Version: 1.0-SNAPSHOT
Start-Class: com.zhanghe.exam.Application
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Build-Jdk-Spec: 1.8
Spring-Boot-Version: 2.1.6.RELEASE
Created-By: Maven Archiver 3.4.0
Main-Class: org.springframework.boot.loader.JarLauncher


可以看到程序的主类是org.springframework.boot.loader.JarLauncher,所以在使用java -jar来执行springboot项目时,真正执行的是JarLauncher中的main方法,该类的作用是Springboot内部提供的工具,用于执行Application的工具类

这些特性通过spring-boot-maven-plugin插件打包完成

Innodb缓冲池

Innodb存储引擎是基于磁盘存储的,将其中的记录按照页的方式进行管理,由于CPU速度和磁盘速度相差太多,所以基于磁盘的数据库系统通常使用缓冲池技术来提高数据库的整体性能

缓冲池就是一块内存区域,通过内存的速度来弥补磁盘速度慢对于数据库性能的影响,在数据库进行读取页的操作,先从磁盘读到的页放在缓存池中,下一次读到相同页时,首先判断该页是否在缓冲池中,如果在,则直接读取该页,否则再去读取磁盘上的页;对数据库进行修改页操作时,首先会修改在缓冲池中的页,然后在以一定的频率刷新到磁盘,通过一种Checkpoint的机制刷新回到磁盘

阅读全文 »

Innodb监控

Innodb由于支持事务操作,是mysql中使用最多的存储引擎,所以如何监控Innodb存储引擎以进行性能优化是在使用mysql过程中遇到最多的,那么如何进行监控呢?

show engine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
-- 显示innodb存储引擎状态的统计和配置信息
show engine innodb status;

展示的主要内容有
-----------------
BACKGROUND THREAD --后台线程
-----------------
srv_master_thread loops: 19610306 srv_active, 0 srv_shutdown, 9705136 srv_idle --统计Innodb启动后的活动
srv_master_thread log flush and writes: 29312902 --写入和刷新日志的次数
----------
SEMAPHORES --信号量包含了线程等待互斥锁或读写锁的信息
----------
OS WAIT ARRAY INFO: reservation count 52795642 --os等待数组信息,分配插槽的次数
OS WAIT ARRAY INFO: signal count 57522728 --os等待数组信息,线程通过数组得到信号的次数
RW-shared spins 0, rounds 77349143, OS waits 9180114 --共享锁期间,读写锁存器上自旋等待个数,自旋循环迭代次数以及操作系统调用的等待个数
RW-excl spins 0, rounds 179767865, OS waits 2534243 --排他锁期间,读写锁存器上自旋等待个数,自旋循环迭代次数以及操作系统调用的等待个数
RW-sx spins 2068750, rounds 40171680, OS waits 844522 --共享排他锁期间,读写锁存器上自选等待个数,自旋循环迭代次数以及操作系统调用的等待个数
Spin rounds per wait: 77349143.00 RW-shared, 179767865.00 RW-excl, 19.42 RW-sx --对于每一个互斥锁,操作系统调用等待的每一个自旋循环迭代个数
------------
TRANSACTIONS --包含所有当前正在执行的事务的信息
------------
Trx id counter 1888483436 --当前事务id
Purge done for trx s n:o < 1888483436 undo n:o < 0 state: running but idle --所有编号小于1888483436的事务都已经从历史记录列表中清除了,清除旧的MVCC行时所用的事务id,这个值与当前事务ID进行比较,就可以知道有多少老版本的数据未被清除
History list length 17 --历史列表的长度,位于Innodb数据文件的撤销空间里的页面的数目,如果事务执行了更新并提交,该数目就会增加,当清理进程移除旧版本数据时,该数目会减少
LIST OF TRANSACTIONS FOR EACH SESSION: 当前事务列表
---TRANSACTION 422068961001072, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068960999248, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961005632, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961013840, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961012016, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961010192, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961001984, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961000160, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961017488, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961011104, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961012928, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961004720, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961002896, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961003808, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 422068961007456, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O --各种IO操作的Innodb内部线程以及执行了多少次IO操作
--------
-- 有四个线程
-- insert buffer thread 负责插入缓冲合并
-- log thread 负责异步刷日志
-- read thread 执行预读操作以尝试预先读取Innodb预感需要的数据
-- write thread 刷脏缓冲
I/O thread 0 state: waiting for completed aio requests (insert buffer thread) --IO线程的状态
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] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0 -- 挂起操作的信息,aio是指异步io
83934578288 OS file reads, 282688772 OS file writes, 190348192 OS fsyncs --innodb启动后的总统计信息
984.40 reads/s, 16384 avg bytes/read, 10.15 writes/s, 9.12 fsyncs/s --最后一次显示后的总统计信息
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX --插入缓冲区与自适应散列统计信息
-------------------------------------
Ibuf: size 1, free list len 3078, seg size 3080, 8815726 merges --在页中插入缓冲索引树的当前大小,空闲列表的长度,在包含插入缓冲树与头信息的文件段中已分配页的个数,被合并页的个数
merged operations:
insert 6898371, delete mark 38430046, delete 1226485 --通过类型区分,索引页被执行合并操作的次数
discarded operations:
insert 1019, delete mark 0, delete 0 --无须合并丢弃操作的数量
Hash table size 34673, node heap has 1 buffer(s)
Hash table size 34673, node heap has 74 buffer(s)
Hash table size 34673, node heap has 1 buffer(s)
Hash table size 34673, node heap has 1 buffer(s)
Hash table size 34673, node heap has 1 buffer(s)
Hash table size 34673, node heap has 2 buffer(s)
Hash table size 34673, node heap has 28 buffer(s)
Hash table size 34673, node heap has 7 buffer(s)
5203.54 hash searches/s, 128.14 non-hash searches/s --成功使用自适应散列索引查找的数量,当不能使用自适应索引时向下搜索B树的次数
---
LOG --Innodb日志中活动信息
---
Log sequence number 319041331834 --当前日志序号
Log flushed up to 319041331699 -- 日志已经刷到的位置
Pages flushed up to 319033170877
Last checkpoint at 319033170877 -- 上一个检查点,当前日志序列号LSN
0 pending log flushes, 0 pending chkp writes
169033177 log i/o's done, 8.92 log i/o's/second --挂起的日志写入次数,挂起的检查点写入个数,innodb启动后的IO操作个数,从最近一次显示之后的每秒IO操作个数
----------------------
BUFFER POOL AND MEMORY --Innodb缓冲池与内存使用情况
----------------------
Total large memory allocated 137428992 --分配的内存
Dictionary memory allocated 1204989 --被数据字典表与索引对象所占空间的字节数
Buffer pool size 8191 --缓冲池个数
Free buffers 1024 --空闲缓冲区个数
Database pages 7052 --当前缓冲区LRU队列的长度(分配用来存储数据库页的页数)
Old database pages 2583 --旧的LRU队列的长度
Modified db pages 530 --需要刷新的页面的数量(脏数据库页数)
Pending reads 0 --挂起读操作的个数
Pending writes: LRU 0, flush list 0, single page 0 --通过LRU算法,等待刷新的页数
Pages made young 983912385, not young 304833753259 --因为最近第一次被访问时,变成新页面的数目和没有变成新页面的数目
1.54 youngs/s, 16246.04 non-youngs/s -- 上述两个值每秒的速率
Pages read 83934649301, created 4135172, written 103030852 --读操作的页面数目,在缓冲区中创建但是没有读取的页面数目,写操作的页面数目
984.40 reads/s, 0.17 creates/s, 1.15 writes/s -- 上述值美妙的速率
Buffer pool hit rate 972 / 1000, young-making rate 0 / 1000 not 478 / 1000 --读取到的页面数与获得的缓冲池页面的比例,变为新页面的页面数与获得缓冲池页面的比例,没有变为新页面的页面数与获得缓冲池页面的比例
Pages read ahead 913.79/s, evicted without access 5.60/s, Random read ahead 0.00/s --预读的速率与不通过访问剔除的预读页面的个数
LRU len: 7052, unzip_LRU len: 0 --LRU列表的长度,unzip_LRU列表的长度
I/O sum[4121]:cur[0], unzip sum[0]:cur[0] --IO操作的次数:当前间隔的IO
--------------
ROW OPERATIONS --行操作
--------------
0 queries inside InnoDB, 0 queries in queue --当前有多少个正在执行的查询,在innodb_thread_concurrency队列中的查询个数
0 read views open inside InnoDB --只读视图的数量
Process ID=1543, Main thread ID=140593683990272, state: sleeping --线程id以及状态
Number of rows inserted 56092883, updated 133093048, deleted 40729879, read 477150639699 --从innodb启动后,插入、更新、删除、读取的行数
0.19 inserts/s, 7.73 updates/s, 0.00 deletes/s, 138100.85 reads/s -- 速率


阅读全文 »

system profiler

mac系统中提供了system profiler来查看系统的详细信息,包括硬件、网络以及安装的软件

系统信息
阅读全文 »