MySQL 展示功能与源码对应 丹臣 / 赵林 2010-10-12
提  纲 Mysql 客户端的一些展示命令与源码 Mysqld 服务端的展示命令与源码 Mysql 复制状态信息的查看命令与源码 Innodb monitor 信息展示与源码
客户端 status 命令
客户端 status 命令 client/Mysql.cc 源文件 …
客户端 status 命令 这部份信息来自于哪里? Sql_parse.cc 源程序中的 dispatch_command 函数
服务端常用的一些命令 show processlist show authors show  contributors show create table / view show create database show privileges 神奇的 information_schema
Show processlist
show processlist 三个步骤: 1. 先定义 id,user,Host,db,Command,Time,State,Info 字段信息到 field_list 变量中 , 并通过 protocol->send_fields 发送到客户端 2.  锁定线程总数,遍历所有线程,将所有线程的信息填入 thread_infos 链表变量中 向客户端传送 thread_infos 链表中的数据 , 通过 protocol->write() 完成写操作 实际中遇到的问题: 如果一个 mysql 线程很多,那么大部份的 sleep 线程将干扰查看 processlist 列表
Show authors
show contributors
show create table / view
show create database
show privileges
information_schema 中的对象
schema_information 中的对象
st_schema_table 结构体定义
show table status Table 的各种信息,都在 tables_fields_info[] 数组里定义义 ,Name,Engine,Version,Row_format,Rows,Avg_row_lenght,Data_length  等等
show table status 再看 ST_SCHEMA_TABLE schema_tables[] 关于 tables 的定义 表的名字: TABLES 表结构的定义: tables_fields_info 表的创建函数: create_schema_table 填冲数据函数: by function get_all_tables and get_schema_tables_record
MySQL 复制的常用命令 show slave status; show master status;
show slave status sql/Slave.cc 源文件 如何把一台 mysql 做成多台 master 的 slave?
show master status sql/Sql_repl.cc 源文件
Show innodb status
show innodb status srv_printf_innodb_monitor INNODB MONITOR OUTPUT srv_print_master_thread_info(file) 注解: BACKGROUND THREAD sync_print(file) 注解: SEMAPHORES lock_print_info_summary()  汇总事务信息 lock_print_info_all_transactions() 每个事务的信息 注解: TRANSACTIONS os_aio_print(file); 注解: FILE I/O ibuf_print(file)  // insert buffer ha_print_info(file…) //hash table 注解: INSERT BUFFER AND ADAPTIVE HASH INDEX log_print(file) 注解: LOG buf_print_io(file) 注解: BUFFER POOL AND MEMORY ROW OPERATIONS( 根据全局变量值计算 ) sync_array_print_info sync_print_wait_info 源文件位置: storage/innodb_plugin/srv/srv0srv.c trx_sys_struct trx_purge_struct log_struct buf_pool_struct ibuf_struct hash_table_struct os_aio_array_struct /** The asynchronous i/o array structure */ /** Synchronization array */ sync_array_struct
Innodb monitor 信息展示与源码 …… . srv/Srv0srv.c 源文件中的 srv_monitor_thread 主函数 INNODB TABLESPACE  and  TABLE MONITOR OUTPUT dict_table_print_low,  dict_update_statistics_low, dict_col_print_low,  dtype_print
收集表与索引统计数据
Follow me 团队 blog:http://www.taobaodba.com 个人 blog:http://zhaolinjnu.blog.sohu.com Twitter:http://twitter.com/zhaolinjnu 新浪微博: http://t.sina.com.cn/zhaolinjnu Email:zhaolinjnu@163.com

Mysql 101014202926-phpapp01

  • 1.
  • 2.
    提 纲Mysql 客户端的一些展示命令与源码 Mysqld 服务端的展示命令与源码 Mysql 复制状态信息的查看命令与源码 Innodb monitor 信息展示与源码
  • 3.
  • 4.
    客户端 status 命令client/Mysql.cc 源文件 …
  • 5.
    客户端 status 命令这部份信息来自于哪里? Sql_parse.cc 源程序中的 dispatch_command 函数
  • 6.
    服务端常用的一些命令 show processlistshow authors show contributors show create table / view show create database show privileges 神奇的 information_schema
  • 7.
  • 8.
    show processlist 三个步骤:1. 先定义 id,user,Host,db,Command,Time,State,Info 字段信息到 field_list 变量中 , 并通过 protocol->send_fields 发送到客户端 2. 锁定线程总数,遍历所有线程,将所有线程的信息填入 thread_infos 链表变量中 向客户端传送 thread_infos 链表中的数据 , 通过 protocol->write() 完成写操作 实际中遇到的问题: 如果一个 mysql 线程很多,那么大部份的 sleep 线程将干扰查看 processlist 列表
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    show table statusTable 的各种信息,都在 tables_fields_info[] 数组里定义义 ,Name,Engine,Version,Row_format,Rows,Avg_row_lenght,Data_length 等等
  • 18.
    show table status再看 ST_SCHEMA_TABLE schema_tables[] 关于 tables 的定义 表的名字: TABLES 表结构的定义: tables_fields_info 表的创建函数: create_schema_table 填冲数据函数: by function get_all_tables and get_schema_tables_record
  • 19.
    MySQL 复制的常用命令 showslave status; show master status;
  • 20.
    show slave statussql/Slave.cc 源文件 如何把一台 mysql 做成多台 master 的 slave?
  • 21.
    show master statussql/Sql_repl.cc 源文件
  • 22.
  • 23.
    show innodb statussrv_printf_innodb_monitor INNODB MONITOR OUTPUT srv_print_master_thread_info(file) 注解: BACKGROUND THREAD sync_print(file) 注解: SEMAPHORES lock_print_info_summary() 汇总事务信息 lock_print_info_all_transactions() 每个事务的信息 注解: TRANSACTIONS os_aio_print(file); 注解: FILE I/O ibuf_print(file) // insert buffer ha_print_info(file…) //hash table 注解: INSERT BUFFER AND ADAPTIVE HASH INDEX log_print(file) 注解: LOG buf_print_io(file) 注解: BUFFER POOL AND MEMORY ROW OPERATIONS( 根据全局变量值计算 ) sync_array_print_info sync_print_wait_info 源文件位置: storage/innodb_plugin/srv/srv0srv.c trx_sys_struct trx_purge_struct log_struct buf_pool_struct ibuf_struct hash_table_struct os_aio_array_struct /** The asynchronous i/o array structure */ /** Synchronization array */ sync_array_struct
  • 24.
    Innodb monitor 信息展示与源码…… . srv/Srv0srv.c 源文件中的 srv_monitor_thread 主函数 INNODB TABLESPACE and TABLE MONITOR OUTPUT dict_table_print_low, dict_update_statistics_low, dict_col_print_low, dtype_print
  • 25.
  • 26.
    Follow me 团队blog:http://www.taobaodba.com 个人 blog:http://zhaolinjnu.blog.sohu.com Twitter:http://twitter.com/zhaolinjnu 新浪微博: http://t.sina.com.cn/zhaolinjnu Email:zhaolinjnu@163.com