LoginSignup
35
42

More than 5 years have passed since last update.

CentOSにてRAIDストレージの障害発生HDD交換の作業メモ

Last updated at Posted at 2016-01-14

CentOSなどRHEL系では毎週日曜日にcronでraid-checkが実行されます。
負荷が高い処理ですので、cron実施時間を状況に合わせて設定します。
さて、通常ならば月曜日には完了しているはずのraid-checkが終わらないサーバー機があった時の対処メモです。

RAIDの状態確認

# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sda[1] sdb[0]
      3907015680 blocks super external:/md0/0 [2/2] [UU]
      [=================>...]  check = 88.7% (3466662784/3907015812) finish=912469.8min speed=7K/sec

進行状況が88.7%くらいで速度も超遅いので、終わる気配がありません。
もう少し詳しく確認してみます。

# mdadm -D /dev/md126
/dev/md126:
      Container : /dev/md0, member 0
     Raid Level : raid1
     Array Size : 3907015680 (3726.02 GiB 4000.78 GB)
  Used Dev Size : 3907015812 (3726.02 GiB 4000.78 GB)
   Raid Devices : 2
  Total Devices : 2

          State : active, checking
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

   Check Status : 88% complete


           UUID : c1184dd6:fb1ce82e:026126c6:d57a635d
    Number   Major   Minor   RaidDevice State
       1       8        0        0      active sync   /dev/sda
       0       8       16        1      active sync   /dev/sdb

checking状態なのは間違いないです。
とにかくディスクI/Oの負荷が高いので、raid-checkを止めます。

# cat /sys/block/md126/md/sync_action
check
# echo idle > /sys/block/md126/md/sync_action
# cat /sys/block/md126/md/sync_action
idle

これはハードウェアRAIDなので、ソフトウェアRAIDの場合とデバイス指定場所が違います。
再度、確認してみます。

# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sda[1] sdb[0]
      3907015680 blocks super external:/md0/0 [2/2] [UU]

raid-checkが止まりました。
もう少し詳しく確認してみます。

# mdadm -D /dev/md126
/dev/md126:
      Container : /dev/md0, member 0
     Raid Level : raid1
     Array Size : 3907015680 (3726.02 GiB 4000.78 GB)
  Used Dev Size : 3907015812 (3726.02 GiB 4000.78 GB)
   Raid Devices : 2
  Total Devices : 2

          State : active
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0


           UUID : c1184dd6:fb1ce82e:026126c6:d57a635d
    Number   Major   Minor   RaidDevice State
       1       8        0        0      active sync   /dev/sda
       0       8       16        1      active sync   /dev/sdb

checking状態は解消されました。

ログの確認

ハードウェア系はカーネルからログ出力されていますので、確認してみます。

# cat /var/log/messages | grep "I/O error"
kernel: end_request: I/O error, dev sda, sector 6700004992
kernel: end_request: I/O error, dev sda, sector 6700005120

# cat /var/log/messages | grep "media error"
kernel:         res 41/40:00:47:f1:61/00:00:9e:01:00/40 Emask 0x409 (media error) <F>

どうやらHDDに不具合がありそうです。
RAIDコントローラーの場合もありますので、断言できませんが。

HDDの診断

HDDの状態確認ツールのsmartctlを使用します。

インストール
# yum instal smartmontools

デバイス確認

# smartctl --scan
/dev/sda -d scsi # /dev/sda, SCSI device
/dev/sdb -d scsi # /dev/sdb, SCSI device

HDDがSMART対応か確認する。

# smartctl /dev/sda -i
=== START OF INFORMATION SECTION ===
...
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Enableならば利用できます。
ではSMARTの値を確認してみます。

# smartctl /dev/sda -A
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   198   198   051    Pre-fail  Always       -       94849
  3 Spin_Up_Time            0x0027   194   194   021    Pre-fail  Always       -       7291
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       6
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   083   083   000    Old_age   Always       -       13041
 10 Spin_Retry_Count        0x0032   100   253   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   253   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       6
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       5
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -       318
194 Temperature_Celsius     0x0022   121   115   000    Old_age   Always       -       31
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       80
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   100   253   000    Old_age   Offline      -       0

