OS环境:CentOS 6.3/CentOS 7.1

一.可用如下命令查询服务器raid卡硬件相关信息:

[root@localhost /]# dmesg | grep raid
megaraid_sas 0000:04:00.0: PCI INT A -> GSI 30 (level, low) -> IRQ 30
megaraid_sas 0000:04:00.0: setting latency timer to 64
megaraid_sas 0000:04:00.0: irq 49 for MSI/MSI-X
[root@localhost /]# cat /proc/scsi/scsi
Attached devices:
Host: scsi4 Channel: 02 Id: 00 Lun: 00
  Vendor: LSI      Model: MR9260-8i        Rev: 2.70
  Type:   Direct-Access                    ANSI  SCSI revision: 05
  
#可以看出,此为LSI MR9660-8i raid卡

二.去LSI官网下载Latest MegaRAID StorCLI,Version: 1.14.12 Size: 32.4M:

下载地址:http://www.lsi.com/downloads/Public/RAID%20Controllers/RAID%20Controllers%20Common%20Files/1.14.12_StorCLI.zip

 

三.安装StorCLI:

To install StorCLI, perform the following steps:
1. Unzip the StorCLI package.
2. To install the StorCLI RPM, run the rpm -ivh  command.
3. To upgrade the StorCLI RPM, run the rpm -Uvh  command.

说明:安装完毕之后storcli64所在路径为/opt/MegaRAID/storcli/storcli64,在此路径下可以运行storcli64工具,切换到其它路径下则不能执行,此时为了使用方便,可以考虑将/opt/MegaRAID/storcli追加到系统PATH变量,或者像下面这样做(建议):

ln -s /opt/MegaRAID/storcli/storcli64 /bin/storcli
ln -s /opt/MegaRAID/storcli/storcli64 /sbin/storcli

四.StorCLI基本使用:

#Raid数量及当前状态
[root@localhost Linux]# storcli show ctrlcount
Status Code = 0
Status = Success
Description = None
Controller Count = 1
#查询虚拟磁盘大小,raid结构等
[root@localhost Linux]# storcli /c0 /v0 show
Controller = 0
Status = Success
Description = None
Virtual Drives :
==============
----------------------------------------------------------
DG/VD TYPE   State Access Consist Cache sCC     Size Name 
----------------------------------------------------------
0/0   RAID10 Optl  RW     No      RWTD  -   1.089 TB      
----------------------------------------------------------
Cac=CacheCade|Rec=Recovery|OfLn=OffLine|Pdgd=Partially Degraded|dgrd=Degraded
Optl=Optimal|RO=Read Only|RW=Read Write|HD=Hidden|B=Blocked|Consist=Consistent|
R=Read Ahead Always|NR=No Read Ahead|WB=WriteBack|
AWB=Always WriteBack|WT=WriteThrough|C=Cached IO|D=Direct IO|sCC=Scheduled
Check Consistency
#可以看出此为RAID10,一个虚拟磁盘,大小为1.089 TB
#查看物理硬盘
[root@localhost Linux]# storcli /c0 /eall /sall show
Controller = 0
Status = Success
Description = Show Drive Information Succeeded.
Drive Information :
=================
-------------------------------------------------------------------------
EID:Slt DID State DG       Size Intf Med SED PI SeSz Model            Sp 
-------------------------------------------------------------------------
252:4    12 Onln   0 558.406 GB SAS  HDD N   N  512B ST3600057SS      U  
252:5    13 Onln   0 558.406 GB SAS  HDD N   N  512B ST3600057SS      U  
252:6    14 Onln   0 558.406 GB SAS  HDD N   N  512B ST3600057SS      U  
252:7    15 Onln   0 558.406 GB SAS  HDD N   N  512B ST3600057SS      U  
-------------------------------------------------------------------------
EID-Enclosure Device ID|Slt-Slot No.|DID-Device ID|DG-DriveGroup
DHS-Dedicated Hot Spare|UGood-Unconfigured Good|GHS-Global Hotspare
UBad-Unconfigured Bad|Onln-Online|Offln-Offline|Intf-Interface
Med-Media Type|SED-Self Encryptive Drive|PI-Protection Info
SeSz-Sector Size|Sp-Spun|U-Up|D-Down|T-Transition|F-Foreign
UGUnsp-Unsupported|UGShld-UnConfigured shielded|HSPShld-Hotspare shielded
CFShld-Configured shielded
#可以看到总计有四颗硬盘,每一颗大小448.406GB,是否在线等
#查看StorCLI帮助信息
[root@localhost Linux]# storcli -h
     Storage Command Line Tool  Ver 1.14.12 Nov 25, 2014
     (c)Copyright 2014, LSI Corporation, All Rights Reserved.
