查看centos伺服器硬碟狀態資訊
windows下有HDTune可以查看磁碟的狀態,防止磁碟掛掉才會自己知道,CentOS下有SMART (Self-Monitoring, Analysis and Reporting Technology System)同樣對磁碟做狀態檢測
http://www.smartmontools.org/
下面以dellR720伺服器舉例,/dev/sda是1T的scsi介面普通硬碟,/dev/sdd是三塊盤做的raid5
# df -h #查看磁碟的名字
# dmesg |grep sdd #查看開機資訊裡面的磁碟info
sd 0:2:0:0: [sdd] Attached SCSI disk
# hdparm -I /dev/sda #查看磁碟硬體資訊、開啟的功能等,資訊特別詳細
下面用smart查看磁碟的狀態:
#yuminstallsmartmontools//安裝SMART#smartctl-H/dev/sdd//磁碟健康情況查看smartctl5.432012-06-30r3573[x86_64-linux-3.10.56-11.el6.centos.alt.x86_64](localbuild)Copyright(C)2002-12byBruceAllen,http://smartmontools.sourceforge.netSMARTHealthStatus:OK
# smartctl -A /dev/sda 或者 smartctl --all /dev/sda #硬碟的smart資訊
#smartctl-a/dev/sddsmartctl5.432012-06-30r3573[x86_64-linux-3.10.56-11.el6.centos.alt.x86_64](localbuild)Copyright(C)2002-12byBruceAllen,http://smartmontools.sourceforge.netVendor:DELLProduct:PERCH310Revision:2.12UserCapacity:598,879,502,336bytes[598GB]Logicalblocksize:512bytesLogicalUnitid:Serialnumber:Devicetype:diskLocalTimeis:WedJan1415:37:392015CSTDevicedoesnotsupportSMARTErrorCounterloggingnotsupportedDevicedoesnotsupportSelfTestlogging
這裡提示Device does not support SMART,所以按下面方式查看
查看raid5中第一塊磁碟的狀態
# smartctl -a -d megaraid,0 /dev/sdd
同樣查看第二塊、第三塊磁碟的狀態,根據自己的監控情況,加速nagios、zabbix警示
# smartctl -a -d megaraid,1 /dev/sdd
# smartctl -a -d megaraid,2 /dev/sdd
除此之外的smartctl用法,介紹的很詳細:
#smartctl-hUsage:smartctl[options]device============================================SHOWINFORMATIONOPTIONS=====-h,--help,--usageDisplaythishelpandexit-V,--version,--copyright,--licensePrintlicense,copyright,andversioninformationandexit-i,--infoShowidentityinformationfordevice-gNAME,--get=NAMEGetdevicesetting:all,aam,apm,lookahead,security,wcache-a,--allShowallSMARTinformationfordevice-x,--xallShowallinformationfordevice--scanScanfordevices--scan-openScanfordevicesandtrytoopeneachdevice==================================SMARTCTLRUN-TIMEBEHAVIOROPTIONS=====-qTYPE,--quietmode=TYPE(ATA)Setsmartctlquietmodetooneof:errorsonly,silent,noserial-dTYPE,--device=TYPESpecifydevicetypetooneof:ata,scsi,sat[,auto][,N][+TYPE],usbcypress[,X],usbjmicron[,x][,N],usbsunplus,marvell,areca,N/E,3ware,N,hpt,L/M/N,megaraid,N,cciss,N,auto,test-TTYPE,--tolerance=TYPE(ATA)Tolerance:normal,conservative,permissive,verypermissive-bTYPE,--badsum=TYPE(ATA)Setactiononbadchecksumtooneof:warn,exit,ignore-rTYPE,--report=TYPEReporttransactions(seemanpage)-nMODE,--nocheck=MODE(ATA)Nocheckif:never,sleep,standby,idle(seemanpage)==============================DEVICEFEATUREENABLE/DISABLECOMMANDS=====-sVALUE,--smart=VALUEEnable/disableSMARTondevice(on/off)-oVALUE,--offlineauto=VALUE(ATA)Enable/disableautomaticofflinetestingondevice(on/off)-SVALUE,--saveauto=VALUE(ATA)Enable/disableAttributeautosaveondevice(on/off)-sNAME[,VALUE],--set=NAME[,VALUE]Enable/disable/changedevicesetting:aam,[N|off],apm,[N|off],lookahead,[on|off],security-freeze,standby,[N|off|now],wcache,[on|off]=======================================READANDDISPLAYDATAOPTIONS=====-H,--healthShowdeviceSMARThealthstatus-c,--capabilities(ATA)ShowdeviceSMARTcapabilities-A,--attributesShowdeviceSMARTvendor-specificAttributesandvalues-fFORMAT,--format=FORMAT(ATA)Setoutputformatforattributes:old,brief,hex[,id|val]-lTYPE,--log=TYPEShowdevicelog.TYPE:error,selftest,selective,directory[,g|s],xerror[,N][,error],xselftest[,N][,selftest],background,sasphy[,reset],sataphy[,reset],scttemp[sts,hist],scttempint,N[,p],scterc[,N,M],devstat[,N],ssd,gplog,N[,RANGE],smartlog,N[,RANGE]-vN,OPTION,--vendorattribute=N,OPTION(ATA)SetdisplayOPTIONforvendorAttributeN(seemanpage)-FTYPE,--firmwarebug=TYPE(ATA)Usefirmwarebugworkaround:none,samsung,samsung2,samsung3,swapid-PTYPE,--presets=TYPE(ATA)Drive-specificpresets:use,ignore,show,showall-B[+]FILE,--drivedb=[+]FILE(ATA)Readandreplace[add]drivedatabasefromFILE[defaultis+/etc/smart_drivedb.handthen/usr/share/smartmontools/drivedb.h]============================================DEVICESELF-TESTOPTIONS=====-tTEST,--test=TESTRuntest.TEST:offline,short,long,conveyance,force,vendor,N,select,M-N,pending,N,afterselect,[on|off]-C,--captiveDotestincaptivemode(alongwith-t)-X,--abortAbortanynon-captivetestondevice===================================================SMARTCTLEXAMPLES=====smartctl--all/dev/hda(PrintsallSMARTinformation)smartctl--smart=on--offlineauto=on--saveauto=on/dev/hda(EnablesSMARTonfirstdisk)smartctl--test=long/dev/hda(Executesextendeddiskself-test)smartctl--attributes--log=selftest--quietmode=errorsonly/dev/hda(PrintsSelf-Test&Attributeerrors)smartctl--all--device=3ware,2/dev/sdasmartctl--all--device=3ware,2/dev/twe0smartctl--all--device=3ware,2/dev/twa0smartctl--all--device=3ware,2/dev/twl0(PrintsallSMARTinfofor3rdATAdiskon3wareRAIDcontroller)smartctl--all--device=hpt,1/1/3/dev/sda(PrintsallSMARTinfofortheSATAdiskattachedtothe3rdPMPortofthe1stchannelonthe1stHighPointRAIDcontroller)smartctl--all--device=areca,3/1/dev/sg2(PrintsallSMARTinfofor3rdATAdiskofthe1stenclosureonArecaRAIDcontroller)
本文出自 “金戈鐵馬行飛燕” 部落格,請務必保留此出處http://bbotte.blog.51cto.com/6205307/1603985