問題の値は、Raw_Read_Error_Rate(読み込みエラー)が異常に大きい事で、
(C5)Current_Pending_Sector(代替処理セクタ数)がありますので不良セクタが推測されます。
もう片方のHDDを確認してみます。

# smartctl /dev/sdb -A
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       7701
  3 Spin_Up_Time            0x0027   196   196   021    Pre-fail  Always       -       7158
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       6
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   083   083   000    Old_age   Always       -       13042
 10 Spin_Retry_Count        0x0032   100   253   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   253   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       6
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       5
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -       318
194 Temperature_Celsius     0x0022   123   115   000    Old_age   Always       -       29
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       212
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   100   253   000    Old_age   Offline      -       0

(C5)197 Current_Pending_Sector(代替処理セクタ数)が高くやはり不良セクタが推測されます。
Raw_Read_Error_Rate(読み込みエラー)はこちらが少ないのですが本来は0の値です。
正常の場合は以下の通り。

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   208   201   021    Pre-fail  Always       -       6583
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       13
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   080   080   000    Old_age   Always       -       15264
 10 Spin_Retry_Count        0x0032   100   253   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   253   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       13
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       11
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -       522
194 Temperature_Celsius     0x0022   120   113   000    Old_age   Always       -       32
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   100   253   000    Old_age   Offline      -       0

この記事を書いている間にHDD(/dev/sda)が逝ってしまったので、状態は以下の様に片側運用になりました。

# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sdb[0]
      3907015680 blocks super external:/md0/0 [2/1] [_U]

ユニット番号とUの文字の変化が表示されています。
なお、HDD交換作業では疑似的に故障状態にして同期を停止させますので、表示は同様になります。

HDD交換作業

交換するHDDデバイスを指定して疑似的に故障状態にして同期を停止させます。
# mdadm --fail /dev/md126 /dev/sda
状態を確認します。

# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sdb[0]
      3907015680 blocks super external:/md0/0 [2/1] [_U]

md0 : inactive sdb[1](S) sda[0](S)
      5544 blocks super external:imsm

同期が停止されて、指定したデバイスsdaが消えてユニット数が減っています。
次にRAID構成からデバイスを外します。
# mdadm --remove /dev/md0 sda
状態を確認します。

# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sdb[0]
      3907015680 blocks super external:/md0/0 [2/1] [_U]

md0 : inactive sdb[1](S)
      2772 blocks super external:imsm

md0の構成から指定したデバイスsdaが消えています。
ホットスワップ対応であれば、ここで対象HDDを取り外して交換出来ます。
未対応の場合は電源停止します。

今回はハードウェアRAIDコントローラーの場合で、ソフトウェアRAIDの場合は、
構成したパーティションに合わせて対象デバイスを全て外します。
また、swap利用の場合もデバイスを忘れずに解除します。

交換したHDDの同期作業

新しく交換したHDDを取り付けただけではRAID構成は再構築されませんので、
デバイスの同期作業を行います。
容量が2TBまでのHDDならば、旧来のfdisk -lで接続デバイスがリスト表示されます。
それ以上のHDDの場合は、partedコマンドを使用します。

インストール
# yum install parted

接続デバイスの表示

# parted -l
...
/dev/sdb (4001GB)
/dev/sdd (4001GB)
...

外したHDDと同じドライブレターが割り当てられるとは限りません。
今回の場合は同じユニットに接続してもドライブレターが変わりました。
/dev/sda → /dev/sdd
RAID構成に新しいHDDを追加します。
~ソフトウェアRAIDの場合は予めパーティションを作成をしますが、~
2017/09/15追記
FakeソフトウェアRAIDでLVMで構築でも同様に出来ました。

ハードウェアRAIDの場合はデバイスを追加するだけで再構成されます。
# mdadm --add /dev/md0 /dev/sdd
状態を確認します。

# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sdd[2] sdb[0]
      3907015680 blocks super external:/md0/0 [2/1] [_U]
      [>....................]  recovery =  0.0% (109568/3907015812) finish=1188.4min speed=54784K/sec

md0 : inactive sdd[0](S) sdb[1](S)
      5544 blocks super external:imsm

同期作業が開始されています。
パーティション構成情報はハードウェアRAID側で管理されていますので、作業完了までお任せします。

35
42
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
35
42