mysql 工具 08s01_Mysql管理必備工具Maatkit詳解之十四(mk-kill)

mk-kill - 顧名思義,殺mysql線程。安裝方法查看這里。

在一個OLTP的生產環境,一般不會讓sql執行過長的時間,特別是myisam這樣表鎖的引擎,如果出現長時間執行的sql一般是誤操作,要不就是出現問題了。

出現這種情況,一般是登錄mysql手工執行kill操作,Maatkit現在提供了一個命令來執行這個操作。例如:

殺掉超過60秒的sql:

mk-kill –busy-time 60 –kill

如果你想先不殺,先看看有哪些sql運行超過60秒:

mk-kill –busy-time 60 –print

如果你想殺掉,同時輸出殺掉了哪些進程:

mk-kill –busy-time 60 –print –kill

下面舉例說明:

先模擬一個長時間的sql

mysq> select count(*) from test where gid>2;

把長時間的sql打印:

[root@mysql2 ~]# mk-kill --busy-time 5 --print -u -p -h

# 2009-12-29T10:26:34 KILL 499967 (Query 33 sec) select count(*) from test where gid>2

將這個sql殺掉并打印:

[root@mysql2 ~]# mk-kill --busy-time 5 --print -u -p -h --kill

# 2009-12-29T10:27:09 KILL 499967 (Query 68 sec) select count(*) from test where gid>2

在查看原來模擬的sql:

mysql> select count(*) from test where gid>2;

ERROR 1053 (08S01): Server shutdown in progress

利用mk-kill可以根據自己的需求殺掉影響系統運行的sql,怎么用就需要看自己的實際情況了。下面給出它的幫助:

mk-kill --help

mk-kill kills, prints or executes another script for queries in MySQL that match

certain criteria. If FILE is not given, mk-kill executes SHOW PROCESSLIST on

MySQL to get queries. Else, mk-kill will get queries from FILE which should

contain the output of SHOW PROCESSLIST. If FILE is -, mk-kill reads from STDIN.

For more details, please use the --help option, or try 'perldoc

/usr/bin/mk-kill' for complete documentation.

Usage: /usr/bin/mk-kill [OPTION]... [FILE...]

Options:

--ask-pass Prompt for a password when connecting to MySQL

--charset -A Default character set

--config Read this comma-separated list of config files; if

specified, this must be the first option on the command

line

--daemonize Fork to the background and detach from the shell

--defaults-file -F Only read mysql options from the given file

--heartbeat Print information to STDOUT about what is being done

--help Show help and exit

--host -h Connect to host

--interval How often to check for queries to kill. Optional suffix

s=seconds, m=minutes, h=hours, d=days; if no suffix, s is

used.

--iterations How many times to iterate through the find-and-kill cycle

(default 1)

--log Print all output to this file when daemonized

--password -p Password to use when connecting

--pid Create the given PID file when daemonized

--port -P Port number to use for connection

--run-time How long to run before exiting. Optional suffix

s=seconds, m=minutes, h=hours, d=days; if no suffix, s is

used.

--set-vars Set these MySQL variables (default wait_timeout=10000)

--socket -S Socket file to use for connection

--user -u User for login if not current user

--version Show version and exit

--wait-after-kill Wait after killing a query, before looking for more to

kill. Optional suffix s=seconds, m=minutes, h=hours,

d=days; if no suffix, s is used.

--wait-before-kill Wait before killing a query. Optional suffix s=seconds,

m=minutes, h=hours, d=days; if no suffix, s is used.

Actions:

--execute-command Execute this command when a query matches

--kill Actually kill matching queries

--print Print a KILL statement for matching queries; does not

actually kill queries

Matches:

--busy-time Kill connections that have been running for longer than

this time. Optional suffix s=seconds, m=minutes, h=hours,

d=days; if no suffix, s is used.

--idle-time Kill connections that have been idle/sleeping for longer

than this time. Optional suffix s=seconds, m=minutes,

h=hours, d=days; if no suffix, s is used.

--ignore-command Ignore queries whose Command matches this Perl regex

(default Binlog.Dump)

--ignore-db Ignore queries whose db (database) matches this Perl regex

--ignore-host Ignore queries whose Host matches this Perl regex

--ignore-info Ignore queries whose Info (query) matches this Perl regex

--[no]ignore-self Don't kill mk-kill's own connection (default yes)

