204_mysql_innodb_5_innodb 后臺線程

      網友投稿 830 2025-04-01

      Innodb引擎是多線程模型,不同后臺線程, 負責處理不同業務


      # 1. 前臺線程(連接層)

      show processlist ; show full processlist; select * from information_schema.processlist ;

      # 2. 后臺線程(Server\Engine)

      mysql> select * from performance_schema.threads\G 說明: 如何查詢到連接線程和SQL線程關系 select * from information_schema.processlist ; ---> ID=10 select * from performance_schema.threads where processlist_id=10\G

      1 master thread核心線程

      負責

      控制刷新臟頁到磁盤(CKPT)

      控制日志緩沖刷新到磁盤(log buffer ---> redo)

      undo頁回收

      合并插入緩沖(change buffer)

      控制IO刷新數量

      說明: innodb_io_capacity表示每秒刷新臟頁的數量,默認為200。 innodb_max_dirty_pages_pct設置出發刷盤的臟頁百分比,即當臟頁占到緩沖區數據達到這個百分比時,就會刷新innodb_io_capacity個臟頁到磁盤。 innodb_adaptive_flushing = ON(自適應地刷新),該值影響每秒刷新臟頁的數量。 原來的刷新規則是:臟頁在緩沖池所占的比例小于 innodb_max_dirty_pages_pct時,不刷新臟頁;大于innodb_max_dirty_pages_pct時,刷新100個臟頁。 隨著innodb_adaptive_flushing參數的引入,InnoDB存儲引擎會通過一個名為buf_flush_get_desired_flush_rate的函數來判斷需要刷新臟頁最合適的數量。 buf_flush_get_desired_flush_rate通過判斷產生重做日志(redolog)的速度來決定最合適的刷新臟頁數量 因此,當臟頁的比例小于innodb_max_dirty_pages_pct時,也會刷新一定量的臟頁。

      2 IO thread

      Innodb 使用 AIO(Async IO)來處理寫IO請求,提高性能, 4個核心IO thread? read/write? insert buffer/log io thread

      show variables like '%innodb_%io_threads';

      show engine innodb status \G;

      I/O thread 0 state: wait Windows aio (insert buffer thread) I/O thread 1 state: wait Windows aio (log thread) I/O thread 2 state: wait Windows aio (read thread) I/O thread 3 state: wait Windows aio (read thread) I/O thread 4 state: wait Windows aio (read thread) I/O thread 5 state: wait Windows aio (read thread) I/O thread 6 state: wait Windows aio (write thread) I/O thread 7 state: wait Windows aio (write thread) I/O thread 8 state: wait Windows aio (write thread) I/O thread 9 state: wait Windows aio (write thread)

      3 Purge Thread

      事物提交后 需要purge? thread 來回收已經使用分配的undo頁

      show variables like '%innodb_purge_threads%';

      4 page cleaner Thread

      204_mysql_innodb_5_Innodb 后臺線程

      將刷臟頁單獨線程完成,較少 master thread 壓力,提高性能

      show variables like '%innodb_page_cleaners%';

      5 其它線程: SQL線程/連接層的線程(前臺)

      其它

      查詢系統中所有業務表的存儲引擎信息

      查詢系統中所有業務表的存儲引擎信息 select table_schema, table_name , engine from information_schema.tables where table_schema not in ('sys','mysql','information_schema','performance_schema'); 巡檢需求: 將業務表中所有非InnoDB查詢出來 mysql> select table_schema,table_name,engine from information_schema.tables where table_schema not in ('mysql','sys','information_schema','performance_schema') and engine !='innodb'; 1. 查詢所有非InnoDB表 mysql> select table_schema,table_name ,engine from information_schema.tables where table_schema not in ('sys','mysql','information_schema','performance_schema') and engine !='innodb'; 2. 備份所有非InnoDB表 select concat("mysqldump -uroot -p123 ",table_schema," ",table_name," >/tmp/",table_schema,"_",table_name,".sql") from information_schema.tables where table_schema not in ('sys','mysql','information_schema','performance_schema') and engine !='innodb'; 3. 修改存儲引擎 mysql> select concat("alter table ",table_schema,".",table_name," engine=innodb;") from information_schema.tables where table_schema not in ('sys','mysql','information_schema','performance_schema') and engine !='innodb' into outfile '/tmp/a.sql'; mysql> source /tmp/a.sql 3. 修改存儲引擎 mysql> select concat("alter table ",table_schema,".",table_name," engine=innodb;") from information_schema.tables where table_schema not in ('sys','mysql','information_schema','performance_schema') and engine !='innodb' into outfile '/tmp/a.sql'; mysql> source /tmp/a.sql

      碎片情況

      alter table world.xxx engine=innodb ALGORITHM=COPY; analyze table world.city; 轉儲表(推薦) create table t1_bak like t1; insert into t1_bak selewct * from t1; drop table t1 ; rename table t1_bak to t1; Mysqldump 導出 導入。 或者工具 pt-os ghost 注意: 1. 最好是空窗期做 2. 準備double的存儲空間 tmpdir 3. 整理碎片只對 InnoDB 獨立表空間方式有效

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:excel表格數據取整的方法(excel表格 取整)
      下一篇:excel表格內容顯示不全的解決方案(excel表格內容顯示不全)
      相關文章
      日韩亚洲Av人人夜夜澡人人爽| 亚洲女同成av人片在线观看| 久久亚洲国产精品一区二区| 久久久久久亚洲精品不卡| 亚洲成在人线aⅴ免费毛片| 亚洲无mate20pro麻豆| 亚洲国产精品综合久久20| 亚洲日本人成中文字幕| 亚洲综合偷自成人网第页色| 亚洲乱码在线观看| 亚洲色丰满少妇高潮18p| 亚洲精品无码中文久久字幕| 亚洲a∨无码精品色午夜| 337P日本欧洲亚洲大胆精品| 亚洲AV无码乱码在线观看性色扶 | 亚洲av色香蕉一区二区三区| 亚洲熟女www一区二区三区| 亚洲色欲色欱wwW在线| 亚洲AV无码一区二区三区久久精品 | 99亚偷拍自图区亚洲| 亚洲色少妇熟女11p| 国产午夜亚洲精品不卡免下载| 亚洲毛片网址在线观看中文字幕| 中文字幕中韩乱码亚洲大片| 国产亚洲精品国看不卡| 亚洲精品成人片在线观看精品字幕| 亚洲国产精品无码久久久不卡| 亚洲AV无码1区2区久久| 亚洲视频免费观看| 亚洲最大成人网色香蕉| 亚洲色欲色欲www在线播放| 亚洲AV无码一区二区三区在线观看| 久久99亚洲综合精品首页| 亚洲av午夜福利精品一区人妖| 337p欧洲亚洲大胆艺术| 亚洲国产成a人v在线观看| 亚洲av无码专区在线观看亚| 亚洲精品无码99在线观看| 亚洲精品乱码久久久久久蜜桃不卡 | 77777亚洲午夜久久多人| 久久噜噜噜久久亚洲va久|