Anda di halaman 1dari 9

Belajar Mengkonfigurasi Software RAID Menggunakan Tools Linux mdadm

Pada kesempatan kali ini saya ingin berbagi sedikit pengalaman bagaimana mengkonfigurasi software RAID menggunakan tools Linux mdadm. Sebagai informasi bahwa server yang digunakan adalah server Stratus dengan type 45XX dan Operating system yang digunakan adalah RHEL 5.X. Informasi layout server untuk slot HDD adalah sebagai berikut:

(Gambar-1, Layout Internal Naming) Kali ini kita akan mencoba membuat RAID-1 di device HDD slot /dev/sdd dan HDD slot /dev/sdl. Besarnya tiap HDD adalah 146GB SAS dan kecepatan rpm-nya 15K. Langkah-langkahnya adalah sebagai berikut: 1. Cek/memastikan apakah HDD dislot /dev/sdd dan /dev/sdl belum digunakan dan masih kosong. ----------------------------------------------------------------[root@toiletumum ~]# fdisk -l /dev/sdd Disk /dev/sdd: 146.5 GB, 146500042752 bytes 255 heads, 63 sectors/track, 17810 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System [root@toiletumum ~]# ----------------------------------------------------------------[root@toiletumum ~]# fdisk -l /dev/sdl Disk /dev/sdd: 146.5 GB, 146500042752 bytes 255 heads, 63 sectors/track, 17810 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System [root@toiletumum ~]# -----------------------------------------------------------------

2. Buat partisi baru menggunakan perintah fdisk di HDD pada slot /dev/sdd dan slot /dev/sdl. [root@toiletumum ~]# fdisk /dev/sdd The number of cylinders for this disk is set to 17810. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): ----------------------------------------------------------------Command (m for help): p Disk /dev/sdd: 146.5 GB, 146500042752 bytes 255 heads, 63 sectors/track, 17810 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System

Command (m for help): ----------------------------------------------------------------3. Ketik n untuk menambahkan partisi baru Command (m for help): n ----------------------------------------------------------------4. Ketik e atau p Command action e extended p primary partition (1-4) p ----------------------------------------------------------------5. Ketikan nomor partisi Partition number (1-4): 1 ----------------------------------------------------------------6. Ketikan nilai awal dan nilai akhir dari besarnya partisi yang diinginkan(pada kasus saya, saya menggunakan besaran default sehingga besaran partisi yang diinginkan adalah sebesar +/- 146GB.) First cylinder (1-17810, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-17810, default 17810): Using default value 17810 ----------------------------------------------------------------Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu

n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) ----------------------------------------------------------------7. Ketikan perintah t Command (m for help): t Selected partition 1 ----------------------------------------------------------------8. Ketikan perintah L Hex code (type L to list codes): l
0 1 2 3 4 5 6 7 8 9 a b c e f 10 11 12 14 16 17 18 1b 1c Empty FAT12 XENIX root XENIX usr FAT16 <32M Extended FAT16 HPFS/NTFS AIX AIX bootable OS/2 Boot Manag W95 FAT32 W95 FAT32 (LBA) W95 FAT16 (LBA) W95 Ext'd (LBA) OPUS Hidden FAT12 Compaq diagnost Hidden FAT16 <3 Hidden FAT16 Hidden HPFS/NTF AST SmartSleep Hidden W95 FAT3 Hidden W95 FAT3 1e 24 39 3c 40 41 42 4d 4e 4f 50 51 52 53 54 55 56 5c 61 63 64 65 70 75 Hidden W95 FAT1 NEC DOS Plan 9 PartitionMagic Venix 80286 PPC PReP Boot SFS QNX4.x QNX4.x 2nd part QNX4.x 3rd part OnTrack DM OnTrack DM6 Aux CP/M OnTrack DM6 Aux OnTrackDM6 EZ-Drive Golden Bow Priam Edisk SpeedStor GNU HURD or Sys Novell Netware Novell Netware DiskSecure Mult PC/IX 80 81 82 83 84 85 86 87 88 8e 93 94 9f a0 a5 a6 a7 a8 a9 ab b7 b8 bb be Old Minix Minix / old Lin Linux swap / So Linux OS/2 hidden C: Linux extended NTFS volume set NTFS volume set Linux plaintext Linux LVM Amoeba Amoeba BBT BSD/OS IBM Thinkpad hi FreeBSD OpenBSD NeXTSTEP Darwin UFS NetBSD Darwin boot BSDI fs BSDI swap Boot Wizard hid Solaris boot bf c1 c4 c6 c7 da db de df e1 e3 e4 eb ee ef f0 f1 f4 f2 fb fc fd fe ff Solaris DRDOS/sec (FATDRDOS/sec (FATDRDOS/sec (FATSyrinx Non-FS data CP/M / CTOS / . Dell Utility BootIt DOS access DOS R/O SpeedStor BeOS fs EFI GPT EFI (FAT-12/16/ Linux/PA-RISC b SpeedStor SpeedStor DOS secondary VMware VMFS VMware VMKCORE Linux raid auto LANstep BBT

