ติดตั้ง Innotop เพื่อตรวจสอบประสิทธิภาพของเซิร์ฟเวอร์ MySQL
Innotop เป็นโปรแกรมบรรทัดคำสั่งที่ยอดเยี่ยม คล้ายกับ "คำสั่งยอดนิยม" เพื่อตรวจสอบเซิร์ฟเวอร์ MySQL ภายในและระยะไกลที่ทำงานภายใต้กลไก InnoDB Innotop มาพร้อมกับคุณสมบัติมากมายและโหมด/ตัวเลือกประเภทต่างๆ ซึ่งช่วยตรวจสอบประสิทธิภาพ MySQL ในด้านต่างๆ และยังช่วยให้ผู้ดูแลระบบฐานข้อมูลค้นหาว่าเกิดอะไรขึ้นกับเซิร์ฟเวอร์ MySQL
ตัวอย่างเช่น Innotop ช่วยในการตรวจสอบ สถานะการจำลอง mysql, สถิติผู้ใช้, รายการคำค้นหา, บัฟเฟอร์ InnoDB , ข้อมูล InnoDB I/O, ตารางที่เปิดอยู่, ล็อคตาราง ฯลฯ โดยจะรีเฟรชข้อมูลเป็นประจำ ดังนั้นคุณจึงสามารถเห็นได้ ผลลัพธ์ที่อัปเดต
Innotop มาพร้อมกับคุณสมบัติที่ยอดเยี่ยมและความยืดหยุ่น และไม่ต้องการการกำหนดค่าเพิ่มเติมใดๆ และสามารถดำเนินการได้โดยการเรียกใช้คำสั่ง 'innotop' จากเทอร์มินัลเท่านั้น
การติดตั้ง Innotop (การตรวจสอบ MySQL)
ตามค่าเริ่มต้น แพ็คเกจ innotop จะไม่รวมอยู่ในการกระจาย Linux เช่น RHEL, CentOS , Fedora และ Scientific Linux คุณต้องติดตั้งโดยเปิดใช้งานพื้นที่เก็บข้อมูล epel ของบุคคลที่สามและใช้คำสั่ง yum ดังที่แสดงด้านล่าง
yum install innotop
ผลลัพธ์ตัวอย่าง
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.net.in
* epel: epel.mirror.net.in
* epel-source: epel.mirror.net.in
* extras: centos.mirror.net.in
* updates: centos.mirror.net.in
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package innotop.noarch 0:1.9.0-3.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================
Package Arch Version Repository Size
==========================================================================================================
Installing:
innotop noarch 1.9.0-3.el6 epel 149 k
Transaction Summary
==========================================================================================================
Install 1 Package(s)
Total download size: 149 k
Installed size: 489 k
Is this ok [y/N]: y
Downloading Packages:
innotop-1.9.0-3.el6.noarch.rpm | 149 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : innotop-1.9.0-3.el6.noarch 1/1
Verifying : innotop-1.9.0-3.el6.noarch 1/1
Installed:
innotop.noarch 0:1.9.0-3.el6
Complete!
หากต้องการเริ่มต้น innotop เพียงพิมพ์ “innotop” และระบุตัวเลือก -u (ชื่อผู้ใช้) และ - p (รหัสผ่าน) ตามลำดับ จากบรรทัดคำสั่งแล้วกด Enter
innotop -u root -p 'tecm1nt'
เมื่อคุณเชื่อมต่อกับเซิร์ฟเวอร์ MySQL แล้ว คุณจะเห็นสิ่งที่คล้ายกับหน้าจอต่อไปนี้
[RO] Dashboard (? for help) localhost, 61d, 254.70 QPS, 5/2/200 con/run/cac thds, 5.1.61-log
Uptime MaxSQL ReplLag Cxns Lock QPS QPS Run Run Tbls Repl SQL
61d 4 0 254.70 _ _ 462 Off 1
Innotop ช่วยเหลือ
กด “?” เพื่อดูสรุปตัวเลือกบรรทัดคำสั่งและการใช้งาน
Switch to a different mode:
A Dashboard I InnoDB I/O Info Q Query List
B InnoDB Buffers K InnoDB Lock Waits R InnoDB Row Ops
C Command Summary L Locks S Variables & Status
D InnoDB Deadlocks M Replication Status T InnoDB Txns
F InnoDB FK Err O Open Tables U User Statistics
Actions:
d Change refresh interval p Pause innotop
k Kill a query's connection q Quit innotop
n Switch to the next connection x Kill a query
Other:
TAB Switch to the next server group / Quickly filter what you see
! Show license and warranty = Toggle aggregation
# Select/create server groups @ Select/create server connections
$ Edit configuration settings \ Clear quick-filters
Press any key to continue
ส่วนนี้ประกอบด้วยภาพหน้าจอของการใช้งาน innotop ใช้ปุ่มตัวพิมพ์ใหญ่เพื่อสลับระหว่างโหมดต่างๆ
สถิติผู้ใช้
โหมดนี้แสดง สถิติผู้ใช้ และ สถิติดัชนี จัดเรียงตามการอ่าน
CXN When Load QPS Slow QCacheHit KCacheHit BpsIn BpsOut
localhost Total 0.00 1.07k 697 0.00% 98.17% 476.83k 242.83k
รายการแบบสอบถาม
โหมดนี้แสดงผลจาก SHOW FULL PROCESSLIST ซึ่งคล้ายกับโหมดรายการค้นหาของ mytop คุณลักษณะนี้ไม่แสดงข้อมูล InnoDB และมีประโยชน์มากที่สุดสำหรับการใช้งานทั่วไป
When Load Cxns QPS Slow Se/In/Up/De% QCacheHit KCacheHit BpsIn BpsOut
Now 0.05 1 0.20 0 0/200/450/100 0.00% 100.00% 882.54 803.24
Total 0.00 151 0.00 0 31/231470/813290/188205 0.00% 99.97% 1.40k 0.22
Cmd ID State User Host DB Time Query
Connect 25 Has read all relay system u 05:26:04
ข้อมูล InnoDB I/O
โหมดนี้แสดง สถิติ I/O ของ InnoDB, I/O ที่รอดำเนินการ, เธรด I/O, ไฟล์ I/O และตาราง บันทึกสถิติ ตามค่าเริ่มต้น
____________________ I/O Threads ____________________
Thread Purpose Thread Status
0 insert buffer thread waiting for i/o request
1 log thread waiting for i/o request
2 read thread waiting for i/o request
3 write thread waiting for i/o request
____________________________ Pending I/O _____________________________
Async Rds Async Wrt IBuf Async Rds Sync I/Os Log Flushes Log I/Os
0 0 0 0 0 0
________________________ File I/O Misc _________________________
OS Reads OS Writes OS fsyncs Reads/Sec Writes/Sec Bytes/Sec
26 3 3 0.00 0.00 0
_____________________ Log Statistics _____________________
Sequence No. Flushed To Last Checkpoint IO Done IO/Sec
0 5543709 0 5543709 0 5543709 8 0.00
บัฟเฟอร์ InnoDB
ในส่วนนี้ คุณจะเห็นข้อมูลเกี่ยวกับ พูลบัฟเฟอร์ InnoDB, สถิติหน้า, บัฟเฟอร์แทรก และ ดัชนีแฮชแบบปรับได้ . ข้อมูลดึงมาจาก แสดงสถานะ INNODB
__________________________ Buffer Pool __________________________
Size Free Bufs Pages Dirty Pages Hit Rate Memory Add'l Pool
512 492 20 0 -- 16.51M 841.38k
____________________ Page Statistics _____________________
Reads Writes Created Reads/Sec Writes/Sec Creates/Sec
20 0 0 0.00 0.00 0.00
______________________ Insert Buffers ______________________
Inserts Merged Recs Merges Size Free List Len Seg. Size
0 0 0 1 0 2
__________________ Adaptive Hash Index ___________________
Size Cells Used Node Heap Bufs Hash/Sec Non-Hash/Sec
33.87k 0 0.00 0.00
ปฏิบัติการแถว InnoDB
ที่นี่ คุณจะเห็นผลลัพธ์ของตาราง การดำเนินการแถว InnoDB, การดำเนินการแถวอื่น ๆ, เซมาฟอร์ และ อาร์เรย์รอ โดยค่าเริ่มต้น.
________________ InnoDB Row Operations _________________
Ins Upd Read Del Ins/Sec Upd/Sec Read/Sec Del/Sec
0 0 0 0 0.00 0.00 0.00 0.00
________________________ Row Operation Misc _________________________
Queries Queued Queries Inside Rd Views Main Thread State
0 0 1 waiting for server activity
_____________________________ InnoDB Semaphores _____________________________
Waits Spins Rounds RW Waits RW Spins Sh Waits Sh Spins Signals ResCnt
2 0 41 1 1 2 4 5 5
____________________________ InnoDB Wait Array _____________________________
Thread Time File Line Type Readers Lck Var Waiters Waiting? Ending?
สรุปคำสั่ง
โหมดสรุปคำสั่งจะแสดงตาราง cmd_summary ทั้งหมด ซึ่งมีลักษณะคล้ายกับตารางด้านล่าง
_____________________ Command Summary _____________________
Name Value Pct Last Incr Pct
Com_update 11980303 65.95% 2 33.33%
Com_insert 3409849 18.77% 1 16.67%
Com_delete 2772489 15.26% 0 0.00%
Com_select 507 0.00% 0 0.00%
Com_admin_commands 411 0.00% 1 16.67%
Com_show_table_status 392 0.00% 0 0.00%
Com_show_status 339 0.00% 2 33.33%
Com_show_engine_status 164 0.00% 0 0.00%
Com_set_option 162 0.00% 0 0.00%
Com_show_tables 92 0.00% 0 0.00%
Com_show_variables 84 0.00% 0 0.00%
Com_show_slave_status 72 0.00% 0 0.00%
Com_show_master_status 47 0.00% 0 0.00%
Com_show_processlist 43 0.00% 0 0.00%
Com_change_db 27 0.00% 0 0.00%
Com_show_databases 26 0.00% 0 0.00%
Com_show_charsets 24 0.00% 0 0.00%
Com_show_collations 24 0.00% 0 0.00%
Com_alter_table 12 0.00% 0 0.00%
Com_show_fields 12 0.00% 0 0.00%
Com_show_grants 10 0.00% 0 0.00%
ตัวแปรและสถานะ
ส่วนนี้จะคำนวณสถิติ เช่น ข้อความค้นหาต่อวินาที และแสดงออกมาในโหมดต่างๆ มากมาย
QPS Commit_PS Rlbck_Cmt Write_Commit R_W_Ratio Opens_PS Tbl_Cch_Usd Threads_PS Thrd_Cch_Usd CXN_Used_Ever CXN_Used_Now
0 0 0 18163174 0 0 0 0 0 1.99 1.32
0 0 0 18163180 0 0 0 0 0 1.99 1.32
0 0 0 18163188 0 0 0 0 0 1.99 1.32
0 0 0 18163192 0 0 0 0 0 1.99 1.32
0 0 0 18163217 0 0 0 0 0 1.99 1.32
0 0 0 18163265 0 0 0 0 0 1.99 1.32
0 0 0 18163300 0 0 0 0 0 1.99 1.32
0 0 0 18163309 0 0 0 0 0 1.99 1.32
0 0 0 18163321 0 0 0 0 0 1.99 1.32
0 0 0 18163331 0 0 0 0 0 1.99 1.32
สถานะการจำลองแบบ
ในโหมดนี้ คุณจะเห็นผลลัพธ์ของ สถานะ SQL รอง, สถานะ I/O รอง และ สถานะหลัก สองส่วนแรกจะแสดง สถานะทาส และ สถานะเธรด I/O ทาส และส่วนสุดท้ายแสดง สถานะหลัก
_______________________ Slave SQL Status _______________________
Master On? TimeLag Catchup Temp Relay Pos Last Error
172.16.25.125 Yes 00:00 0.00 0 41295853
____________________________________ Slave I/O Status _____________________________________
Master On? File Relay Size Pos State
172.16.25.125 Yes mysql-bin.000025 39.38M 41295708 Waiting for master to send event
____________ Master Status _____________
File Position Binlog Cache
mysql-bin.000010 10887846 0.00%
แบบไม่โต้ตอบ
คุณสามารถเรียกใช้ “innotop” แบบไม่โต้ตอบได้
innotop --count 5 -d 1 -n
uptime max_query_time time_behind_master connections locked_count qps spark_qps run spark_run open slave_running longest_sql
61d 2 0 0.000363908088893752 64 Yes
61d 2 0 4.96871146980749 _ _ 64 Yes
61d 2 0 3.9633543857494 ^_ __ 64 Yes
61d 2 0 3.96701862656428 ^__ ___ 64 Yes
61d 2 0 3.96574802684297 ^___ ____ 64 Yes
ตรวจสอบฐานข้อมูลระยะไกล
หากต้องการตรวจสอบฐานข้อมูลระยะไกลบนระบบระยะไกล ให้ใช้คำสั่งต่อไปนี้โดยใช้ ชื่อผู้ใช้, รหัสผ่าน และ ชื่อโฮสต์ เฉพาะ
innotop -u username -p password -h hostname
สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการใช้งานและตัวเลือก 'innotop' โปรดดูหน้า man โดยการกด "man innotop" บนเทอร์มินัล
ลิงค์อ้างอิง
หน้าแรกของ Innotop
อ่านเพิ่มเติม :
- Mtop (การตรวจสอบฐานข้อมูล MySQL) ใน RHEL/CentOS/Fedora