Kamis, 29 Juli 2010

RAID 1 yang rusak bagaimana memperbaikinya???

Beberapa waktu yang lalu server di cabang surabaya rusak karena mati lampu.karena ada server cadangan maka server cadangan siap take over dengan terlebih dulu mencopi data basenya. Nah semalam tuh baru sempet yoba ngerepair RAID 1 nya.Ternyata yang rusak Arraynya itu sdb.Dan Alhamdulilla tidak rusak fisiknya.

langkah yang saya lakukan adalah:

1. melihat status RAID 1 nya
/home/surabaya# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sdb2[0] sda2[1]
4907776 blocks [2/2] [UU]

md0 : active raid1 sda1[1]
73240192 blocks [2/1] [_U]

unused devices:
Berarti salah satu HD raidnya rusak.
Karena saya paranoid saya matikan dulu komputer lalu saya cabut satu hardisk yang tidak mau booting lalu saya fdisk -l
2. Pastikan HD yang rusak.
/home/surabaya# fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xb4ef48c6

Device Boot Start End Blocks Id System
/dev/sda1 * 1 9118 73240303+ fd Linux raid autodetect
/dev/sda2 9119 9729 4907857+ fd Linux raid autodetect

Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00043347

Ternyata yang rusak adalah sdb.
3. Selanjutnya Tandai jika sdb1 dan sdb2 di md0 dan md1 itu gagal.
/home/surabaya# mdadm --manage /dev/md0 --fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
4. Hapus sd1 di md0
/home/surabaya# mdadm --manage /dev/md0 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1
5. lakukan begitu pula untuk sdb2
/home/surabaya# mdadm --manage /dev/md1 --fail /dev/sdb2
mdadm: set /dev/sdb2 faulty in /dev/md1
mdadm --manage /dev/md1 --remove /dev/sdb2
mdadm: hot removed /dev/sdb2
6. Lihat statusnya Array lagi dengan mdstat
/home/surabaya# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda2[1]
4907776 blocks [2/1] [_U]

md0 : active raid1 sda1[1]
73240192 blocks [2/1] [_U]

unused devices:

Terlihat bahwa Array di kedua HD sda dan sdb masih belum bekerja.
7.Pada langkah ini anda harus reboot komputer karena jika tidak di restart pengalaman saya tidak bisa membangun RAID nya (proses lama tapi tidak kunjung selesai). pada Langkah ini pula jika sdb rusak fisik maka harus di ganti dengan HD baru.
8. Buat partisi di sdb dari sda
/home/surabaya# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 9729 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sdb1 * 0+ 9117 9118- 73240303+ fd Linux raid autodetect
/dev/sdb2 9118 9728 611 4907857+ fd Linux raid autodetect
/dev/sdb3 0 - 0 0 0 Empty
/dev/sdb4 0 - 0 0 0 Empty
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/sdb1 * 63 146480669 146480607 fd Linux raid autodetect
/dev/sdb2 146480670 156296384 9815715 fd Linux raid autodetect
/dev/sdb3 0 - 0 0 Empty
/dev/sdb4 0 - 0 0 Empty
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
9. Terakhir bangun kembali array nya di md0 sdb1 dan md1 sdb2
/home/surabaya# mdadm --manage /dev/md0 --add /dev/sdb1
mdadm: re-added /dev/sdb1
root@surabaya:/home/surabaya# mdadm --manage /dev/md1 --add /dev/sdb2
mdadm: re-added /dev/sdb2
bersamaan dengan itu juga system akan bekerja membangun RAID nya
lihat dengan perintah
/home/surabaya# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sdb2[2] sda2[1]
4907776 blocks [2/1] [_U]
resync=DELAYED

md0 : active raid1 sdb1[2] sda1[1]
73240192 blocks [2/1] [_U]
[>....................] recovery = 0.5% (405504/73240192) finish=50.8min speed=23853K/sec

unused devices:

md1 masih DELAYED karena proses md0 belum 100%
/home/surabaya# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sdb2[2] sda2[1]
4907776 blocks [2/1] [_U]
resync=DELAYED

md0 : active raid1 sdb1[2] sda1[1]
73240192 blocks [2/1] [_U]
[==================>..] recovery = 94.6% (69302336/73240192) finish=3.3min speed=19842K/sec

unused devices:
Proses di md0 hampir selesai.

jika sudah selesai maka akan lanjut ke proses md1
cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sdb2[2] sda2[1]
4907776 blocks [2/1] [_U]
[===========>.........] recovery = 58.9% (2893248/4907776) finish=2.1min speed=15388K/sec

md0 : active raid1 sdb1[0] sda1[1]
73240192 blocks [2/2] [UU]

unused devices:

Jika tidak ada masalah maka tampilan ketika di cat /proc/mdstat akan seperti ini.

/home/surabaya# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sdb2[0] sda2[1]
4907776 blocks [2/2] [UU]

md0 : active raid1 sdb1[0] sda1[1]
73240192 blocks [2/2] [UU]

unused devices:

Selamat mencoba....

Tidak ada komentar:

Posting Komentar