----------------------------------------------------------------9. Jika kita ingin menginginkan type default (83) tekan enter,karena saya ingin menggunakan system pertisi Linux RAID autidetect, maka saya mengetikan perintah fd. Hex code (type L to list codes): fd Changed system type of partition 1 to fd (Linux raid autodetect) ----------------------------------------------------------------10. Ketikan perintah w untuk menulis tabel partisi kedisk dan kemudian keluar. Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@toiletumum ~]# -----------------------------------------------------------------

11. Lakukan langkah pada point 2 s/d 10 di slot hdd /dev/sdl [root@toiletumum ~]# fdisk /dev/sdl The number of cylinders for this disk is set to 17810. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-17810, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-17810, default 17810): Using default value 17810 Command (m for help): t Selected partition 1 Hex code (type L to list codes): fd Changed system type of partition 1 to fd (Linux raid autodetect) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@toiletumum ~]# ----------------------------------------------------------------12. Periksa hasil pekerjaan kita, apakah sudah sesuai dengan keinginan kita yaitu partisi tabel sebesar 146 GB dengan type Linux raid autodetect [root@toiletumum ~]# fdisk -l /dev/sdd Disk /dev/sdd: 146.5 GB, 146500042752 bytes 255 heads, 63 sectors/track, 17810 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End /dev/sdd1 1 17810 [root@toiletumum ~]# fdisk -l /dev/sdl Blocks 143058793+ Id fd System Linux raid autodetect

Disk /dev/sdl: 146.5 GB, 146500042752 bytes 255 heads, 63 sectors/track, 17810 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start /dev/sdl1 1 [root@toiletumum ~]# End 17810 Blocks 143058793+ Id fd System Linux raid autodetect

-----------------------------------------------------------------

----------------------------------------------------------------13. Cek tabel partisi dan mount-point existing [root@toiletumum ~]# df -h Filesystem Size /dev/md2 31G /dev/md3 33G /dev/md0 251M tmpfs 47G [root@toiletumum ~]# Used Avail Use% Mounted on 12G 19G 39% / 177M 31G 1% /var/crash 22M 216M 10% /boot 0 47G 0% /dev/shm

