您好,登錄后才能下訂單哦!
這篇文章主要介紹如何監控innodb status指標,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
輸入被監控機器的ip 實時獲取innodb相關status指標,包含:
---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --
---QPS---|select insert update delete| read inserted updated deleted| logical physical
#需要編譯腳本 寫入賬號密碼
#可以給自己維護的所有DB創建一個監控專用賬號 密碼統一 這樣寫死在腳本中 直接用即可
]$ cat innodb_status.sh
#!/bin/bash
#參數變量
host=$1
port=$2
username=用戶
passwd=密碼
#echo "sh $0 $host $username $passwd $port"
#fountion 腳本說明、幫助
help_info(){
echo "NAME"
echo " $0"
echo "SYNOPSIS"
echo " $0 is a shell script and monitor innodb status,eg:qps,tps......"
echo "DESCRIPTION"
echo " option like mysql client -h host -u username -p password -P port"
echo "Usage:"
echo " sh $0 ipaddr username password port"
echo " E.g sh $0 10.111.7.31 3306 yujx yujxpw"
echo
}
#function 打印innodb相關指標
server_id(){
mysql -h $host -P$port -u$username -p$passwd -e "show variables like 'server_id'"|grep -iv value
}
innodb_status(){
mysqladmin -h $host -P$port -u$username -p$passwd -r -i 1 ext |\
awk -F"|" \
"BEGIN{ count=0; }"\
'{ if($2 ~ /Variable_name/ && ((++count)%20 == 1)){\
print "----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --";\
print "---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical";\
}\
else if ($2 ~ /Queries/){queries=$3;}\
else if ($2 ~ /Com_select /){com_select=$3;}\
else if ($2 ~ /Com_insert /){com_insert=$3;}\
else if ($2 ~ /Com_update /){com_update=$3;}\
else if ($2 ~ /Com_delete /){com_delete=$3;}\
else if ($2 ~ /Innodb_rows_read/){innodb_rows_read=$3;}\
else if ($2 ~ /Innodb_rows_deleted/){innodb_rows_deleted=$3;}\
else if ($2 ~ /Innodb_rows_inserted/){innodb_rows_inserted=$3;}\
else if ($2 ~ /Innodb_rows_updated/){innodb_rows_updated=$3;}\
else if ($2 ~ /Innodb_buffer_pool_read_requests/){innodb_lor=$3;}\
else if ($2 ~ /Innodb_buffer_pool_reads/){innodb_phr=$3;}\
else if ($2 ~ /Uptime / && count >= 2){\
printf(" %s |%9d",strftime("%H:%M:%S"),queries);\
printf("|%6d %6d %6d %6d",com_select,com_insert,com_update,com_delete);\
printf("|%6d %8d %7d %7d",innodb_rows_read,innodb_rows_inserted,innodb_rows_updated,innodb_rows_deleted);\
printf("|%10d %11d\n",innodb_lor,innodb_phr);\
}}'
}
# 默認端口3306
if [ ! $port ]; then
port=3306
fi
#echo $#,$1
# 執行腳本
if [ $# -le 0 ]||[ "$1"x = "-h"x ]||[ "$1"x = "--help"x ]
then
help_info
else
echo "................"
server_id
echo "..................."
innodb_status
fi
#運行
]$ ./innodb_status.sh ip地址
................
Warning: Using a password on the command line interface can be insecure.
server_id 111111
...................
Warning: Using a password on the command line interface can be insecure.
----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --
---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical
09:37:24 | 10526| 318 66 5021 0| 18124 66 10061 0| 537009 87
09:37:25 | 10596| 298 96 5048 0| 21170 96 10118 0| 535858 79
09:37:26 | 10300| 238 65 4947 0| 21968 65 9914 0| 525109 91
以上是“如何監控innodb status指標”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。