storcli -v 
storcli -h| -help| ? 
storcli -h| -help| ? legacy
storcli show 
storcli show all
storcli show ctrlcount
storcli show file=
storcli /cx add vd r[0|1|5|6|00|10|50|60]
        [Size=,,..|all] [name=,..] 
        drives=e:s|e:s-x|e:s-x,y,e:s-x,y,z [PDperArray=x][SED]
        [pdcache=on|off|default][pi][DimmerSwitch(ds)=default|automatic(auto)|
        none|maximum(max)|MaximumWithoutCaching(maxnocache)][WT|WB|AWB][nora|ra]
        [direct|cached] [cachevd] [Strip=<8|16|32|64|128|256|512|1024>]
         [AfterVd=X] [EmulationType=0|1|2] [Spares = [e:]s|[e:]s-x|[e:]s-x,y]
        [force][ExclusiveAccess] [Cbsize=0|1|2 Cbmode=0|1|2|3|4|7] 
storcli /cx add vd each r0 [name=,..] [drives=e:s|e:s-x|e:s-x,y]
        [SED] [pdcache=on|off|default][pi] [DimmerSwitch(ds)=default|
        automatic(auto)|none|maximum(max)|MaximumWithoutCaching(maxnocache)] 
        [WT|WB|AWB] [nora|ra] [direct|cached] [EmulationType=0|1|2]
        [Strip=<8|16|32|64|128|256|512|1024>] [ExclusiveAccess]
        [Cbsize=0|1|2 Cbmode=0|1|2|3|4|7]
storcli /cx add VD cachecade|nytrocache r[aid][0,1,10, 1EC] 
        drives = [e:]s|[e:]s-x|[e:]s-x,y [WT|WB] [assignvds = 0,1,2] 
        [BOOTVOLSIZE=x]
storcli /cx add VD cachecade|nytrocache slice r[aid][0,1]
        size= [name=] drives= [e:]s|[e:]s-x|[e:]s-x,y
        [WT|WB][assignvds = 0,1,2]
        size=[,,..] [name=,..] [WT|WB] [nora|ra]
        [direct|cached] [CachedBadBBU|NoCachedBadBBU]
        [Strip=<8|16|32|64|128|256|512|1024>] [AfterVd=X]
        [Spares = [e:]s|[e:]s-x|[e:]s-x,y] [force]
