MySQL監(jiān)控利器-Innotop

Innotop是一款十分強大的MySQL監(jiān)控工具,用perl所寫,通過文本模式展示MysQL服務(wù)器和Innodb的運行狀況。

成都創(chuàng)新互聯(lián)服務(wù)項目包括烏拉特中網(wǎng)站建設(shè)、烏拉特中網(wǎng)站制作、烏拉特中網(wǎng)頁制作以及烏拉特中網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,烏拉特中網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到烏拉特中省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

安裝innotop

下載地址:https://github.com/innotop/innotop

Github上提供兩種版本,一種是開發(fā)版(innotop-master),一種是穩(wěn)定版(innotop-gtid)。在這里,我們使用的是開發(fā)版。

注意: 網(wǎng)上提供的下載地址是http://code.google.com/p/innotop/ ,但這個是原先的維護地址,該項目現(xiàn)已遷移到Github上,而且,innotop-1.9.0.tar.gz這個版本也測試了下(google code上面的最新版本是1.9.1),很多功能都無法使用,可能與MySQL的版本有關(guān),建議還是直接從Github上下載。

# unzip innotop-master.zip

# cd innotop-master

# perl Makefile.PL

Checking if your kit is complete...
Looks good
Warning: prerequisite Term::ReadKey 2.1 not found.
Writing Makefile for innotop

報以上錯誤,缺少ReadKey包。

# yum search ReadKey   --注意:基本上缺失的Perl Module都可以通常yum獲取

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
================================================= N/S matched: ReadKey ==================================================
perl-TermReadKey.x86_64 : A perl module for simple terminal control

  Name and summary matches only, use "search all" for everything.

# yum install -y perl-TermReadKey

# perl Makefile.PL

Writing Makefile for innotop

# make install

cp innotop blib/script/innotop
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/innotop
Manifying blib/man1/innotop.1 Installing /usr/local/share/man/man1/innotop.1 Installing /usr/local/bin/innotop
Appending installation info to /usr/lib64/perl5/perllocal.pod

如何使用Innotop

首先我們通過innotop --help查看其常見的啟動參數(shù)

# innotop --help Usage: innotop  

  --[no]color   -C   Use terminal coloring (default)
  --config      -c   Config file to read --count            Number of updates before exiting
  --delay       -d   Delay between updates in seconds
  --help             Show this help message
  --host        -h   Connect to host
  --[no]inc     -i   Measure incremental differences
  --mode        -m Operating mode to start in
  --nonint      -n   Non-interactive, output tab-separated fields
  --password    -p   Password to use for connection
  --port        -P   Port number to use for connection
  --skipcentral -s Skip reading the central configuration file
  --socket -S   MySQL socket to use for connection
  --spark            Length of status sparkline (default 10)
  --timestamp   -t   Print timestamp in -n mode (1: per iter; 2: per line)
  --user        -u   User for login if not current user
  --version          Output version information and exit --write -w   Write running configuration into home directory if no config files were loaded

其中:

-d:多久時間更新一次

-h:連接的主機名

-p:連接的端口

-S:socket的位置

-u:連接的用戶

熟悉MysQL的童鞋不難理解。

登錄進來后,默認是Dashboard。Innotop支持多種模式,Dashboard只是其中一種模式。通過“?”鍵我們可以查看所有模式

MySQL監(jiān)控利器-Innotop

通過上述字母可切換到不同的狀態(tài)下。

如何查看innotop的文檔

1. # man innotop

2. # perldoc innotop

如何監(jiān)控多個MySQL服務(wù)器

有兩種方式:

一、直接在innotop交互式界面中添加,步驟如下:

# innotop

進入到交互式界面后,點擊@鍵,會進入到連接配置界面

MySQL監(jiān)控利器-Innotop

下面開始填寫,主要有以下幾項:

MySQL監(jiān)控利器-Innotop

說明如下:

Choose connections for this mode:選擇連接,如果連接不存在,則手動創(chuàng)建。所以下面會有提示“There is no connection called 'master26',create it?:”。

填寫y,然后回車,會提示填寫DSN string,按格式來即可。

其中在Enter password這一項需要注意,你輸入密碼的時候光標沒有動,但實際上它是有輸入,輸入完畢,直接回車即可。