--ignore-state Ignore queries whose State matches this Perl regex

(default Locked)

--ignore-user Ignore queries whose user matches this Perl regex (default

system.user)

--match-command Kill only queries whose Command matches this Perl regex

--match-db Kill only queries whose db (database) matches this Perl

regex

--match-host Kill only queries whose Host matches this Perl regex

--match-info Kill only queries whose Info (query) matches this Perl

regex

--match-state Kill only queries whose State matches this Perl regex

--match-user Kill only queries whose User matches this Perl regex

--[no]only-oldest Only kill the single oldest query (default yes)

Rules:

Specify at least one of --kill, --print or --execute-command.

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/532363.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/532363.shtml
英文地址,請注明出處:http://en.pswp.cn/news/532363.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【經典簡讀】知識蒸餾(Knowledge Distillation) 經典之作

【經典簡讀】知識蒸餾(Knowledge Distillation) 經典之作 轉自:【經典簡讀】知識蒸餾(Knowledge Distillation) 經典之作 作者:潘小小 知識蒸餾是一種模型壓縮方法,是一種基于“教師-學生網絡思想”的訓練方法,由于其簡單&#xf…

深度學習三大謎團:集成、知識蒸餾和自蒸餾

深度學習三大謎團:集成、知識蒸餾和自蒸餾 轉自:https://mp.weixin.qq.com/s/DdgjJ-j6jHHleGtq8DlNSA 原文(英):https://www.microsoft.com/en-us/research/blog/three-mysteries-in-deep-learning-ensemble-knowledge…

在墻上找垂直線_墻上如何快速找水平線

在裝修房子的時候,墻面的面積一般都很大,所以在施工的時候要找準水平線很重要,那么一般施工人員是如何在墻上快速找水平線的呢?今天小編就來告訴大家幾種找水平線的方法。一、如何快速找水平線1、用一根透明的軟管,長度…

百度地圖mysql打點_關于百度地圖連接MYSQL的問題,謝謝啦!

該樓層疑似違規已被系統折疊 隱藏此樓查看此樓大家好,剛使用百度地圖API,請教大家一個問題,謝啦!我需要從我的數據庫中取出字段為"city"的所有數據,然后通過bdGEO()函數在地圖上標注這些城市,我是…

PyTorch中的torch.nn.Parameter() 詳解

PyTorch中的torch.nn.Parameter() 詳解 今天來聊一下PyTorch中的torch.nn.Parameter()這個函數,筆者第一次見的時候也是大概能理解函數的用途,但是具體實現原理細節也是云里霧里,在參考了幾篇博文,做過幾個實驗之后算是清晰了&am…

Vision Transformer(ViT)PyTorch代碼全解析(附圖解)

Vision Transformer(ViT)PyTorch代碼全解析 最近CV領域的Vision Transformer將在NLP領域的Transormer結果借鑒過來,屠殺了各大CV榜單。本文將根據最原始的Vision Transformer論文,及其PyTorch實現,將整個ViT的代碼做一…

hdfs的副本數為啥增加了_HDFS詳解之塊大小和副本數

1.HDFSHDFS : 偽分布式(學習)NNDNSNNsbin/start-dfs.sh(開啟hdfs使用的腳本)bin/hdfs dfs -ls (輸入命令加前綴bin/hdfs dfs)2.block(塊)dfs.blocksize : 134217728(字節) / 128M 官網默認一個塊的大小128M*舉例理解塊1個文件 130M,默認一個塊的大小128M…

Linux下的ELF文件、鏈接、加載與庫(含大量圖文解析及例程)

Linux下的ELF文件、鏈接、加載與庫 鏈接是將將各種代碼和數據片段收集并組合為一個單一文件的過程,這個文件可以被加載到內存并執行。鏈接可以執行與編譯時,也就是在源代碼被翻譯成機器代碼時;也可以執行于加載時,也就是被加載器加…

mysql gender_Mysql第一彈

1、創建數據庫pythoncreate database python charsetutf8;2、設計班級表結構為id、name、isdelete,編寫創建表的語句create table classes(id int unsigned auto_increment primary key not null,name varchar(10),isdelete bit default 0);向班級表中插入數據pytho…

python virtualenv nginx_Ubuntu下搭建Nginx+supervisor+pypy+virtualenv

