|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
修复过程包含最多4个阶段,在下面描述。在你开始前,你应该cd到数据库目录和检查表文件的权限,确保他们可被运行mysqld的Unix用户读取(和你,因为你需要存取你正在检查的文件)。如果它拒绝你修改文件,他们也必须是可被你写入的。客户端
/*****************************************************************************************************************
上面的SP是前往一切的客户真个IP和HOSTNAME,目标是能够经由过程JOB前往某一工夫点的CLIENT的毗连情形.
我事先写这个剧本的目标是常常有一些没有受权的客户机,经由过程SQLSERVER的CLIENT就毗连到SQLSERVER,以是我能够界说一个JOB每隔30分钟运转一次这个存储历程,而且将内容写的一个LOG文件,如许能够也许纪录有哪些CLIENT在毗连SQLSERVER,固然人人能够能够修正这个剧本,使之前往更多的信息,好比CPU,MEMORY,LOCK....
Author:黄山光亮顶
mail:leimin@jxfw.com
version:1.0.0
date:2004-1-30
(如需转载,请说明出处!)
*********************************************************************************************************/
Createprocusp_getClient_infor
as
setnocounton
Declare@rcint
Declare@RowCountint
Select@rc=0
Select@RowCount=0
begin
--//createtemptable,savesp_whoinformation
createtable#tspid(
spidintnull,
ecidintnull,
statusnchar(60)null,
loginnamenchar(256)null,
hostnamenchar(256)null,
blkbitnull,
dbnamenchar(256)null,
cmdnchar(32)
)
--//createtemptablesaveallSQLclientIPandhostnameandlogintime
Createtable#userip(
[id]intidentity(1,1),
txtvarchar(1000),
)
--//Createresulttabletoreturnrecordset
Createtable#result(
[id]intidentity(1,1),
ClientIPvarchar(1000),
hostnamenchar(256),
login_timedatetimedefault(getdate())
)
--//gethostnamebyexecsp_who,insert#tspidfromsp_who,
insertinto#tspid(spid,ecid,status,loginname,hostname,blk,dbname,cmd)execsp_who
declare@cmdStrvarchar(100),
@hostNamenchar(256),
@useripvarchar(20),
@sendstrvarchar(100)
--//declareacursorfromtable#tspid
declaretspidcursor
forselectdistincthostnamefrom#tspidwith(nolock)wherespid>50
forreadonly
opentspid
fetchnextfromtspidinto@hostname
While@@FETCH_STATUS=0
begin
select@cmdStr=ping+rtrim(@hostName)
insertinto#userip(txt)execmaster..xp_cmdshell@cmdStr
select@rowcount=count(id)from#userIP
if@RowCount=2--//noIPfeedbackpackage
begin
insertinto#Result(ClientIP,hostname)values(CannotgetfeedbackpackagefromPing!,@hostname)
end
if@RowCount>2
begin
select@userip=substring(txt,charindex([,txt)+1,charindex(],txt)-charindex([,txt)-1)
from#userIP
wheretxtlikePinging%
insertinto#Result(ClientIP,hostname)values(@userIP,@hostname)
end
select@rc=@@error
if@rc=0
truncatetable#userip--//clear#userIPtable
fetchnextfromtspidinto@hostname
end
closetspid
deallocatetspid
select*from#resultwith(nolock)
droptable#tspid
droptable#userip
droptable#result
end
go
execusp_getClient_infor
这章描述如何检查和处理在MySQL数据库中的数据损坏。如果你的表损坏很多,你应该尝试找出其原因!见G.1调试一个MySQL服务器。 |
|