• MySQL Hardware--RAID卡常用信息查看


    MegaRAID信息查看

    #查raid卡信息(生产商、电池信息及所支持的raid级别)
    /usr/local/sbin/MegaCli -AdpAllInfo -aALL |grep -E "Product Name|BBU|Memory Size|RAID Level Supported"
    
    #查看虚拟化(vd)和物理盘(pd)的信息,比如查看物理硬盘数,是否有硬盘offline或者degraded
    /usr/local/sbin/MegaCli -AdpAllInfo -aALL |grep -E "Device Present" -A9
    
    ## 查看RAID日志
    /usr/local/sbin/MegaCli -FwTermLog dsply –aAll
    
    #查看硬盘是否online
    /usr/local/sbin/MegaCli -PDList -aALL |grep "Firmware state"
    
    #查看硬盘是否存在物理错误(error不为0,可能会有硬盘故障即将发生)
    /usr/local/sbin/MegaCli -PDList -aALL |grep -i error
    
    #查看电池信息(电池类型、电池状态、充电状态、温度等)
    /usr/local/sbin/MegaCli -AdpBbuCmd -aAll
    
    #raid卡个数
    /usr/local/sbin/MegaCli -adpCount
    
    #显示所有逻辑磁盘组信息(做了几组raid,raid cache的默认和当前策略,做好raid后的虚拟盘容量)
    /usr/local/sbin/MegaCli -LDInfo -LALL -aAll
    
    #显示所有物理盘(物理磁盘个数、大小、是否存在error)
    /usr/local/sbin/MegaCli -PDList -aAll
    
    #显示所有物理盘物理错误
    /usr/local/sbin/MegaCli -PDList -aAll |grep -i error
    
    #查看充电状态
    /usr/local/sbin/MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep 'Charger Status'
    
    ##查看BBU设置
    /usr/local/sbin/MegaClii -AdpBbuCmd -GetBbuProperties -aALL
    
    ## 查看当前BBU状态
    /usr/local/sbin/MegaClii -AdpBbuCmd -GetBbuStatus -aALL
    
    #显示BBU状态信息,比如电池是否,如果issohgood为Yes为正常,No为异常
    /usr/local/sbin/MegaCli -AdpBbuCmd -GetBbuStatus -aALL|grep -i issohgood
    
    #显示Raid卡型号,cache大小、Raid设置,cache策略、Disk相关信息
    /usr/local/sbin/MegaCli -cfgdsply -aALL |egrep "PDs|VDs|Product Name|Memory|BBU:"
    
    #磁带状态的变化,从拔盘,到插盘的过程中。
    Device |Normal|Damage|Rebuild|Normal
    Virtual Drive |Optimal|Degraded|Degraded|Optimal
    Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online
    
    #查看磁盘缓存策略(查看vd的)
    /usr/local/sbin/MegaCli -LDGetProp -Cache -LALL -aALL
    
    #或者(查看pd的)
    
    #/usr/local/sbin/MegaCli -LDGetProp -DskCache -LALL -aALL
    
    #缓存策略解释:
    
    WT (Write through
    WB (Write back)
    NORA (No read ahead)
    RA (Read ahead)
    ADRA (Adaptive read ahead)
    Cached
    Direct
    例子:
    
    #查看物理磁盘重建进度
    /usr/local/sbin/MegaCli -PDRbld -ShowProg -PhysDrv [1:5] -a0
    或者以动态可视化文字界面显示
    /usr/local/sbin/MegaCli -PDRbld -ProgDsply -PhysDrv [1:5] -a0
    
    #磁带状态的变化,从拔盘,到插盘的过程中:
    Device |Normal|Damage|Rebuild|Normal
    Virtual Drive |Optimal|Degraded|Degraded|Optimal
    Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online

    HP RAID信息查看

    ## 查看控制器编号
    hpacucli ctrl all show status |egrep 'Smart Array'
    
    ## 看出slot=0控制卡的信息
    hpacucli ctrl slot=0 show config detail
    
    ## 看出slot=0缓存信息
    hpacucli ctrl slot=0 show config detail | grep -i 'cache'
    

    MegaRAID修改写缓存

    ## 强制在BBU损坏时使用Cache
    /usr/local/sbin/MegaCli -LDSetProp CachedBadBBU -Lall -aALL
    
    ## 强制使用WriteBack写策略
    /usr/local/sbin/MegaCli -LDSetProp WB -Lall -aALL 

    HP RAID修改写缓存

    ## 关闭slot=0上物理磁盘缓存
    hpssacli ctrl slot=0 modify drivewritecache=disable
    
    ## 开启slot=0上逻辑磁盘缓存
    hpssacli ctrl slot=0 logicaldrive 2 modify caching=enable
    
    ## 开启slot=0上逻辑磁盘在BBU损坏时缓存
    hpssacli ctrl slot=0 modify nobatterywritecache=enable

    简易版的RAID检查脚本:

    #!/bin/bash
    
    ##====================================================##
    ## 服务器信息 ##
    server_vendor=`dmidecode -s system-manufacturer|sed '/^#/d'|awk '{print $1}'`
    server_ip=`ip addr sh|grep -v 'global secondary'|grep inet|grep -v 169.254|grep -v inet6|grep -v '127.0.0.1'|grep -v '172.172.170.11'|grep -v '172.16.0.11'|awk '{print $2}'|awk -F'/' '{print $1}'|head -n 1`
    docker_flag=`ps -ef|grep "sleep 99999"|grep -v grep|wc -l`
    os_version=`cat /etc/issue |head   -1`
    
    if [ "${docker_flag}" == "1" ]
    then
    	server_vendor="docker"
    fi
    
    raid_product_name=''
    raid_slot_id=''
    raid_cache_size=''
    raid_level=''
    raid_size=''
    raid_status=''
    raid_bbu_count=''
    raid_bbu_status=''
    raid_cache_policy=''
    raid_logic_drive_count=''
    raid_logic_drive_error=''
    raid_physical_drive_error=''
    raid_physical_drive_type=''
    raid_physical_drive_size=''
    raid_physical_drive_count=''
    raid_predictive_failure_count=''
    log_file='./raid_info.txt'
    
    
    
    ##====================================================##
    ## 安装包信息 ##
    hpacucli_rpm_url="http://xxxx.com/hpacucli-9.40-12.0.x86_64.rpm"
    hpacucli_rpm_name="hpacucli-9.40-12.0.x86_64.rpm"
    lib_utils_rpm_url="http://xxxx.com/Lib_Utils-1.00-09.noarch.rpm"
    lib_utils_rpm_name="Lib_Utils-1.00-09.noarch.rpm"
    megacli_rpm_url="http://xxxx.com/MegaCli-8.02.21-1.noarch.rpm"
    megacli_rpm_name="MegaCli-8.02.21-1.noarch.rpm"
    
    ##====================================================##
    ## 高亮输出信息 ##
    function echo_info()
    {
    	message=$1
    	echo -e "33[;37;32m ${message} 33[0m"
    }
    
    function echo_error()
    {
    	message=$1
    	echo -e "33[;37;31m ${message} 33[0m"
    }
    ##====================================================##
    ## 获取服务器ILO信息 ##
    imm_idrac_mac="" 
    imm_idrac_ip=""
    function get_imm_info()
    {
    	if [[ "${server_vendor}" == "docker" ]]
    	then
    		echo_info "server is docker"
    	elif [[ "${server_vendor}" == "HP" ]]
    	then
    		imm_idrac_mac=`timeout 3s ipmitool -I open lan print 2|grep "MAC Address" |awk '{print $4}'` 
    		imm_idrac_ip=`timeout 3s ipmitool -I open lan print 2 |grep -w "IP Address " |awk -F : '{print $2}'|sed 's/^ *//'`
    	elif [[ "${server_vendor}" == "LENOVO" ]]
    	then
    		imm_idrac_mac=`timeout 3s ipmitool -I open lan print 1|grep "MAC Address" |awk '{print $4}'` 
    		imm_idrac_ip=`timeout 3s ipmitool -I open lan print 1 |grep -w "IP Address " |awk -F : '{print $2}'|sed 's/^ *//'`
    	elif [[ "${server_vendor}" == "INSPUR" ]]
    	then
    		imm_idrac_mac=`timeout 3s ipmitool -I open lan print 8|grep "MAC Address" |awk '{print $4}'` 
    		imm_idrac_ip=`timeout 3s ipmitool -I open lan print 8 |grep -w "IP Address " |awk -F : '{print $2}'|sed 's/^ *//'`
    	else
    		imm_idrac_mac=`timeout 3s ipmitool -I open lan print 1|grep "MAC Address" |awk '{print $4}'`
    		imm_idrac_ip=`timeout 3s ipmitool -I open lan print 1 |grep -w "IP Address " |awk -F : '{print $2}'|sed 's/^ *//' `
    	fi
    }
    get_imm_info
    echo_info "ILO_MAC:${imm_idrac_mac}"
    echo_info "ILO_IP:${imm_idrac_ip}"
    
    ##====================================================##
    ## 安装HP服务器使用的hpssacli ##
    
    function install_hpssacli()
    {
    	rpm_count=`rpm -qa |grep -i 'hpacucli' |wc -l`
    	if [ ${rpm_count} -gt 0 ]
    	then
        	echo_info 'hpacucli has been installed' 
    	else
    		echo_info 'start to install hpacucli'
    		/bin/rm -f "/tmp/${hpacucli_rpm_name}"
    		wget -O "/tmp/${hpacucli_rpm_name}" "${hpacucli_rpm_url}"
    	    rpm -ivh "/tmp/${hpacucli_rpm_name}" >/dev/null
    	    echo_info 'end to install hpacucli'
    	fi
    }
    ##====================================================##
    ## 安装服务器使用的MegaCli ##
    function install_MegaCli()
    {
    	rpm_count=`rpm -qa |grep 'Lib_Utils-' |wc -l`
    	if [ ${rpm_count} -gt 0 ]
    	then
    	    echo_info 'Lib_Utils has been installed' 
    	else
    		echo_info 'start to install Lib_Utils'
    		/bin/rm -f "/tmp/${lib_utils_rpm_name}"
    		wget -O "/tmp/${lib_utils_rpm_name}" "${lib_utils_rpm_url}"
    	    rpm -ivh "/tmp/${lib_utils_rpm_name}"
    	    echo_info 'end to install Lib_Utils'
    	fi
    
    	rpm_count=`rpm -qa |grep 'MegaCli-' |wc -l`
    	if [ ${rpm_count} -gt 0 ]
    	then
    	    echo_info 'MegaCli has been installed'
    	else
    		echo_info 'start to install Lib_Utils'
    		/bin/rm -f "/tmp/${megacli_rpm_name}"
    		wget -O "/tmp/${megacli_rpm_name}" "${megacli_rpm_url}"
    	    rpm -ivh "/tmp/${megacli_rpm_name}"
    	    echo_info 'end to install Lib_Utils'
    	fi
    }
    ##====================================================##
    ## 安装服务器RAID使用的包 ##
    function install_raid_rpm()
    {
    	if [[ "${server_vendor}" == "docker" ]]
    	then
    		echo_info "server is docker"
    	elif [[ "${server_vendor}" == "HP" ]]
    	then
    		install_hpssacli
    	else
    		install_MegaCli
    	fi
    
    }
    ##====================================================##
    ## 安装服务器RAID使用的包 ##
    
    function get_hp_raid_info()
    {
    	raid_product_name='HP'
    	raid_slot_id=`hpacucli ctrl all show status | grep 'Smart Array'|tail -n 1|awk '{ print $6 }'`
    	raid_cache_size=`hpacucli ctrl all show config detail |grep 'Total Cache Size'|awk -F ':' '{print $2}'`
    	raid_level=`hpacucli ctrl slot=${raid_slot_id} ld all show|grep -i 'raid' |awk -F ',' '{print $2}'`
    	raid_size=`hpacucli ctrl slot=${raid_slot_id} ld all show|grep -i 'raid' |awk -F '(' '{print $2}'|awk -F ',' '{print $1}'`
    	raid_status=`hpacucli ctrl all show config detail|grep 'Controller Status'|awk -F ':' '{print $2}'`
    	raid_bbu_count=`hpacucli ctrl all show config detail|grep 'Capacitor Count'|awk -F ':' '{print $2}'`
    	raid_bbu_status=`hpacucli ctrl all show config detail|grep 'Capacitor Status'|awk -F ':' '{print $2}'`
    	raid_cache_radio=`hpacucli ctrl all show config detail|grep 'Cache Ratio'| sed 's/:/ is/g'`
    	raid_cache_write_policy=`hpacucli ctrl all show config detail|grep 'No-Battery Write Cache' | sed 's/:/ is/g'`
    	raid_cache_policy="${raid_cache_radio},${raid_cache_write_policy}"
    	raid_logic_drive_count=`hpacucli ctrl all show status | grep 'Smart Array'|wc -l`
    	raid_logic_drive_error=`hpacucli ctrl slot=${raid_slot_id} ld all show| grep 'logicaldrive' |grep -v 'OK' |wc -l`
    	raid_physical_drive_error=`hpacucli ctrl slot=${raid_slot_id} physicaldrive all show| grep 'physicaldrive' |grep -v 'OK' |wc -l`
    	raid_physical_drive_type=`hpacucli ctrl slot=${raid_slot_id} physicaldrive all show| grep 'physicaldrive' |tail -n 1|awk -F ',' '{print $2}'`
    	raid_physical_drive_size=`hpacucli ctrl slot=${raid_slot_id} physicaldrive all show| grep 'physicaldrive' |tail -n 1|awk -F ',' '{print $3}'`
    	raid_physical_drive_count=`hpacucli ctrl slot=${raid_slot_id} physicaldrive all show| grep 'physicaldrive' |wc -l`
    	raid_predictive_failure_count=0
    	raid_error_count=0
    	if [[ "${raid_physical_drive_error}" != '0' ]]
    	then
    		raid_error_count=${raid_physical_drive_error}
    	fi
    	raid_warning_count=0
    
    }
    
    function get_normal_raid_info()
    {
    	raid_product_name=`/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL |egrep "Product Name" |awk -F ':' '{print $2}'`
    	raid_cache_size=`/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL |egrep "Memory" | awk -F ':' '{print $2}'`
    	raid_level=`/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL |grep 'RAID Level' |awk -F ':' '{print $2}'`
    	raid_size=`/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL |egrep '^Size'|tail -n 1 |awk -F ':' '{print $2}'`
    	raid_status=''
    	raid_bbu_count=`/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL |egrep '^BBU'|wc -l`
    	raid_bbu_status=`/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL |egrep '^BBU'|awk -F ':' '{print $2}'`
    	raid_cache_policy=`/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL |grep 'Current Cache Policy' |tail -n 1 |awk -F ':' '{print $2}'`
    	raid_logic_drive_count=`/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL |grep 'Target Id'|wc -l`
    	raid_logic_drive_error=0
    	raid_physical_drive_error=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep -i 'error' | grep -v '0' |wc -l`
    	raid_physical_drive_type=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep 'Media Type' |tail -n 1 |awk -F ':' '{print $2}' |awk -F '[' '{print $1 }'`
    	raid_physical_drive_size=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep 'Raw Size' |tail -n 1 |awk -F ':' '{print $2}' |awk -F '[' '{print $1 }'`
    	raid_physical_drive_count=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep 'Raw Size' |wc -l`
    	raid_span_depth=`/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL |egrep '^Span Depth'|tail -n 1 |awk -F ':' '{print $2}'|sed s/[[:space:]]//g`
    	match_result=$(echo ${raid_level} |grep "Primary-1")
    	
    	raid_error_count=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep -i 'Firmware state' | grep 'Unconfigured(bad)' |wc -l`
    	raid_warning_count=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep -i 'S.M.A.R.T alert' | grep -v ': No' |wc -l`
    	
    	raid_predictive_failure_count=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep -i 'Predictive Failure Count' | grep -v ': 0' |wc -l`
    	
    	if [[ "${match_result}" != "" ]]
    	then
    		echo_info 'Primary-1'
    		if [[ "${raid_span_depth}" == "1" ]]
    		then 
    			raid_level='RAID 1'
    		else
    			raid_level='RAID 10'
    		fi
    	fi
    	match_result=$(echo ${raid_level} |grep "Primary-5")
    	if [[ "${match_result}" != "" ]]
    	then
    		echo_info 'Primary-5'
    		if [[ "${raid_span_depth}" == "1" ]]
    		then 
    			raid_level='RAID 5'
    		else
    			raid_level='RAID 50'
    		fi
    	fi
    }
    
    function get_raid_info()
    {
    	if [[ "${server_vendor}" == "docker" ]]
    	then
    		echo_info "server is docker"
    	elif [[ "${server_vendor}" == "HP" ]]
    	then
    		get_hp_raid_info
    	else
    		get_normal_raid_info
    	fi
    }
    
    function write_raid_info()
    {
    	echo "server_vendor:${server_vendor}" > "${log_file}"
    	echo "server_ip:${server_ip}" >> "${log_file}"
    	echo "os_version:${os_version}" >> "${log_file}"
    	echo "imm_idrac_mac:${imm_idrac_mac}" >> "${log_file}"
    	echo "imm_idrac_ip:${imm_idrac_ip}" >> "${log_file}"
    	echo "raid_product_name:${raid_product_name}" >> "${log_file}"
    	echo "raid_cache_size:${raid_cache_size}" >> "${log_file}"
    	echo "raid_level:${raid_level}" >> "${log_file}"
    	echo "raid_size:${raid_size}" >> "${log_file}"
    	echo "raid_status:${raid_status}" >> "${log_file}"
    	echo "raid_bbu_count:${raid_bbu_count}" >> "${log_file}"
    	echo "raid_bbu_status:${raid_bbu_status}" >> "${log_file}"
    	echo "raid_cache_policy:${raid_cache_policy}" >> "${log_file}"
    	echo "raid_logic_drive_count:${raid_logic_drive_count}" >> "${log_file}"
    	echo "raid_logic_drive_error:${raid_logic_drive_error}" >> "${log_file}"
    	echo "raid_physical_drive_error:${raid_physical_drive_error}" >> "${log_file}"
    	echo "raid_physical_drive_type:${raid_physical_drive_type}" >> "${log_file}"
    	echo "raid_physical_drive_size:${raid_physical_drive_size}" >> "${log_file}"
    	echo "raid_physical_drive_count:${raid_physical_drive_count}" >> "${log_file}"
    	echo "raid_error_count:${raid_error_count}" >> "${log_file}"
    	echo "raid_warning_count:${raid_warning_count}" >> "${log_file}"
    	echo "raid_predictive_failure_count:${raid_predictive_failure_count}" >> "${log_file}"
    
    }
    
    echo_info "get imm rpm"
    get_imm_info
    echo_info "install rpm"
    install_raid_rpm
    echo_info "get raid info"
    get_raid_info
    echo_info "write raid info to log"
    write_raid_info
    echo_info "#======================Server Info=======================##"
    cat "${log_file}"
    echo_info "#========================================================##"
  • 相关阅读:
    保存时出错jup
    Spyder默认页面布局调整
    根据所处位置提取单元格内容的函数(left、right、mid)和查找字符串位于单元格内容第几位的函数(find)
    excel打印出现多余空白页
    Excel的布尔值运算
    excel VBA一个fuction同时执行多个正则表达式,实现方法
    excel VBA把一个单元格内容按逗号拆分并依次替换到另一个单元格的括号里面(本题例子,把文本中的括号换成{答案}的格式,并按顺序填空)
    excel自动记录项目完成进度,是否逾期,逾期/提前完成天数,计算天数可以把now()改为today()
    jquery循环动画
    jquery动画(控制动画隐藏、显示时间轴)
  • 原文地址:https://www.cnblogs.com/gaogao67/p/10989121.html
Copyright © 2020-2023  润新知