硬盤有價,數據無價,如果搭建的服務器是做文件存儲,而且所存儲的數據很重要的話,我一般會想盡辦法保證數據的安全性,並儘量多次,異地的數據備份。
備份的方式多種多樣,在這裏我只介紹最簡單而且超級實用的方法來減少數據丟失的風險。
網上介紹raid,也就是磁盤陣列的理論很多,以下是在公司實際運維中的搭建方法。
Part 1:配置raid5
準備工作:
1)三塊容量一樣的硬盤,可以是三塊500G,也可以是三塊1T等等,切記容量要一樣大,最好是同一批次的新硬盤,不要捨不得花錢在硬盤上,如果因爲硬盤的原因導致數據丟失,得不償失的。
2)CentOS 的linux操作系統,我用的Centos 6.4,只要是基於Redhat的應該都可以。
配置過程如下:
Part2:郵件提醒
當raid5磁盤陣列出問題時,我們怎麼知道呢,也許這臺服務器你很少去檢查,因爲是做數據存儲用,但如果raid壞了,或者硬盤損壞,我們又怎麼在第一時間知道呢。
網上有一些參考資料,又是要自己搭建郵件服務器,又是要寫複雜的檢查腳本,費力不討好。
具體配置如下:
steps
vim /etc/mail.rc: allow p4proxy to send email
at the button
set from=XXXXXXX#set send email address, you can change as you like
set smtp=XXXXXX#using our real smtp server
set smtp-auth-user=XXXXXXX#using your real email account
set smtp-auth-password=your_email_password#using your real email account password
cat /proc/mdstst > /root/mdstat# take a snapshot of raid array healthy /proc/mdstat file
vim /root/raid_monitor.sh#comparing /proc/mdstat and /root/mdstat files, if different then send email to inform.
auto run
vim /etc/crondtab#run this script every 2 hours:0 */2 * * * root /root/raid_monitor.sh