系統:Ubuntu 14.04 LTS搭建python的運行環境:NginxSupervisorPypyVirtualenv軟件說明:Nginx:通過upstream進行負載均衡Supervisor:管理python進程Pypy:用Python實現的Python解釋器PyPy is a fast, complian…

如何設置mysql表中文亂碼_php mysql表中文亂碼問題如何解決

為避免mysql中出現中文亂碼,建議在創建數據庫時指定編碼格式:復制代碼 代碼示例:create database zzjz CHARACTER SET gbk COLLATE gbk_chinese_ci;create table zz_employees (employeeid int unsigned not null auto_increment primary key,name varch…

java 按鈕 監聽_Button的四種監聽方式

Button按鈕設置點擊的四種監聽方式注:加粗放大的都是改變的代碼1.使用匿名內部類的形式進行設置使用匿名內部類的形式,直接將需要設置的onClickListener接口對象初始化,內部的onClick方法會在按鈕被點擊的時候執行第一個活動的java代碼&#…

java int轉bitmap_Java Base64位編碼與String字符串的相互轉換,Base64與Bitmap的相互轉換實例代碼...

首先是網上大神給的類package com.duanlian.daimengmusic.utils;public final class Base64Util {private static final int BASELENGTH 128;private static final int LOOKUPLENGTH 64;private static final int TWENTYFOURBITGROUP 24;private static final int EIGHTBIT …

linux查看java虛擬機內存_深入理解java虛擬機(linux與jvm內存關系)

本文轉載自美團技術團隊發表的同名文章https://tech.meituan.com/linux-jvm-memory.html一, linux與進程內存模型要理解jvm最重要的一點是要知道jvm只是linux的一個進程,把jvm的視野放大,就能很好的理解JVM細分的一些概念下圖給出了硬件系統進程三個層面內存之間的關系.從硬件上…

java 循環stringbuffer_java常用類-----StringBuilder和StringBuffer的用法

一、可變字符常用方法package cn.zxg.PackgeUse;/*** 測試StringBuilder,StringBuffer可變字符序列常用方法*/public class TestStringBuilder2 {public static void main(String[] args) {StringBuilder sbnew StringBuilder();for(int i0;i<26;i){char temp(char)(ai);sb.…

java function void_Java8中你可能不知道的一些地方之函數式接口實戰

什么時候可以使用 Lambda&#xff1f;通常 Lambda 表達式是用在函數式接口上使用的。從 Java8 開始引入了函數式接口&#xff0c;其說明比較簡單&#xff1a;函數式接口(Functional Interface)就是一個有且僅有一個抽象方法&#xff0c;但是可以有多個非抽象方法的接口。 java8…

java jvm內存地址_JVM--Java內存區域

Java虛擬機在執行Java程序的過程中會把它所管理的內存劃分為若干個不同的數據區域&#xff0c;如圖&#xff1a;1.程序計數器可以看作是當前線程所執行的字節碼的行號指示器&#xff0c;通俗的講就是用來指示執行哪條指令的。為了線程切換后能恢復到正確的執行位置Java多線程是…

java情人節_情人節寫給女朋友Java Swing代碼程序

馬上又要到情人節了&#xff0c;再不解風情的人也得向女友表示表示。作為一個程序員&#xff0c;示愛的時候自然也要用我們自己的方式。這里給大家上傳一段我在今年情人節的時候寫給女朋友的一段簡單的Java Swing代碼&#xff0c;主要定義了一個對話框&#xff0c;讓女友選擇是…

java web filter鏈_filter過濾鏈:Filter鏈是如何構建的?

在一個Web應用程序中可以注冊多個Filter程序&#xff0c;每個Filter程序都可以針對某一個URL進行攔截。如果多個Filter程序都對同一個URL進行攔截&#xff0c;那么這些Filter就會組成一個Filter鏈(也叫過濾器鏈)。Filter鏈用FilterChain對象來表示&#xff0c;FilterChain對象中…

java web 應用技術與案例教程_《Java Web應用開發技術與案例教程》怎么樣_目錄_pdf在線閱讀 - 課課家教育...

出版說明前言第1章 java Web應用開發技術概述1.1 Java Web應用開發技術簡介1.1.1 Java Web應用1.1.2 Java Web應用開發技術1.2 Java Web開發環境及開發工具1.2.1 JDK的下載與安裝1.2.2 Tomcat服務器的安裝和配置1.2.3 MyEclipse集成開發工具的安裝與操作1.3 Java Web應用程序的…