我的伺服器有三個相同的 SATA/600 3TB 硬碟:/dev/sda
、/dev/sdb
、/dev/sdc
。磁碟機使用 GPT 進行分割區,每個分割區包含三個分割區:
- 1 MB:為引導程式保留的分割區
- 1 GB:RAID1 /dev/md0 ( ext2 ( /boot ) )
- 3 TB:RAID1 /dev/md1(加密磁碟區(LVM(磁碟區組(Swap、/、/etc、/home ...))))
三個驅動器之一是熱備用驅動器,另外兩個驅動器在 RAID 集中處於活動狀態。它工作正常,我可以在斷開任何單一硬碟後啟動。我想用smartd(smartmontools 的一部分)監視驅動器的運行狀況並向系統日誌報告錯誤(我使用日誌檢查)。該伺服器應該具有盡可能高的可用性,但在測試過程中效能下降是可以接受的。
這是輸出smartctl -a /dev/sda
:
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.2.0-4-amd64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
=== START OF INFORMATION SECTION ===
Device Model: WDC WD30EZRX-00MMMB0
Serial Number: WD-WMAWZ0412093
LU WWN Device Id: 5 0014ee 2b19fbdcd
Firmware Version: 80.00A80
User Capacity: 3,000,592,982,016 bytes [3.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Fri Sep 27 15:37:25 2013 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: (50280) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 255) minutes.
Conveyance self-test routine
recommended polling time: ( 5) minutes.
SCT capabilities: (0x3035) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.
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 148 148 021 Pre-fail Always - 9575
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 95
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 099 099 000 Old_age Always - 820
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 - 93
192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 65
193 Load_Cycle_Count 0x0032 196 196 000 Old_age Always - 12824
194 Temperature_Celsius 0x0022 119 116 000 Old_age Always - 33
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 200 200 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0008 200 200 000 Old_age Offline - 0
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 787 -
# 2 Extended offline Completed without error 00% 727 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
貌似支援離線測試。當我發出時smartctl -o on
,smartctl -c
顯示Offline data collection status
已經設定為(0x82)
。如果我發出smartctl -o off
相同的值就會變成(0x02)
.
start_smartd=yes
我已經設定 smartd 透過設定來啟動伺服器/etc/default/smartmontools
。您建議我如何透過編輯/etc/smartd.conf
此伺服器來設定 smartd?請描述您使用的每個參數以及為什麼這樣使用它。
我將添加我當前的設定作為答案。請隨意使用它作為基礎並在您自己的答案中改進它。使用相同設定的更好描述也將是一種改進!
答案1
我從長時間的自我檢測轉向了select,cont
測試。這就像長時間的自測試,但一次只有一個磁碟片。因此,雖然長時間的自測試可能需要一天多的時間(對於繁忙的 3TB 磁碟),但選擇性測試可以在伺服器最不忙的每晚運行並實際完成,而不會損害更繁忙時間的效能。
因此,基本上,您將每月對整個磁碟進行一次長時間的自檢,然後進行夜間選擇性測試,該測試在一個月內仍然覆蓋整個磁碟。
但這需要一些準備。
smartd
必須使用該--savestates
選項運行,因為磁碟本身通常不會追蹤最後測試的區域。- 您必須手動啟動第一個選擇性自測 (
-t select,0-$size
),以便smartd
了解每天要測試的切片大小。大小決定了測試需要多長時間以及跨越整個磁碟的天數。 - 確保您選擇的 $size 與磁碟大小一致。否則,您將面臨最後一個切片非常小的風險(最壞的情況是您浪費一天時間僅測試磁碟的單一磁區)。
- 您必須驗證此資訊是否確實已儲存到 savestates 檔案中,因為有時沒有,然後測試將不會按照您想要的方式運行。 (直接編輯 savestate 檔案也是一種選擇)。
smartd.conf
該文件的語法為-s c/../.././01
(在本例中它將每天凌晨 1 點運行)。
然而,一旦完成,該過程就會自動且可靠。一旦到達磁碟末尾,它將自動從第二天的開始開始。閱讀smartctl
有關select,cont
測試的線上說明頁。
雖然長期或選擇性測試很棒,但您可能仍然應該運行短期或整體評估測試。它們只需要很短的時間,並且可以幫助檢測一般問題。
答案2
我們已將所有伺服器配置為執行定期自測試,其中包含以下行/etc/smartd.conf
:
# DEVICESCAN matches all hard disks found in /dev/ and applies the following
# options to them.
#
# Default options from Debian:
# -d removable don't exit when the device when a device vanishes
# -n standby don't wake a device up that is sleeping
# -m root send error reports to root
# -M exec ... pipe the mail through that script
#
# Our options:
# -s L/../02/./17 run a long selftest on every 2nd of every month
# at 17 o'clock
DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner -s L/../02/./17
在我看來,自我檢測是 SMART 提供的最可靠的健康檢查方式。
編輯:
您能解釋一下
-d removable
是什麼嗎?
從man smartd.conf
:
removable - the device or its media is removable. This indi‐
cates to smartd that it should continue (instead of exiting,
which is the default behavior) if the device does not appear to
be present when smartd is started. This Directive may be used
in conjunction with the other ´-d´ Directives.
我認為它可以防止smartd
當受監視的磁碟之一消失時死亡...?我不確定,我只是將該-s L/../02/./17
部分添加到該行中。原來的行:
DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner
是 Debian 的預設值。
答案3
# DEVICESCAN For all disks with SMART capabilities.
#
# -o off Turn off automatic running of offline tests. An offline test
# is a test which may degrade performance.
#
# -n standby Do not spin up the disk for the periodic 30 minute (default)
# SMART status polling, instead wait until the disk is active
# again and poll it then.
#
# -W 2 Report temperature changes of at least 2 degrees celsius since
# the last reading. Also report if a new min/max temperature is
# detected.
#
# -S on Auto save attributes such as how long the disk has been powered
# on, min and max disk temperature.
#
# -s (L/../.[02468]/1/04|S/../.[13579]/1/04)
# '-------a--------' '--------b-------'
#
# a: Long test on even monday mornings at 04:00
# b: Short test on uneven monday mornings at 04:00
DEVICESCAN -o off -n standby -W 2 -S on -s (L/../.[02468]/1/04|S/../.[13579]/1/04)
答案4
我通常使用這個簡單的檢查,它是按驅動器定義的,而不是按系統全局定義的(帶DEVICESCAN
選項) - 我對整體SMART 運行狀況以及自上次SMART 測試以來是否有任何待處理的扇區重新分配和任何錯誤扇區感興趣。任何可疑事件都會郵寄到我的智慧綜合地址:
/dev/sda -H -C 0 -U 0 -m [email protected]
在某些系統上,我已定義在特定日期自動執行 SMART 自檢。此規範定義每週日午夜後在兩個驅動器上運行長時間測試(但不是在同一時間 - 午夜到凌晨 1 點之間,然後從凌晨 2 點開始):
/dev/sda -a -s L/../../7/00 -m [email protected]
/dev/sdb -a -s L/../../7/02 -m [email protected]