----------------------------------------------------------------14. Langkah selanjutnya adalah membuat RAID-1 dengan perintah berikut, dimana device baru bernama /dev/md20, menggunakan mode=1 (mirroring) dimana device pasangannya adalah /dev/sdd1 dan /dev/sdl1: [root@toiletumum ~]# mdadm -C /dev/md20 -b internal --level=1 --raid-devices=2 /dev/sdd1 /dev/sdl1 mdadm: array /dev/md20 started. ----------------------------------------------------------------15. Untuk mengecek status RAID yang sedang dibuat atau ingin mengetahui proses RAID yang sedang berjalan, bisa menggunakan perintah berikut: [root@toiletumum ~]# cat /proc/mdstat Personalities : [raid1] md20 : active raid1 sdx1[1] sdt1[0] 143058688 blocks [2/2] [UU] [>....................] resync = 1.6% (2421632/143058688) finish=13.5min speed=172973K/sec bitmap: 137/137 pages [548KB], 512KB chunk md0 : active raid1 sdq1[1] sdu1[0] 264960 blocks [2/2] [UU] bitmap: 0/33 pages [0KB], 4KB chunk md1 : active raid1 sdq3[1] sdu3[0] 12586816 blocks [2/2] [UU] bitmap: 0/193 pages [0KB], 32KB chunk md3 : active raid1 sdq5[1] sdu5[0] 34644032 blocks [2/2] [UU] bitmap: 0/133 pages [0KB], 128KB chunk md2 : active raid1 sdq2[1] sdu2[0] 33551680 blocks [2/2] [UU] bitmap: 2/128 pages [8KB], 128KB chunk unused devices: <none> [root@toiletumum ~]#

(Gambar-2,/dev/sdd dan /dev/sdl sedang dalam proses pembuatan RAID-1) ----------------------------------------------------------------16. Selain perintah cat /proc/mdstat, kita bisa juga menggunakan perintah lain untuk mengetahui status dari RAID. [root@toiletumum ~]# mdadm -Q --detail /dev/md20 /dev/md20: Version : 0.90 Creation Time : Tue Mar 4 10:01:21 2014 Raid Level : raid1 Array Size : 143058688 (136.43 GiB 146.49 GB) Used Dev Size : 143058688 (136.43 GiB 146.49 GB) Raid Devices : 2 Total Devices : 2 Preferred Minor : 20 Persistence : Superblock is persistent Intent Bitmap : Internal Update Time State Active Devices Working Devices Failed Devices Spare Devices : : : : : : Tue Mar 4 10:01:21 2014 active, resyncing 2 2 0 0

Rebuild Status : 7% complete UUID : ba54c955:ac61fc5d:87a88595:3947eac7 Events : 0.1 Number Major Minor RaidDevice State 0 65 49 0 active sync /dev/sdd1 1 65 113 1 active sync /dev/sdl1 [root@toiletumum ~]# -----------------------------------------------------------------