storcli /cx/ex show 
storcli /cx/ex show all 
storcli /cx/ex show status 
storcli /cx/ex show phyerrorcounters 
storcli /cx/vx del [cachecade] [discardcache] [force]
storcli /cx delete events
storcli /cx show events [[type= ] filter=<[info],[warning],[critical],[fatal]>
file=
storcli /cx show eventloginfo
storcli /cx show health [all]
storcli /cx delete securitykey
storcli /cx set securitykey=xxxxxxxx {passphrase=xxxx} {keyid=xxx}
storcli /cx start Diag Duration= 
storcli /cx set securitykey keyid=xxx
storcli /cx compare securitykey=xxxxxxxxxx
storcli /cx set termlog[=on|off|offthisboot]
storcli /cx show termlog [type=config|contents]
storcli /cx delete termlog
storcli /cx set securitykey=xxxxxxxx oldsecuritykey=xxxxxxxx
        {passphrase=xxxx} {keyid=xxx}
storcli /cx set sesmonitoring[=on|off]
storcli /cx show sesmonitoring 
storcli /cx/dx show 
storcli /cx/dall show cachecade 
storcli /cx/dx show all 
storcli /cx/dall show mirror 
storcli /cx/dall split mirror 
storcli /cx/dall add mirror src= [force] 
storcli /cx show freespace
storcli /cx/fall show [all] [securityKey = xxx]
storcli /cx/fall del|delete [securityKey = xxx]
storcli /cx/fall import [preview] [securityKey = xxx]
storcli /cx/vx set ssdcaching=on|off
storcli /cx/vx set hidden=on|off
storcli /cx/dx set hidden=on|off
storcli /cx/dx set security=on
storcli /cx/vx show expansion
storcli /cx show fshinting
storcli /cx/vx set fshinting=
storcli /cx/vx expand Size= [expandarray]
storcli /cx[/ex]/sx show 
storcli /cx[/ex]/sx show all
storcli /cx[/ex]/sx start rebuild 
storcli /cx[/ex]/sx stop rebuild 
storcli /cx[/ex]/sx pause rebuild 
storcli /cx[/ex]/sx resume rebuild 
storcli /cx[/ex]/sx show rebuild 
storcli /cx[/ex]/sx show health 
storcli /cx[/ex]/sx show smart 
storcli /cx[/ex]/sx start copyback target=e:s 
storcli /cx[/ex]/sx stop copyback 
storcli /cx[/ex]/sx pause copyback 
storcli /cx[/ex]/sx resume copyback 
storcli /cx[/ex]/sx reset phyerrorcounters 
storcli /cx[/ex]/sx show copyback 
storcli /cx[/ex]/sx show phyerrorcounters 
storcli /cx[/ex]/sx start initialization  
storcli /cx[/ex]/sx stop initialization  
storcli /cx[/ex]/sx show initialization  
storcli /cx[/ex]/sx start locate  
storcli /cx[/ex]/sx stop locate  
storcli /cx[/ex]/sx show securitykey keyid 
storcli /cx[/ex]/sx add hotsparedrive [DGs=] [enclaffinity]
        [nonrevertible]
storcli /cx[/ex]/sx delete hotsparedrive
storcli /cx[/ex]/sx spinup
storcli /cx[/ex]/sx spindown
storcli /cx[/ex]/sx set online 
storcli /cx[/ex]/sx set offline 
storcli /cx[/ex]/sx set missing 
storcli /cx[/ex]/sx set jbod 
storcli /cx[/ex]/sx set security=on 
storcli /cx[/ex]/sx set good [force]  
storcli /cx[/ex]/sx insert dg=A array=B row=C 
storcli /cx/vx set emulationType=0|1|2
storcli /cx/vx set cbsize=0|1|2 cbmode=0|1|2|3|4|7 
storcli /cx/vx set wrcache=WT|WB|AWB
storcli /cx/vx set rdcache=RA|NoRA
storcli /cx/vx set iopolicy=Cached|Direct
storcli /cx/vx set accesspolicy=RW|RO|Blocked|RmvBlkd
storcli /cx/vx set pdcache=On|Off|Default
storcli /cx/vx set name=
storcli /cx/vx set HostAccess=ExclusiveAccess|SharedAccess
storcli /cx/vx set ds=Default|Auto|None|Max|MaxNoCache
storcli /cx/vx set autobgi=On|Off
storcli /cx/vx set pi=Off
storcli /cx/vx show
storcli /cx/vx show all
storcli /cx/vx show init
storcli /cx/vx show cc
storcli /cx/vx show erase
storcli /cx/vx show migrate
storcli /cx/vx show bgi
storcli /cx/vx show autobgi
storcli /cx/vx show trim
storcli /cx set consistencycheck|cc=[off|seq|conc] [delay=value]
        starttime=yyyy/mm/dd hh] [excludevd=x-y,z]
storcli /cx show cc|consistencycheck
storcli /cx show ocr 
storcli /cx set ocr=
storcli /cx/vx start init[Full][Force]
storcli /cx/vx start erase [simple|normal|thorough|standard][patternA=]
[patternB=]
storcli /cx/vx start cc[Force]
storcli /cx/vx start migrate type=raidx [option=add|remove 
        drives=[e:]s|[e:]s-x|[e:]s-x,y] [Force] 
