码迷,mamicode.com
首页 > 数据库 > 详细

mysql初步调试

时间:2016-05-03 12:41:49      阅读:936      评论:0      收藏:0      [点我收藏+]

标签:

第一次这么近距离的接触源码,有点兴奋,又有点不知所措,尼玛随便一个源文件都有几千行,你说怎么看,还有一些数不清的数据结构,函数,类等乱七八糟的东西。

我装的mysql版本是5.7.12,然后运行平台是centos 6.5 x64 (应该是x64)。

启动gdb

gdb --args /usr/local/mysql-5.7.12/bin/mysqld

也可以用如下,如果你设置了链接的话

gdb --args mysqld

然后你就进入了gdb的环境中

技术分享

在此呢,我们可以用b 函数名来添加断点

技术分享

这个个断点是我在mysqld.cc的源文件中找的一个函数,随便瞎找的一个。

然后用下面的这个命令来启动mysqld

技术分享

然后就是gdb c,c的意思是继续的意思,刚刚run --defaults-file=/etc/my.cnf --user=root已经运行了,而且到达设置的断点mysqld_main

如果此时我们用另一个客户端service mysql status一下的话

技术分享

发现mysql的服务并没有启动

于是我们继续在gdb中输入命令c

技术分享

...

技术分享

并且这里是等待模式,没有出现(gdb)

然后在另一可以客户端继续service mysql status一下的话

技术分享

会发现mysql的服务已经启动了

继续在这个客户端操作,登录mysql

mysql -uroot -hlocalhost -p

技术分享

发现可以成功的登录进去了

然后再看看调试环境下

技术分享

可以发现出现了一个新的线程,应该是客户端连接的线程吧。

然后退出mysql,exit,发现gdb环境下没啥变化,没有说线程结束了什么的。

但是如果我们重新开一个客户端登录mysql,又会多出一个线程

技术分享

关闭了客户端仍然没有发现这两个线程退出的迹象。

当在一个客户端关闭mysql服务的时候,service mysql stop,

会发现在gdb出现了这个

技术分享

然后

Shutting down MySQL......................................这个点点无限循环下去

技术分享

于是在gdb环境下,输入命令c

