《mysql 源码分析.ppt》由会员分享,可在线阅读,更多相关《mysql 源码分析.ppt(26页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、1MySQL展示功能与源码对应丹臣/赵林2010-10-12提 纲Mysql客户端的一些展示命令与源码Mysqld服务端的展示命令与源码Mysql复制状态信息的查看命令与源码Innodb monitor信息展示与源码客户端status命令客户端status命令client/Mysql.cc源文件客户端status命令这部份信息来自于哪里?Sql_parse.cc源程序中的dispatch_command函数服务端常用的一些命令show processlistshow authorsshow contributorsshow create table/viewshow create databa
2、seshow privileges神奇的information_schemaShow processlistshow processlist三个步骤:1.先定义id,user,Host,db,Command,Time,State,Info字段信息到field_list变量中,并通过protocol-send_fields发送到客户端2.锁定线程总数,遍历所有线程,将所有线程的信息填入thread_infos链表变量中3.向客户端传送thread_infos链表中的数据,通过protocol-write()完成写操作实际中遇到的问题:如果一个mysql线程很多,那么大部份的sleep线程将干扰查
3、看processlist列表Show authorsshow contributorsshow create table/viewshow create databaseshow privilegesinformation_schema中的对象schema_information中的对象st_schema_table结构体定义show table statusTable的各种信息,都在tables_fields_info数组里定义义,Name,Engine,Version,Row_format,Rows,Avg_row_lenght,Data_length 等等show table statu
4、s再看ST_SCHEMA_TABLE schema_tables关于tables的定义表的名字:TABLES表结构的定义:tables_fields_info表的创建函数:create_schema_table填冲数据函数:by function get_all_tables and get_schema_tables_recordMySQL复制的常用命令show slave status;show master status;show slave statussql/Slave.cc源文件如何把一台mysql做成多台master的slave?show master statussql/Sql
5、_repl.cc源文件Show innodb statusshow innodb statussrv_printf_innodb_monitorINNODB MONITOR OUTPUTsrv_print_master_thread_info(file)注解:BACKGROUND THREADsync_print(file)注解:SEMAPHORESlock_print_info_summary()汇总事务信息lock_print_info_all_transactions()每个事务的信息注解:TRANSACTIONSos_aio_print(file);注解:FILE I/Oibuf_pr
6、int(file)/insert bufferha_print_info(file)/hash table注解:INSERT BUFFER AND ADAPTIVE HASH INDEXtrx_sys_structtrx_purge_structlog_print(file)注解:LOGlog_structbuf_print_io(file)注解:BUFFER POOL AND MEMORYbuf_pool_structROW OPERATIONS(根据全局变量值计算)ibuf_structhash_table_structos_aio_array_struct/*The asynchrono
7、us i/o array structure*/sync_array_print_infosync_print_wait_info/*Synchronization array*/sync_array_struct源文件位置:storage/innodb_plugin/srv/srv0srv.cInnodb monitor信息展示与源码.srv/Srv0srv.c源文件中的srv_monitor_thread主函数INNODB TABLESPACE and TABLE MONITOR OUTPUTdict_table_print_low,dict_update_statistics_low,dict_col_print_low,dtype_print收集表与索引统计数据Follow me团队blog:http:/个人blog:http:/Twitter:http:/