storcli /cx/vx stop init
storcli /cx/vx stop erase
storcli /cx/vx stop cc
storcli /cx/vx stop bgi
storcli /cx/vx pause cc
storcli /cx/vx pause bgi
storcli /cx/vx resume cc
storcli /cx/vx resume bgi
storcli /cx show 
storcli /cx show all 
storcli /cx show preservedcache 
storcli /cx/vx delete preservedcache[force] 
storcli /cx[/ex]/sx download src= [satabridge] [mode= 5|7]
storcli /cx/ex download src= [forceActivate] 
storcli /cx[/ex]/sx secureerase [force]  
storcli /cx[/ex]/sx start erase [simple| normal| thorough | standard| threepass]
   [patternA=] [patternB=]
storcli /cx[/ex]/sx stop erase 
storcli /cx[/ex]/sx show erase 
storcli /cx[/ex]/sx show rawdata pageaddr= file= 
storcli /cx[/ex]/sx set bootdrive= 
storcli /cx/vx set bootdrive=
storcli /cx show bootdrive
storcli /cx show bootwithpinnedcache
storcli /cx set bootwithpinnedcache=
storcli /cx show activityforlocate
storcli /cx set activityforlocate=
storcli /cx show copyback
storcli /cx set copyback= type=smartssd|smarthdd|all 
storcli /cx show jbod
storcli /cx set jbod= 
storcli /cx set autorebuild= 
storcli /cx set ldlimit= 
storcli /cx show autorebuild
storcli /cx set autopdcache= [immediate]
storcli /cx show autopdcache
storcli /cx show cachebypass
storcli /cx set cachebypass= 
storcli /cx show usefdeonlyencrypt
storcli /cx set usefdeonlyencrypt=
storcli /cx show prcorrectunconfiguredareas
storcli /cx set prcorrectunconfiguredareas= 
storcli /cx show batterywarning
storcli /cx set batterywarning= 
storcli /cx show abortcconerror
storcli /cx set abortccοnerrοr= 
storcli /cx show ncq
storcli /cx show configautobalance 
storcli /cx set ncq= 
storcli /cx set configautobalance= 
storcli /cx show maintainpdfailhistory
storcli /cx set maintainpdfailhistory= 
storcli /cx show restorehotspare
storcli /cx set restorehotspare= 
storcli /cx set bios [state=] [Mode=] [abs=]
       [DeviceExposure=]
storcli /cx show bios 
storcli /cx show alarm
storcli /cx set alarm= 
storcli /cx show foreignautoimport
storcli /cx set foreignautoimport= 
storcli /cx show directpdmapping
storcli /cx set directpdmapping= 
storcli /cx show rebuildrate
storcli /cx set rebuildrate= 
storcli /cx show loadbalancemode
storcli /cx set loadbalancemode= 
storcli /cx show eghs
storcli /cx set eghs [state=] [eug=] [smarter=] 
storcli /cx show cacheflushint
storcli /cx set cacheflushint= 
storcli /cx show prrate
storcli /cx set prrate= 
storcli /cx show ccrate
storcli /cx set ccrate= 
storcli /cx show bgirate
storcli /cx set bgirate = 
storcli /cx show dpm 
storcli /cx set dpm = 
storcli /cx show sgpioforce 
storcli /cx set sgpioforce = 
storcli /cx set supportssdpatrolread = 
storcli /cx show migraterate
storcli /cx set migraterate= 
storcli /cx show spinupdrivecount
storcli /cx show wbsupport
storcli /cx set spinupdrivecount= 
storcli /cx show spinupdelay
storcli /cx set spinupdelay= 
storcli /cx show coercion
storcli /cx set coercion= 
storcli /cx show limitMaxRateSATA
storcli /cx set limitMaxRateSATA=on|off 
storcli /cx show HDDThermalPollInterval
storcli /cx set HDDThermalPollInterval= 
storcli /cx show SSDThermalPollInterval
storcli /cx set SSDThermalPollInterval= 
storcli /cx show smartpollinterval
storcli /cx set smartpollinterval= 
storcli /cx show eccbucketsize
storcli /cx set eccbucketsize= 
storcli /cx show eccbucketleakrate
storcli /cx set eccbucketleakrate= 
storcli /cx show backplane
storcli /cx set backplane mode= expose= 
storcli /cx show perfmode
storcli /cx set perfmode= [maxflushlines= numiostoorder=]
storcli /cx show perfmodevalues
storcli /cx show pi
storcli /cx set pi [state=] [import=]
storcli /cx show time
storcli /cx set time= 
storcli /cx show ds
storcli /cx set ds=OFF type=1|2|3|4
storcli /cx set ds=ON type=1|2 [properties]
storcli /cx set ds=ON type=3|4 DefaultLdType= [properties]
storcli /cx set ds [properties] 
storcli /cx show safeid
storcli /cx show rehostinfo
storcli /cx show pci
storcli /cx show ASO
storcli /cx set aso key= preview
storcli /cx set aso key=
storcli /cx set aso transfertovault
storcli /cx set aso rehostcomplete
storcli /cx set aso deactivatetrialkey
storcli /cx set factory defaults
storcli /cx download file= [fwtype=] [ResetNow] [nosigchk] 
        [noverchk] [force]