(gdb) c
Continuing.
2016-05-03T10:49:28.524672Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 180093ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
[Thread 0x7fff957fb700 (LWP 4113) exited]
[Thread 0x7fffb8c82700 (LWP 4162) exited]
2016-05-03T10:49:28.569814Z 0 [Note] Giving 0 client threads a chance to die gracefully
2016-05-03T10:49:28.569875Z 0 [Note] Shutting down slave threads
2016-05-03T10:49:28.569896Z 0 [Note] Forcefully disconnecting 0 remaining clients
2016-05-03T10:49:28.569912Z 0 [Note] Event Scheduler: Purging the queue. 0 events
[Thread 0x7fffb8cc3700 (LWP 4135) exited]
2016-05-03T10:49:28.578091Z 0 [Note] Binlog end
2016-05-03T10:49:28.581076Z 0 [Note] Shutting down plugin ‘ngram‘
2016-05-03T10:49:28.581127Z 0 [Note] Shutting down plugin ‘ARCHIVE‘
2016-05-03T10:49:28.581135Z 0 [Note] Shutting down plugin ‘partition‘
2016-05-03T10:49:28.581139Z 0 [Note] Shutting down plugin ‘BLACKHOLE‘
2016-05-03T10:49:28.581170Z 0 [Note] Shutting down plugin ‘CSV‘
2016-05-03T10:49:28.581180Z 0 [Note] Shutting down plugin ‘MEMORY‘
2016-05-03T10:49:28.581189Z 0 [Note] Shutting down plugin ‘MyISAM‘
2016-05-03T10:49:28.581240Z 0 [Note] Shutting down plugin ‘MRG_MYISAM‘
2016-05-03T10:49:28.581250Z 0 [Note] Shutting down plugin ‘PERFORMANCE_SCHEMA‘
2016-05-03T10:49:28.581321Z 0 [Note] Shutting down plugin ‘INNODB_SYS_VIRTUAL‘
2016-05-03T10:49:28.581337Z 0 [Note] Shutting down plugin ‘INNODB_SYS_DATAFILES‘
2016-05-03T10:49:28.581341Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESPACES‘
2016-05-03T10:49:28.581345Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN_COLS‘
2016-05-03T10:49:28.581349Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN‘
2016-05-03T10:49:28.581352Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FIELDS‘
2016-05-03T10:49:28.581356Z 0 [Note] Shutting down plugin ‘INNODB_SYS_COLUMNS‘
2016-05-03T10:49:28.581363Z 0 [Note] Shutting down plugin ‘INNODB_SYS_INDEXES‘
2016-05-03T10:49:28.581367Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESTATS‘
2016-05-03T10:49:28.581370Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLES‘
2016-05-03T10:49:28.581374Z 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_TABLE‘
2016-05-03T10:49:28.581377Z 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_CACHE‘
2016-05-03T10:49:28.581381Z 0 [Note] Shutting down plugin ‘INNODB_FT_CONFIG‘
2016-05-03T10:49:28.581411Z 0 [Note] Shutting down plugin ‘INNODB_FT_BEING_DELETED‘
2016-05-03T10:49:28.581417Z 0 [Note] Shutting down plugin ‘INNODB_FT_DELETED‘
2016-05-03T10:49:28.581420Z 0 [Note] Shutting down plugin ‘INNODB_FT_DEFAULT_STOPWORD‘
2016-05-03T10:49:28.581424Z 0 [Note] Shutting down plugin ‘INNODB_METRICS‘
2016-05-03T10:49:28.581428Z 0 [Note] Shutting down plugin ‘INNODB_TEMP_TABLE_INFO‘
2016-05-03T10:49:28.581431Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_POOL_STATS‘
2016-05-03T10:49:28.581435Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE_LRU‘
2016-05-03T10:49:28.581438Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE‘
2016-05-03T10:49:28.581442Z 0 [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX_RESET‘
2016-05-03T10:49:28.581445Z 0 [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX‘
2016-05-03T10:49:28.581449Z 0 [Note] Shutting down plugin ‘INNODB_CMPMEM_RESET‘
2016-05-03T10:49:28.581452Z 0 [Note] Shutting down plugin ‘INNODB_CMPMEM‘
2016-05-03T10:49:28.581456Z 0 [Note] Shutting down plugin ‘INNODB_CMP_RESET‘
2016-05-03T10:49:28.581459Z 0 [Note] Shutting down plugin ‘INNODB_CMP‘
2016-05-03T10:49:28.581463Z 0 [Note] Shutting down plugin ‘INNODB_LOCK_WAITS‘
2016-05-03T10:49:28.581466Z 0 [Note] Shutting down plugin ‘INNODB_LOCKS‘
2016-05-03T10:49:28.581470Z 0 [Note] Shutting down plugin ‘INNODB_TRX‘
2016-05-03T10:49:28.581473Z 0 [Note] Shutting down plugin ‘InnoDB‘
[Thread 0x7fffb8d04700 (LWP 4112) exited]
2016-05-03T10:49:28.581822Z 0 [Note] InnoDB: FTS optimize thread exiting.
2016-05-03T10:49:28.590938Z 0 [Note] InnoDB: Starting shutdown...
[Thread 0x7fff96bfd700 (LWP 4110) exited]
[Thread 0x7fff975fe700 (LWP 4109) exited]
2016-05-03T10:49:28.691896Z 0 [Note] InnoDB: Dumping buffer pool(s) to /usr/local/mysql-5.7.12/data/ib_buffer_pool
2016-05-03T10:49:28.692817Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 160503 18:49:28
[Thread 0x7fffb0dbd700 (LWP 4101) exited]
[Thread 0x7fff961fc700 (LWP 4111) exited]
[Thread 0x7fffb17be700 (LWP 4100) exited]
[Thread 0x7fff97fff700 (LWP 4108) exited]
[Thread 0x7fffabfff700 (LWP 4102) exited]
[Thread 0x7fffa8dfa700 (LWP 4107) exited]
[Thread 0x7fffaabfd700 (LWP 4104) exited]
[Thread 0x7fffa97fb700 (LWP 4106) exited]
[Thread 0x7fffaa1fc700 (LWP 4105) exited]
[Thread 0x7fffb23e5700 (LWP 4098) exited]
[Thread 0x7fffab5fe700 (LWP 4103) exited]
[Thread 0x7fffb37e7700 (LWP 4096) exited]
[Thread 0x7fffb2de6700 (LWP 4097) exited]
[Thread 0x7fffb87ef700 (LWP 4088) exited]
[Thread 0x7fffb41e8700 (LWP 4095) exited]
[Thread 0x7fffb4be9700 (LWP 4094) exited]
[Thread 0x7fffb55ea700 (LWP 4093) exited]
[Thread 0x7fffb69ec700 (LWP 4091) exited]
[Thread 0x7fffb5feb700 (LWP 4092) exited]
[Thread 0x7fffb73ed700 (LWP 4090) exited]
[Thread 0x7fffb7dee700 (LWP 4089) exited]
2016-05-03T10:49:29.967622Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2739027
2016-05-03T10:49:29.970363Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2016-05-03T10:49:29.970416Z 0 [Note] Shutting down plugin ‘sha256_password‘
2016-05-03T10:49:29.970422Z 0 [Note] Shutting down plugin ‘mysql_native_password‘
2016-05-03T10:49:29.970683Z 0 [Note] Shutting down plugin ‘binlog‘
2016-05-03T10:49:29.971711Z 0 [Note] /usr/local/mysql-5.7.12/bin/mysqld: Shutdown complete

[Thread 0x7fffeeeec700 (LWP 4087) exited]

Program exited normally.
(gdb) 

然后即使就是程序退出是的各种动作,哗啦啦一片。

然后再看那个关闭mysql服务的客户端

技术分享

可以发现mysql服务已经彻底关闭了。

 

上面是初次用gdb来运行mysqld的过程,只能算是初涉吧。

mysql初步调试

标签:

原文地址:http://www.cnblogs.com/tuhooo/p/5454432.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!