标签 RAID 下的文章

Proxmox+VE用于公有云、VPS的可靠性得到了很多同行长期的验证认可,整个生态环境也满足我的需求,所需功能也基本都能满足,所以我开始用PVE了。我考虑用本地存储,如果是用智简魔方的公有云平台,一般情况只有硬卡RAID10是最好方案;但PVE出现了多个方案,我挑了几个,但很犹豫哪个最合适我:ZFS-RAID-Z2、ZFS-RAID-Z3、ZFS-RAID10,以及硬卡RAID10。

- 阅读剩余部分 -

基于mysubmail接口发送短信、电话语音通知。创建脚本后可以通过crontab -e每小时或半小时运行一次,例如:
/30 * python /etc/weed/checkRAID.py
可以在raid出现异常状态时快速获知及时处理,避免故障扩大。

# -*- coding: utf-8 -*-
#!/usr/bin/python
import os
import requests

node = '香港vps-nvmenode-1'
error = 0

def get_status(value):
    try:
        status = value.split(": ")
        return status[1].strip()
    except:
        return False
    

def send_warning():
    global node

    # 语音通知
    voice_url = 'http://api.mysubmail.com/voice/send.json'
    voice_params = { 'appid': '*****',
                      'to': '13200000000',
                      'content': '紧急事态:'+node+'硬盘状态异常,请立即检查',
                      'signature': '**************'
                   }
    #voice_res = requests.post(voice_url, data=voice_params)
    # print voice_res.text

    # 短信通知
    message_url = 'http://api.mysubmail.com/message/send.json'
    message_params = { 'appid': '*****',
                       'to': '13200000000',
                       'content': '【XXX】紧急事态:'+node+'硬盘状态异常,请立即检查',
                       'signature': '**************'
                     }
    message_res = requests.post(message_url, data=message_params)
    # print(message_res.text)


# 检查RAID状态,注意/dev/md10是变动参数,自行fdisk -l查看你的软列阵磁盘名称,如raid1则为/dev/md1
raidinfos = os.popen('mdadm -D /dev/md10').readlines()
for raidinfo in raidinfos:
    raidinfo = raidinfo.strip('\n')
    print(raidinfo)

    if "State : " in raidinfo:
        status = get_status(raidinfo)
        if status != 'active' and status != 'active, checking':
            error = 1

    if "Failed Devices : " in raidinfo:
        status = get_status(raidinfo)
        if status != '0':
            error = 1

    if "Active Devices : " in raidinfo:
        status = get_status(raidinfo)
        if status != '2':
            error = 1

# 发送通知
if error == 1:
    send_warning()

如果RAID0用作CEPH OSD,则建议禁用磁盘级的缓存,也就是磁盘标签上写的那个256MB缓存:

# /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -DisDskCache -Immediate -Lall -aAll
                                     
Set Disk Cache Policy to Disabled on Adapter 0, VD 0 (target id: 0) success
Set Disk Cache Policy to Disabled on Adapter 0, VD 1 (target id: 1) success
Set Disk Cache Policy to Disabled on Adapter 0, VD 2 (target id: 2) success
Set Disk Cache Policy to Disabled on Adapter 0, VD 4 (target id: 4) success
Set Disk Cache Policy to Disabled on Adapter 0, VD 5 (target id: 5) success
Set Disk Cache Policy to Disabled on Adapter 0, VD 7 (target id: 7) success
Set Disk Cache Policy to Disabled on Adapter 0, VD 8 (target id: 8) success

- 阅读剩余部分 -