對于該種方法,簡單,在監(jiān)控機器較少的情況下,比較適用,但該方法的弊端在于一旦退出innotop,所有的配置信息都會丟失,重新進入,需重新配置。

所以,推薦的方法如下。

二、利用配置文件

# innotop --write,進入交互式界面后退出。會在當前目錄下生成一個.innotop/innotop.conf

# ls .innotop/ innotop.conf  plugins

# vim .innotop/innotop.conf

該配置文件中有關(guān)連接的配置信息,默認有一個localhost。

[connections] localhost=user= have_user= have_pass= dsn=DBI:mysql:;host=localhost;mysql_read_default_group=client savepass= dl_table=test.innotop_dl [/connections] 

當然,這個對我們編輯自己的配置信息沒有多大用處,可以刪除掉。

在此,可根據(jù)第一種方式添加一個connection信息,然后根據(jù)該信息進行相應(yīng)的編輯。

以第一種方式中的master26為例,添加后,innotop.conf中的信息如下:

[connections] localhost=user= have_user= have_pass= dsn=DBI:mysql:;host=localhost;mysql_read_default_group=client savepass= dl_table=test.innotop_dl master26=user=root have_user=1 pass=123 have_pass=1 dsn=DBI:mysql:;host=192.168.91.26;port=3306 savepass=1 [/connections] 

根據(jù)實際生產(chǎn)的需求,編輯innotop.conf文件。

[connections] master26=user=root have_user=1 pass=123 have_pass=1 dsn=DBI:mysql:;host=192.168.91.26;port=3306 savepass=1 slave25=user=root have_user=1 pass=123 have_pass=1 dsn=DBI:mysql:;host=192.168.91.25;port=3306 savepass=1 slave22=user=root have_user=1 pass=123 have_pass=1 dsn=DBI:mysql:;host=192.168.91.22;port=3306 savepass=1 [/connections] 

啟動innotop,默認監(jiān)控的是master26的信息。

MySQL監(jiān)控利器-Innotop

可通過“n”或“@”選擇相應(yīng)的服務(wù)器。

好雖好,但不夠直觀,我們希望本例中三個服務(wù)器的信息能顯示在一個屏幕里,這樣就不需要進行來回的切換,更直觀。這里,就需要用到SERVER GROUPS的功能。

SERVER GROUPS

顧名思義,就是講服務(wù)器進行分組,這種信息展示的粒度就不在是服務(wù)器,而是整個組了。

同樣有兩種方式添加:

一、直接在innotop交互式界面中添加

使用“#”鍵,首先創(chuàng)建組的名字,然后添加服務(wù)器,如下所示:

MySQL監(jiān)控利器-Innotop

二、編輯配置文件

[server_groups] master-slave=master26 slave22 slave25 [/server_groups] 

下面,我們來看看集群顯示的效果

MySQL監(jiān)控利器-Innotop

對于監(jiān)控主從集群的狀況,完全夠用。

注意: 在innotop交互式界面中配置完畢后,需退出innotop,再進入,不然就不會顯示CXN列。

總結(jié):

1. 可能有人有疑慮,將密碼保存到配置文件中,是否不安全,尤其是在生產(chǎn)環(huán)境下。其實,密碼也可以不保存在配置文件中,配置如下:

[connections] server144=user=root have_user=1 have_pass=1 dsn=DBI:mysql:;host=192.168.244.144;port=3306 savepass= dl_table= [/connections] 

如果是在innotop交互式界面中添加,則最后一步Save password in plain text in the config file?: 寫“n”即可。

2. 除了上述功能,innotop還是蠻強大的。譬如在M模式,即Replication Status下,可通過“o”鍵給服務(wù)器發(fā)送命令。如下所示:

MySQL監(jiān)控利器-Innotop

Anyway,Innotop功能還是及其強大的,大家慢慢琢磨吧~

參考:

https://www.percona.com/blog/2013/10/14/innotop-real-time-advanced-investigation-tool-mysql/

當前名稱:MySQL監(jiān)控利器-Innotop
標題URL:http://muchs.cn/article42/pdpcec.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、外貿(mào)建站網(wǎng)站改版、移動網(wǎng)站建設(shè)、面包屑導(dǎo)航搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計