storcli /cx flush|flushcache
storcli /cx [start] flush|flushcache [cachecade | nytrocache | ALL]
storcli /cx stop flush|flushcache cachecade|nytrocache
storcli /cx show flush|flushcache cachecade|nytrocache 
storcli /cx/px show 
storcli /cx/px show all
storcli /cx/px set linkspeed=0|1.5|3|6|12 
storcli /cx/bbu show 
storcli /cx/bbu show all 
storcli /cx/bbu show status 
storcli /cx/bbu show properties 
storcli /cx/bbu show learn 
storcli /cx/bbu show gasgauge Offset=xxxx Numbytes=n 
storcli /cx/bbu start learn 
storcli /cx/bbu show modes 
storcli /cx/bbu set [ learnDelayInterval= | bbuMode=  
        |learnStartTime=[DDD HH | off] | autolearnmode= | 
        powermode=sleep | writeaccess=sealed ] 
storcli /cx/cv set SCAPVPD file= VPDPage=
storcli /cx/cv show 
storcli /cx/cv show all 
storcli /cx/cv show status 
storcli /cx/cv show learn 
storcli /cx/cv show SCAPVPD file= VPDPage=
storcli /cx/cv start learn 
storcli /cx show securitykey keyid 
storcli /cx start patrolread
storcli /cx stop patrolread
storcli /cx pause patrolread
storcli /cx resume patrolread
storcli /cx show patrolRead
storcli /cx show powermonitoringinfo
storcli /cx show ldlimit
storcli /cx set patrolread = {{on mode= }|{off}}
storcli /cx set patrolread [starttime=< yyyy/mm/dd hh>] 
        [maxconcurrentpd =] [includessds=]
        [uncfgareas=on|off]
storcli /cx set patrolread delay = 
storcli /cx[/ex]/sx show diag paniclog [Query] | [ExtractSlot=x] 
                                         | [EraseSlot=x] [file=filepath]
storcli /cx[/ex]/sx show diag smartlog [file=filepath] 
storcli /cx[/ex]/sx show diag errorlog [file=filepath] 
storcli /cx del Nytrocache [force]
storcli /cx show badblocks
storcli /cx flasherase 
storcli /cx shutdown 
storcli /cx/mx set mode= 
storcli /cx/mx show 
storcli /cx transform iMR 
storcli /cx restart 
storcli /cx/vx show BBMT
storcli /cx/vx delete BBMT
storcli /cx[/ex]/sx start format [thorough] 
storcli /cx show dequeuelog file=
storcli /cx show maintenance
storcli /cx set maintenance mode=normal|nodevices 
storcli /cx show personality
storcli /cx set personality=RAID|HBA 
storcli /cx show immediateio
storcli /cx show driveactivityled
storcli /cx set immediateio=
storcli /cx set driveactivityled=
Note:Use 'page=[x]'as the last option in all the commands to set the page break.
      X=lines per page. E.g. 'storcli help page=10'

 

总结:StorCLI功能强大,可以安装在多个平台下,具体安装以及使用方法,可参阅官网文档。