17. Untuk meload RAID array yang baru ketika booting tambahkan informasi array baru kedalam konfigurasi /etc/mdadm.conf [root@toiletumum ~]# mdadm --detail --scan -v ARRAY /dev/md2 level=raid1 num-devices=2 metadata=0.90 UUID=387b6b8a:1d33cd75:ed53c63b:4cd72ec1 devices=/dev/sdi2,/dev/sda2 ARRAY /dev/md3 level=raid1 num-devices=2 metadata=0.90 UUID=f08961db:2cad273a:a7b37711:2fb0462c devices=/dev/sdi5,/dev/sda5 ARRAY /dev/md1 level=raid1 num-devices=2 metadata=0.90 UUID=6887676b:1dee3134:6a63ea65:bb42a944 devices=/dev/sdi3,/dev/sda3 ARRAY /dev/md0 level=raid1 num-devices=2 metadata=0.90 UUID=01ff7fe7:af66d3f8:de336369:d34485c0 devices=/dev/sdi1,/dev/sda1 ARRAY /dev/md20 level=raid1 num-devices=2 metadata=0.90 UUID=ba54c955:ac61fc5d:87a88595:3947eac7 devices=/dev/sdd1,/dev/sdl1 [root@toiletumum ~]# ----------------------------------------------------------------# mdadm.conf written out by anaconda DEVICE partitions MAILADDR root ARRAY /dev/md2 level=raid1 num-devices=2 uuid=387b6b8a:1d33cd75:ed53c63b:4cd72ec1 ARRAY /dev/md3 level=raid1 num-devices=2 uuid=f08961db:2cad273a:a7b37711:2fb0462c ARRAY /dev/md0 level=raid1 num-devices=2 uuid=01ff7fe7:af66d3f8:de336369:d34485c0 ARRAY /dev/md1 level=raid1 num-devices=2 uuid=6887676b:1dee3134:6a63ea65:bb42a944 ARRAY /dev/md20 level=raid1 num-devices=2 UUID=ba54c955:ac61fc5d:87a88595:3947eac7 ----------------------------------------------------------------18. Untuk menggunakan raw disk block devices yang baru dibuat kita harus memformat dam me-mounting nya terlebih dahulu (Pada percobaan saya menggunakan journaling EXT3). [root@toiletumum /]# mkfs.ext3 /dev/md20 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 17891328 inodes, 35764672 blocks 1788233 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 1092 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Writing inode tables: done

Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 30 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@toiletumum /]# [root@toiletumum /]# ----------------------------------------------------------------19. Mount hasil dari langkah 18 ke mountpoint yang kita inginkan. [root@toiletumum /]# mount /dev/md20 /bayar_seribu/ [root@toiletumum /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/md2 31G 12G 19G 39% / /dev/md3 33G 177M 31G 1% /var/crash /dev/md0 251M 22M 216M 10% /boot tmpfs 47G 0 47G 0% /dev/shm /dev/md20 135G 188M 128G 1% /bayar_seribu [root@toiletumum /]# [root@toiletumum /]# df /bayar_seribu/ Filesystem 1K-blocks Used Available Use% Mounted on /dev/md20 140812936 192132 133467872 1% /bayar_seribu [root@toiletumum /]# ----------------------------------------------------------------[root@toiletumum /]# ls -l /bayar_seribu/ total 16 drwx------ 2 root root 16384 Mar 4 10:18 lost+found [root@toiletumum /]# ----------------------------------------------------------------20. Jangan lupa tambahkan mount-point baru di fstab agar bisa termounting secara otomatis ketika server direstart. [root@toiletumum /]# cat /etc/fstab /dev/md2 / ext3 defaults /dev/md3 /var/crash ext3 defaults /dev/md0 /boot ext3 defaults tmpfs /dev/shm tmpfs defaults devpts /dev/pts devpts gid=5,mode=620 sysfs /sys sysfs defaults proc /proc proc defaults /dev/md1 swap swap defaults /dev/scd1 /media/cdrecorder auto pamconsole,exec,noauto,managed 0 0 /dev/md20 /bayar_seribu ext3 defaults [root@toiletumum /]# ----------------------------------------------------------------1 1 1 0 0 0 0 0 1 2 2 0 0 0 0 0

0 0

21. Cek hasil hasilnya dengan cara merestart server. [root@toiletumum ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/md2 31G 12G 19G 39% / /dev/md3 33G 177M 31G 1% /var/crash /dev/md0 251M 22M 216M 10% /boot tmpfs 47G 0 47G 0% /dev/shm /dev/md20 135G 188M 128G 1% /bayar_seribu [root@toiletumum ~]# cd /bayar_seribu/ [root@toiletumum bayar_seribu]# ls lost+found [root@toiletumum bayar_seribu]# mkdir test.txt [root@toiletumum bayar_seribu]# ls lost+found test.txt [root@toiletumum bayar_seribu]# pwd /bayar_seribu [root@toiletumum bayar_seribu]# ----------------------------------------------------------------Sekian pengalamam dari saya, mudah-mudahan dapat bermanfaat. Ref: [1].http://stratadoc.stratus.com/linux/4.1.0/r003l-05a/wwhelp/wwhimpl/common/ html/r003l-05a.pdf, (Diakses Februari 2014) [2]. http://en.wikipedia.org/wiki/Mdadm, (Diakses Februari 2014).